feat: closes #38

This commit is contained in:
Andre Henriques 2023-10-10 14:58:18 +01:00
parent b6afecc682
commit ef1348fe93
5 changed files with 20 additions and 7 deletions

View File

@ -48,7 +48,7 @@ func HandleList(handle *Handle) {
return Error500(nil) 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 { if err != nil {
return Error500(err) return Error500(err)
} }
@ -58,13 +58,14 @@ func HandleList(handle *Handle) {
Id string Id string
FilePath string FilePath string
Mode int Mode int
Status int
} }
got := []baserow{} got := []baserow{}
for rows.Next() { for rows.Next() {
nrow := baserow{} 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 { if err != nil {
return Error500(err) return Error500(err)
} }

View File

@ -326,7 +326,7 @@ func trainModel(c *Context, model *BaseModel) {
} }
func removeFailedDataPoints(db *sql.DB, model *BaseModel) (err error) { 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 { if err != nil {
return 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 return
} }
@ -418,7 +419,7 @@ func handleTrain(handle *Handle) {
return c.Error500(err) return c.Error500(err)
} }
err = removeFailedDataPoints(c.Db, model.Id) err = removeFailedDataPoints(c.Db, model)
if err != nil { if err != nil {
return c.Error500(err) return c.Error500(err)
} }

View File

@ -1,6 +1,6 @@
{{ define "title"}} Home : AI Stuff {{ end }} {{ define "title"}} Home : AI Stuff {{ end }}
{{ define "mainbody" }} {{ define "mainbody" }}
hey bitches Main Page TODO
{{ end }} {{ end }}

View File

@ -11,6 +11,7 @@
<link rel="stylesheet" href="/styles/main.css" > <link rel="stylesheet" href="/styles/main.css" >
<link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
{{ block "other_imports" . }} {{end}} {{ block "other_imports" . }} {{end}}
</head> </head>

View File

@ -57,6 +57,9 @@
<th> <th>
<!-- Img --> <!-- Img -->
</th> </th>
<th>
<!-- Status -->
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -84,6 +87,13 @@
img {{ .FilePath }} img {{ .FilePath }}
{{ end }} {{ end }}
</td> </td>
<td class="text-center">
{{ if eq .Status 1 }}
<span class="bi bi-check-circle-fill" style="color: green"></span>
{{ else }}
<span class="bi bi-exclamation-triangle-fill" style="color: red"></span>
{{ end }}
</td>
</tr> </tr>
{{end}} {{end}}
</tbody> </tbody>
@ -249,7 +259,7 @@
</p> </p>
{{ if gt .NumberOfInvalidImages 0 }} {{ if gt .NumberOfInvalidImages 0 }}
<p class="danger"> <p class="danger">
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.
</p> </p>
{{ end }} {{ end }}
<div class="tabs"> <div class="tabs">
@ -275,7 +285,7 @@
{{ if .HasData }} {{ if .HasData }}
{{ if gt .NumberOfInvalidImages 0 }} {{ if gt .NumberOfInvalidImages 0 }}
<p class="danger"> <p class="danger">
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.
</p> </p>
{{ end }} {{ end }}
{{/* TODO expading mode */}} {{/* TODO expading mode */}}