diff --git a/a.out b/a.out new file mode 100755 index 0000000..bdddb1f Binary files /dev/null and b/a.out differ diff --git a/logic/models/index.go b/logic/models/index.go index fa0258b..ef3e194 100644 --- a/logic/models/index.go +++ b/logic/models/index.go @@ -18,6 +18,7 @@ func HandleModels (handle *Handle) { model_classes.HandleList(handle) // Train endpoints + handleRun(handle) models_train.HandleTrainEndpoints(handle) } diff --git a/logic/models/run.go b/logic/models/run.go index 2694c9f..8ece6af 100644 --- a/logic/models/run.go +++ b/logic/models/run.go @@ -70,19 +70,20 @@ func handleRun(handle *Handle) { } definitions_rows, err := handle.Db.Query("select id from model_definition where model_id=$1;", model.Id) - if !definitions_rows.Next() { - // TODO improve this - return ErrorCode(nil, 400, c.AddMap(nil)) + if err != nil { + return Error500(err) } defer definitions_rows.Close() if !definitions_rows.Next() { - return Error500(nil) + // TODO improve this + fmt.Printf("Could not find definition\n") + return ErrorCode(nil, 400, c.AddMap(nil)) } var def_id string if err = definitions_rows.Scan(&def_id); err != nil { - return Error500(nil) + return Error500(err) } // TODO create a database table with tasks @@ -97,18 +98,21 @@ func handleRun(handle *Handle) { img_file.Write(file) root := tg.NewRoot() - tf_img := image.Read(root, path.Join(run_path, "img.png"), 1) - tf_model := tg.LoadModel(path.Join("savedData", model.Id, "defs", def_id, "model"), []string{"serve"}, nil) + tf_img := image.Read(root, path.Join(run_path, "img.png"), 3) - tf_img_tensor, err := tf.NewTensor(tf_img.Value()) + batch := tg.Batchify(root, []tf.Output{tf_img.Value()}) + exec_results := tg.Exec(root, []tf.Output{batch}, nil, &tf.SessionOptions{}) + inputImage, err:= tf.NewTensor(exec_results[0].Value()) if err != nil { return Error500(err) } + tf_model := tg.LoadModel(path.Join("savedData", model.Id, "defs", def_id, "model"), []string{"serve"}, nil) + results := tf_model.Exec([]tf.Output{ tf_model.Op("StatefulPartitionedCall", 0), }, map[tf.Output]*tf.Tensor{ - tf_model.Op("serving_default_inputs_input", 0): tf_img_tensor, + tf_model.Op("serving_default_rescaling_input", 0): inputImage, }) predictions := results[0] diff --git a/views/models/edit.html b/views/models/edit.html index 0930963..f1eeab8 100644 --- a/views/models/edit.html +++ b/views/models/edit.html @@ -303,7 +303,7 @@ Image File - +