From ef1348fe935d56ebef57c03f200ca013c6a76545 Mon Sep 17 00:00:00 2001 From: Andre Henriques Date: Tue, 10 Oct 2023 14:58:18 +0100 Subject: [PATCH] feat: closes #38 --- logic/models/classes/list.go | 5 +++-- logic/models/train/train.go | 5 +++-- views/index.html | 2 +- views/layout.html | 1 + views/models/edit.html | 14 ++++++++++++-- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/logic/models/classes/list.go b/logic/models/classes/list.go index 7dd2082..b6433d9 100644 --- a/logic/models/classes/list.go +++ b/logic/models/classes/list.go @@ -48,7 +48,7 @@ func HandleList(handle *Handle) { return Error500(nil) } - rows, err := handle.Db.Query("select id, file_path, model_mode from model_data_point where class_id=$1 limit 10 offset $2;", id, page * 10) + rows, err := handle.Db.Query("select id, file_path, model_mode, status from model_data_point where class_id=$1 limit 10 offset $2;", id, page * 10) if err != nil { return Error500(err) } @@ -58,13 +58,14 @@ func HandleList(handle *Handle) { Id string FilePath string Mode int + Status int } got := []baserow{} for rows.Next() { nrow := baserow{} - err = rows.Scan(&nrow.Id, &nrow.FilePath, &nrow.Mode) + err = rows.Scan(&nrow.Id, &nrow.FilePath, &nrow.Mode, &nrow.Status) if err != nil { return Error500(err) } diff --git a/logic/models/train/train.go b/logic/models/train/train.go index ee24dfd..68a5b23 100644 --- a/logic/models/train/train.go +++ b/logic/models/train/train.go @@ -326,7 +326,7 @@ func trainModel(c *Context, model *BaseModel) { } func removeFailedDataPoints(db *sql.DB, model *BaseModel) (err error) { - rows, err := db.Query("select id from model_data_point as mdp join model_classes as mc on mc.id=mpd.class_id where mc.model_id=$1 and mdp.status=-1;", model.Id) + rows, err := db.Query("select mdp.id from model_data_point as mdp join model_classes as mc on mc.id=mdp.class_id where mc.model_id=$1 and mdp.status=-1;", model.Id) if err != nil { return } @@ -346,6 +346,7 @@ func removeFailedDataPoints(db *sql.DB, model *BaseModel) (err error) { } } + _, err = db.Exec("delete from model_data_point as mdp using model_classes as mc where mdp.class_id = mc.id and mc.model_id=$1 and mdp.status=-1;", model.Id) return } @@ -418,7 +419,7 @@ func handleTrain(handle *Handle) { return c.Error500(err) } - err = removeFailedDataPoints(c.Db, model.Id) + err = removeFailedDataPoints(c.Db, model) if err != nil { return c.Error500(err) } diff --git a/views/index.html b/views/index.html index 05224e4..553fcdc 100644 --- a/views/index.html +++ b/views/index.html @@ -1,6 +1,6 @@ {{ define "title"}} Home : AI Stuff {{ end }} {{ define "mainbody" }} - hey bitches + Main Page TODO {{ end }} diff --git a/views/layout.html b/views/layout.html index 2e5b79f..3bca6e3 100644 --- a/views/layout.html +++ b/views/layout.html @@ -11,6 +11,7 @@ + {{ block "other_imports" . }} {{end}} diff --git a/views/models/edit.html b/views/models/edit.html index e862c7c..fb42885 100644 --- a/views/models/edit.html +++ b/views/models/edit.html @@ -57,6 +57,9 @@ + + + @@ -84,6 +87,13 @@ img {{ .FilePath }} {{ end }} + + {{ if eq .Status 1 }} + + {{ else }} + + {{ end }} + {{end}} @@ -249,7 +259,7 @@

{{ if gt .NumberOfInvalidImages 0 }}

- There are images that were loaded that do not have the correct format. These images will be delete when the model trains. + There are images {{ .NumberOfInvalidImages }} that were loaded that do not have the correct format. These images will be delete when the model trains.

{{ end }}
@@ -275,7 +285,7 @@ {{ if .HasData }} {{ if gt .NumberOfInvalidImages 0 }}

- There are images that were loaded that do not have the correct format. These images will be delete when the model trains. + There are images {{ .NumberOfInvalidImages }} that were loaded that do not have the correct format. These images will be delete when the model trains.

{{ end }} {{/* TODO expading mode */}}