2023-09-22 19:22:36 +01:00
|
|
|
-- drop table if exists model_data_point;
|
2023-09-26 20:15:28 +01:00
|
|
|
-- drop table if exists model_definition_layer;
|
|
|
|
-- drop table if exists model_definition;
|
2023-09-21 15:38:02 +01:00
|
|
|
-- drop table if exists models;
|
|
|
|
create table if not exists models (
|
|
|
|
id uuid primary key default gen_random_uuid(),
|
|
|
|
user_id uuid references users (id) not null,
|
|
|
|
name varchar (70) not null,
|
|
|
|
-- Status:
|
|
|
|
-- -1: failed preparing
|
|
|
|
-- 1: preparing
|
|
|
|
status integer default 1,
|
2024-01-31 21:48:35 +00:00
|
|
|
|
|
|
|
-- Types:
|
|
|
|
-- 0: Unset
|
|
|
|
-- 1: simple
|
|
|
|
-- 2: expandable
|
|
|
|
model_type integer default 0,
|
2023-09-21 15:38:02 +01:00
|
|
|
|
|
|
|
width integer,
|
|
|
|
height integer,
|
2023-10-06 12:13:19 +01:00
|
|
|
color_mode varchar (20),
|
2023-10-22 23:02:39 +01:00
|
|
|
format varchar (20) default ''
|
2023-09-21 15:38:02 +01:00
|
|
|
);
|
|
|
|
|
2023-09-22 19:22:36 +01:00
|
|
|
-- drop table if exists model_data_point;
|
2023-09-21 16:43:11 +01:00
|
|
|
-- drop table if exists model_classes;
|
|
|
|
create table if not exists model_classes (
|
|
|
|
id uuid primary key default gen_random_uuid(),
|
2023-09-22 19:22:36 +01:00
|
|
|
model_id uuid references models (id) on delete cascade,
|
2023-10-02 21:15:31 +01:00
|
|
|
name varchar (70) not null,
|
2024-03-06 23:33:54 +00:00
|
|
|
class_order integer,
|
|
|
|
|
|
|
|
-- 1: to_train
|
|
|
|
-- 2: training
|
|
|
|
-- 3: trained
|
|
|
|
status integer default 1,
|
2023-09-21 16:43:11 +01:00
|
|
|
);
|
2023-09-22 19:22:36 +01:00
|
|
|
|
|
|
|
-- drop table if exists model_data_point;
|
|
|
|
create table if not exists model_data_point (
|
|
|
|
id uuid primary key default gen_random_uuid(),
|
|
|
|
class_id uuid references model_classes (id) on delete cascade,
|
|
|
|
file_path text not null,
|
|
|
|
-- 1 training
|
|
|
|
-- 2 testing
|
2023-10-10 12:28:49 +01:00
|
|
|
model_mode integer default 1,
|
|
|
|
-- -1 Error on creation
|
|
|
|
-- 1 OK
|
|
|
|
status integer not null,
|
|
|
|
status_message text
|
2023-09-22 19:22:36 +01:00
|
|
|
);
|
2023-09-26 20:15:28 +01:00
|
|
|
|
|
|
|
-- drop table if exists model_definition;
|
|
|
|
create table if not exists model_definition (
|
|
|
|
id uuid primary key default gen_random_uuid(),
|
|
|
|
model_id uuid references models (id) on delete cascade,
|
2023-10-21 00:26:52 +01:00
|
|
|
accuracy real default 0,
|
2023-09-26 20:15:28 +01:00
|
|
|
target_accuracy integer not null,
|
|
|
|
epoch integer default 0,
|
|
|
|
-- TODO add max epoch
|
|
|
|
-- 1: Pre Init
|
|
|
|
-- 2: Init
|
|
|
|
-- 3: Training
|
|
|
|
-- 4: Tranied
|
|
|
|
-- 5: Ready
|
|
|
|
status integer default 1,
|
2023-10-12 12:08:12 +01:00
|
|
|
created_on timestamp default current_timestamp,
|
|
|
|
epoch_progress integer default 0
|
2023-09-26 20:15:28 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
-- drop table if exists model_definition_layer;
|
|
|
|
create table if not exists model_definition_layer (
|
|
|
|
id uuid primary key default gen_random_uuid(),
|
|
|
|
def_id uuid references model_definition (id) on delete cascade,
|
|
|
|
layer_order integer not null,
|
|
|
|
-- 1: input
|
|
|
|
-- 2: dense
|
|
|
|
-- 3: flatten
|
|
|
|
-- TODO add conv
|
|
|
|
layer_type integer not null,
|
|
|
|
-- ei 28,28,1
|
|
|
|
-- a 28x28 grayscale image
|
2024-01-31 21:48:35 +00:00
|
|
|
shape text not null,
|
|
|
|
|
|
|
|
-- Type based on the expandability
|
|
|
|
-- 0: not expandalbe model
|
|
|
|
-- 1: fixed
|
|
|
|
-- 2: head
|
|
|
|
exp_type integer default 0
|
|
|
|
);
|
|
|
|
|
|
|
|
-- drop table if exists exp_model_head;
|
|
|
|
create table if not exists exp_model_head (
|
|
|
|
id uuid primary key default gen_random_uuid(),
|
|
|
|
def_id uuid references model_definition (id) on delete cascade,
|
|
|
|
-- Start order id to the class that this model satifies inclusive
|
|
|
|
range_start integer not null,
|
|
|
|
-- end order id to the class that this model satifies inclusive
|
|
|
|
range_end integer not null,
|
|
|
|
|
|
|
|
accuracy real default 0,
|
|
|
|
|
|
|
|
-- TODO add max epoch
|
|
|
|
-- 1: Pre Init
|
|
|
|
-- 2: Init
|
|
|
|
-- 3: Training
|
|
|
|
-- 4: Tranied
|
|
|
|
-- 5: Ready
|
|
|
|
status integer default 1,
|
|
|
|
created_on timestamp default current_timestamp,
|
|
|
|
epoch_progress integer default 0
|
2023-09-26 20:15:28 +01:00
|
|
|
);
|
|
|
|
|