6
0
Pārlūkot izejas kodu

Resolve "predict all images in model view"

Eric Tröbs 4 gadi atpakaļ
vecāks
revīzija
757619b27f

+ 2 - 0
pycs/frontend/WebServer.py

@@ -79,6 +79,8 @@ class WebServer:
                 app_status['projects'].delete_project(identifier)
             elif 'fit' in data.keys():
                 app_status['projects'].fit(identifier)
+            elif 'predictAll' in data.keys():
+                app_status['projects'].predict(identifier)
             elif 'predict' in data.keys():
                 app_status['projects'].predict(identifier, data['predict'])
             else:

+ 17 - 18
pycs/pipeline/PipelineManager.py

@@ -41,6 +41,7 @@ class PipelineManager:
         for identifier in self.project['data']:
             obj = self.project['data'][identifier]
             media = {
+                'type': obj['type'],
                 'name': obj['name'],
                 'extension': obj['extension'],
                 'size': obj['size'],
@@ -54,28 +55,26 @@ class PipelineManager:
                     continue
 
                 if 'x' not in prediction:
-                    media['predictionResults'].append({
+                    o = {
                         'type': 'labeled-image',
                         'label': prediction['label']
-                    })
+                    }
                 else:
+                    o = {
+                        'type': 'bounding-box',
+                        'x': prediction['x'],
+                        'y': prediction['y'],
+                        'w': prediction['w'],
+                        'h': prediction['h']
+                    }
+
                     if 'label' in prediction:
-                        media['predictionResults'].append({
-                            'type': 'labeled-bounding-box',
-                            'x': prediction['x'],
-                            'y': prediction['y'],
-                            'w': prediction['w'],
-                            'h': prediction['h'],
-                            'label': prediction['label']
-                        })
-                    else:
-                        media['predictionResults'].append({
-                            'type': 'bounding-box',
-                            'x': prediction['x'],
-                            'y': prediction['y'],
-                            'w': prediction['w'],
-                            'h': prediction['h']
-                        })
+                        o['type'] = 'labeled-bounding-box'
+                        o['label'] = prediction['label']
+                    if 'frame' in prediction:
+                        o['frame'] = prediction['frame']
+
+                media['predictionResults'].append(o)
 
             data.append(media)
 

+ 5 - 1
pycs/projects/ProjectManager.py

@@ -81,13 +81,17 @@ class ProjectManager(ObservableDict):
         # delete project data
         del self[uuid]
 
-    def predict(self, uuid, identifiers):
+    def predict(self, uuid, identifiers=None):
         # abort if uuid is no valid key
         if uuid not in self.keys():
             return
 
         project = self[uuid]
 
+        # get identifiers
+        if identifiers is None:
+            identifiers = list(project['data'].keys())
+
         # run prediction
         project.predict(identifiers)
 

+ 18 - 3
webui/src/components/projects/project-model-interaction-window.vue

@@ -1,8 +1,16 @@
 <template>
   <div class="project-model-interaction-window">
-    <button-input type="primary"
-                  @click="fit">fit model with new data
-    </button-input>
+    <div>
+      <button-input type="primary"
+                    @click="predict">predict all images
+      </button-input>
+    </div>
+
+    <div>
+      <button-input type="primary"
+                    @click="fit">fit model with new data
+      </button-input>
+    </div>
   </div>
 </template>
 
@@ -14,6 +22,9 @@ export default {
   components: {ButtonInput},
   props: ['currentProject', 'socket'],
   methods: {
+    predict: function () {
+      this.socket.post('/projects/' + this.currentProject.id, {'predictAll': true});
+    },
     fit: function () {
       this.socket.post('/projects/' + this.currentProject.id, {'fit': true});
     }
@@ -25,4 +36,8 @@ export default {
 .project-model-interaction-window {
   padding: 1rem;
 }
+
+.project-model-interaction-window > div {
+  margin-bottom: 1rem;
+}
 </style>