chore: closes #21, #20

This commit is contained in:
2023-09-27 21:20:39 +01:00
parent eab788aabd
commit 194277297f
9 changed files with 465 additions and 94 deletions

View File

@@ -288,6 +288,30 @@
</form>
{{ end }}
{{ define "run-model-card" }}
<form hx-headers='{"REQUEST-TYPE": "html"}' enctype="multipart/form-data" hx-post="/models/run">
<input type="hidden" name="id" value={{.Model.Id}} />
<fieldset class="file-upload" >
<label for="file">Image</label>
<div class="form-msg">
Run image through them model and get the result
</div>
<div class="icon-holder">
<button class="icon">
<img replace="icon" src="/imgs/upload-icon.png" />
<span replace="File Selected">
Image File
</span>
</button>
<input id="file" name="file" type="file" required accept="application/zip" />
</div>
</fieldset>
<button>
Run
</button>
</form>
{{ end }}
{{ define "mainbody" }}
<main>
{{ if (eq .Model.Status 1) }}
@@ -345,7 +369,7 @@
Processing zip file...
</div>
{{/* FAILED TO Prepare for training */}}
{{ else if (eq .Model.Status -3)}}
{{ else if or (eq .Model.Status -3) (eq .Model.Status -4)}}
{{ template "base-model-card" . }}
<form hx-delete="/models/train/reset" hx-headers='{"REQUEST-TYPE": "html"}' hx-swap="outerHTML">
Failed Prepare for training.<br/>
@@ -364,9 +388,11 @@
{{/* TODO Add progress status on definitions */}}
{{/* TODO Add aility to stop training */}}
</div>
<button hx-post="/models/train/test?id={{ .Model.Id }}" hx-headers='{"REQUEST-TYPE": "html"}'>
Test
</button>
{{/* Model Ready */}}
{{ else if (eq .Model.Status 5)}}
{{ template "base-model-card" . }}
{{ template "run-model-card" . }}
{{ template "delete-model-card" . }}
{{ else }}
<h1>
Unknown Status of the model.

View File

@@ -46,7 +46,7 @@ model.compile(
optimizer=tf.keras.optimizers.Adam(),
metrics=['accuracy'])
his = model.fit(dataset, validation_data= dataset_validation, epochs=50)
his = model.fit(dataset, validation_data= dataset_validation, epochs=70)
acc = his.history["accuracy"]
@@ -54,4 +54,6 @@ f = open("accuracy.val", "w")
f.write(str(acc[-1]))
f.close()
model.save("model.keras")
tf.saved_model.save(model, "model")
# model.save("model.keras", save_format="tf")