parent
c844aeabe4
commit
beeb42be56
@ -99,12 +99,14 @@ func handleEdit(handle *Handle) {
|
||||
case TRAINING:
|
||||
|
||||
type defrow struct {
|
||||
Id string
|
||||
Status int
|
||||
EpochProgress int
|
||||
Epoch int
|
||||
Accuracy float64
|
||||
}
|
||||
|
||||
def_rows, err := c.Db.Query("select status, epoch_progress, accuracy from model_definition where model_id=$1", model.Id)
|
||||
def_rows, err := c.Db.Query("select id, status, epoch, epoch_progress, accuracy from model_definition where model_id=$1 order by created_on asc", model.Id)
|
||||
if err != nil {
|
||||
return c.Error500(err)
|
||||
}
|
||||
@ -114,16 +116,54 @@ func handleEdit(handle *Handle) {
|
||||
|
||||
for def_rows.Next() {
|
||||
var def defrow
|
||||
err = def_rows.Scan(&def.Status, &def.EpochProgress, &def.Accuracy)
|
||||
err = def_rows.Scan(&def.Id, &def.Status, &def.Epoch, &def.EpochProgress, &def.Accuracy)
|
||||
if err != nil {
|
||||
return c.Error500(err)
|
||||
}
|
||||
defs = append(defs, def)
|
||||
}
|
||||
|
||||
type layerdef struct {
|
||||
LayerType int
|
||||
Shape string
|
||||
}
|
||||
|
||||
layers := []layerdef{}
|
||||
|
||||
for _, def := range defs {
|
||||
if def.Status == MODEL_DEFINITION_STATUS_TRAINING {
|
||||
rows, err := c.Db.Query("select layer_type, shape from model_definition_layer where def_id=$1 order by layer_order asc;", def.Id)
|
||||
if err != nil {
|
||||
return c.Error500(err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
for rows.Next() {
|
||||
var layerdef layerdef
|
||||
err = rows.Scan(&layerdef.LayerType, &layerdef.Shape)
|
||||
if err != nil {
|
||||
return c.Error500(err)
|
||||
}
|
||||
layers = append(layers, layerdef)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
sep_mod := 100
|
||||
if len(layers) > 8 {
|
||||
sep_mod = 100 - (len(layers)-8)*10
|
||||
}
|
||||
|
||||
if sep_mod < 10 {
|
||||
sep_mod = 10
|
||||
}
|
||||
|
||||
LoadBasedOnAnswer(c.Mode, w, "/models/edit.html", c.AddMap(AnyMap{
|
||||
"Model": model,
|
||||
"Defs": defs,
|
||||
"Model": model,
|
||||
"Defs": defs,
|
||||
"Layers": layers,
|
||||
"SepMod": sep_mod,
|
||||
}))
|
||||
case PREPARING_ZIP_FILE:
|
||||
LoadBasedOnAnswer(c.Mode, w, "/models/edit.html", c.AddMap(AnyMap{
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/utils"
|
||||
)
|
||||
|
||||
const EPOCH_PER_RUN = 20
|
||||
const EPOCH_PER_RUN = 1
|
||||
const MAX_EPOCH = 100
|
||||
|
||||
func MakeDefenition(db *sql.DB, model_id string, target_accuracy int) (id string, err error) {
|
||||
@ -36,28 +36,6 @@ func MakeDefenition(db *sql.DB, model_id string, target_accuracy int) (id string
|
||||
return
|
||||
}
|
||||
|
||||
type ModelDefinitionStatus int
|
||||
|
||||
const (
|
||||
MODEL_DEFINITION_STATUS_CANCELD_TRAINING = -4
|
||||
MODEL_DEFINITION_STATUS_FAILED_TRAINING = -3
|
||||
MODEL_DEFINITION_STATUS_PRE_INIT ModelDefinitionStatus = 1
|
||||
MODEL_DEFINITION_STATUS_INIT = 2
|
||||
MODEL_DEFINITION_STATUS_TRAINING = 3
|
||||
MODEL_DEFINITION_STATUS_PAUSED_TRAINING = 6
|
||||
MODEL_DEFINITION_STATUS_TRANIED = 4
|
||||
MODEL_DEFINITION_STATUS_READY = 5
|
||||
)
|
||||
|
||||
type LayerType int
|
||||
|
||||
const (
|
||||
LAYER_INPUT LayerType = 1
|
||||
LAYER_DENSE = 2
|
||||
LAYER_FLATTEN = 3
|
||||
LAYER_SIMPLE_BLOCK = 4
|
||||
)
|
||||
|
||||
func ModelDefinitionUpdateStatus(c *Context, id string, status ModelDefinitionStatus) (err error) {
|
||||
_, err = c.Db.Exec("update model_definition set status = $1 where id = $2", status, id)
|
||||
return
|
||||
@ -301,7 +279,10 @@ func trainModel(c *Context, model *BaseModel) {
|
||||
}
|
||||
def.epoch += EPOCH_PER_RUN
|
||||
accuracy = accuracy * 100
|
||||
def.acuracy = accuracy
|
||||
def.acuracy = float64(accuracy)
|
||||
|
||||
definitions[i].epoch += EPOCH_PER_RUN
|
||||
definitions[i].acuracy = accuracy
|
||||
|
||||
if accuracy >= float64(def.target_accuracy) {
|
||||
c.Logger.Info("Found a definition that reaches target_accuracy!")
|
||||
@ -361,11 +342,11 @@ func trainModel(c *Context, model *BaseModel) {
|
||||
continue
|
||||
}
|
||||
|
||||
sort.Sort(definitions)
|
||||
sort.Reverse(definitions)
|
||||
|
||||
acc := definitions[0].acuracy - 20
|
||||
acc := definitions[0].acuracy - 20.0
|
||||
|
||||
c.Logger.Info("Training models, Highest acc", "acc", acc)
|
||||
c.Logger.Info("Training models, Highest acc", "acc", definitions[0].acuracy, "mod_acc", acc)
|
||||
|
||||
toRemove = []int{}
|
||||
for i, def := range definitions {
|
||||
|
@ -29,14 +29,40 @@ const (
|
||||
READY = 5
|
||||
)
|
||||
|
||||
type ModelDefinitionStatus int
|
||||
|
||||
type LayerType int
|
||||
|
||||
const (
|
||||
LAYER_INPUT LayerType = 1
|
||||
LAYER_DENSE = 2
|
||||
LAYER_FLATTEN = 3
|
||||
LAYER_SIMPLE_BLOCK = 4
|
||||
)
|
||||
|
||||
const (
|
||||
MODEL_DEFINITION_STATUS_CANCELD_TRAINING ModelDefinitionStatus = -4
|
||||
MODEL_DEFINITION_STATUS_FAILED_TRAINING = -3
|
||||
MODEL_DEFINITION_STATUS_PRE_INIT = 1
|
||||
MODEL_DEFINITION_STATUS_INIT = 2
|
||||
MODEL_DEFINITION_STATUS_TRAINING = 3
|
||||
MODEL_DEFINITION_STATUS_PAUSED_TRAINING = 6
|
||||
MODEL_DEFINITION_STATUS_TRANIED = 4
|
||||
MODEL_DEFINITION_STATUS_READY = 5
|
||||
)
|
||||
|
||||
var ModelNotFoundError = errors.New("Model not found error")
|
||||
|
||||
func GetBaseModel(db *sql.DB, id string) (base *BaseModel, err error) {
|
||||
rows, err := db.Query("select name, status, id, width, height, color_mode, format from models where id=$1;", id)
|
||||
if err != nil { return }
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
if !rows.Next() { return nil, ModelNotFoundError }
|
||||
if !rows.Next() {
|
||||
return nil, ModelNotFoundError
|
||||
}
|
||||
|
||||
base = &BaseModel{}
|
||||
var colorMode string
|
||||
|
@ -563,12 +563,12 @@ func (x Handle) ReadTypesFiles(pathTest string, baseFilePath string, fileTypes [
|
||||
// fmt.Printf("Requested path: %s\n", user_path)
|
||||
|
||||
found := false
|
||||
index := -1;
|
||||
index := -1
|
||||
|
||||
for i, fileType := range fileTypes {
|
||||
if strings.HasSuffix(user_path, fileType) {
|
||||
found = true
|
||||
index = i;
|
||||
index = i
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -637,5 +637,11 @@ func NewHandler(db *sql.DB) *Handle {
|
||||
|
||||
func (x Handle) Startup() {
|
||||
fmt.Printf("Starting up!\n")
|
||||
log.Fatal(http.ListenAndServe(":8000", nil))
|
||||
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8000"
|
||||
}
|
||||
|
||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
|
||||
}
|
||||
|
@ -437,6 +437,9 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Done Progress
|
||||
</th>
|
||||
<th>
|
||||
Training Round Progress
|
||||
</th>
|
||||
@ -451,6 +454,9 @@
|
||||
<tbody>
|
||||
{{ range .Defs}}
|
||||
<tr>
|
||||
<td>
|
||||
{{.Epoch}}
|
||||
</td>
|
||||
<td>
|
||||
{{.EpochProgress}}/20
|
||||
</td>
|
||||
@ -471,6 +477,49 @@
|
||||
{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
{{ if (eq .Status 3) }}
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<svg viewBox="0 200 1000 600">
|
||||
{{ range $i, $layer := $.Layers }}
|
||||
{{ if (eq $layer.LayerType 1)}}
|
||||
<polygon
|
||||
points="50,450 200,250 200,550 50,750"
|
||||
stroke="black"
|
||||
stroke-width="2"
|
||||
fill="green"></polygon>
|
||||
{{ else if (eq $layer.LayerType 4)}}
|
||||
<polygon
|
||||
points="{{add 50 (mul $i $.SepMod) }},450 {{ add 200 (mul $i $.SepMod) }},250 {{add 200 (mul $i $.SepMod)}},550 {{ add 50 (mul $i $.SepMod) }},750"
|
||||
stroke="black"
|
||||
stroke-width="2"
|
||||
fill="orange">
|
||||
</polygon>
|
||||
{{ else if (eq $layer.LayerType 3)}}
|
||||
<polygon
|
||||
points="{{add 50 (mul $i $.SepMod) }},450 {{ add 200 (mul $i $.SepMod) }},250 {{add 200 (mul $i $.SepMod)}},550 {{ add 50 (mul $i $.SepMod) }},750"
|
||||
stroke="black"
|
||||
stroke-width="2"
|
||||
fill="red">
|
||||
</polygon>
|
||||
{{ else if (eq $layer.LayerType 2)}}
|
||||
<polygon
|
||||
points="{{add 50 (mul $i $.SepMod) }},550 {{ add 200 (mul $i $.SepMod) }},350 {{add 200 (mul $i $.SepMod)}},450 {{ add 50 (mul $i $.SepMod) }},650"
|
||||
stroke="black"
|
||||
stroke-width="2"
|
||||
fill="blue">
|
||||
</polygon>
|
||||
{{ else }}
|
||||
<div>
|
||||
{{ .LayerType }}
|
||||
{{ .Shape }}
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</svg>
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user