6
0
Эх сурвалжийг харах

minor UI-related fixes in label showing

Dimitri Korsch 3 жил өмнө
parent
commit
524353df00

+ 2 - 1
pycs/database/base.py

@@ -23,6 +23,7 @@ class BaseModel(db.Model, SerializerMixin):
     serialize_only = ("id", "identifier")
 
     def identifier(self):
+        """ alias for id attribute """
         return self.id
 
     def __repr__(self):
@@ -32,7 +33,7 @@ class BaseModel(db.Model, SerializerMixin):
 
 
     def serialize(self) -> dict:
-        """ default model serialization method"""
+        """ default model serialization method """
         return self.to_dict()
 
 

+ 1 - 1
pycs/frontend/WebServer.py

@@ -147,7 +147,7 @@ class WebServer:
             view_func=ListJobs.as_view('list_jobs', jobs)
         )
         self.app.add_url_rule(
-            '/jobs/<int:job_id>/remove',
+            '/jobs/<job_id>/remove',
             view_func=RemoveJob.as_view('remove_job', jobs)
         )
 

+ 1 - 1
pycs/frontend/endpoints/labels/RemoveLabel.py

@@ -43,7 +43,7 @@ class RemoveLabel(View):
             label.flush()
 
             # notify about changes and reset the parent
-            for child in label.children:
+            for child in children:
                 child.parent_id = label.parent_id
                 self.nm.edit_label(child)
 

+ 3 - 3
pycs/frontend/endpoints/pipelines/PredictModel.py

@@ -81,7 +81,7 @@ class PredictModel(View):
 
         # create new database instance
         project = Project.query.get(project_id)
-        model = project.model
+        model_root = project.model.root_folder
         storage = MediaStorage(project_id, notifications)
 
         # create a list of MediaFile
@@ -102,7 +102,7 @@ class PredictModel(View):
         media_files = map(lambda f: MediaFile(f, notifications), files)
         # load pipeline
         try:
-            pipeline = pipelines.load_from_root_folder(project, model.root_folder)
+            pipeline = pipelines.load_from_root_folder(project, model_root)
 
             # iterate over media files
             index = 0
@@ -121,7 +121,7 @@ class PredictModel(View):
 
         finally:
             if pipeline is not None:
-                pipelines.free_instance(model.root_folder)
+                pipelines.free_instance(model_root)
 
 
     @staticmethod

+ 1 - 1
pycs/interfaces/MediaStorage.py

@@ -26,7 +26,7 @@ class MediaStorage:
         :return: list of labels
         """
         label_list = self.__project.labels.all()
-        label_dict = {la.label: MediaLabel(la) for la in label_list}
+        label_dict = {la.id: MediaLabel(la) for la in label_list}
         result = []
 
         for label in label_list:

+ 1 - 1
pycs/jobs/Job.py

@@ -11,7 +11,7 @@ class Job:
 
     # pylint: disable=too-few-public-methods
     def __init__(self, project: Project, job_type: str, name: str):
-        self.uuid = self.id = str(uuid1())
+        self.uuid = self.identifier = str(uuid1())
         self.project_id = project.id
         self.type = job_type
         self.name = name

+ 12 - 4
pycs/jobs/JobRunner.py

@@ -1,9 +1,16 @@
+import traceback
+
 from concurrent.futures import ThreadPoolExecutor
 from time import time
 from types import GeneratorType
-from typing import Callable, List, Generator, Optional, Any
-
-from eventlet import spawn_n, tpool
+from typing import Any
+from typing import Callable
+from typing import Generator
+from typing import List
+from typing import Optional
+
+from eventlet import spawn_n
+from eventlet import tpool
 from eventlet.event import Event
 from eventlet.queue import Queue
 
@@ -94,7 +101,7 @@ class JobRunner:
         :return:
         """
         for i in range(len(self.__jobs)):
-            if self.__jobs[i].id == identifier:
+            if self.__jobs[i].identifier == identifier:
                 if self.__jobs[i].finished is not None:
                     job = self.__jobs[i]
                     del self.__jobs[i]
@@ -219,6 +226,7 @@ class JobRunner:
 
             # save exceptions to show in ui
             except Exception as exception:
+                traceback.print_exc()
                 job.exception = f'{type(exception).__name__} ({str(exception)})'
 
             # remove from group dict

+ 3 - 3
webui/src/components/media/annotation-box.vue

@@ -42,11 +42,11 @@ export default {
   },
   computed: {
     labelName: function () {
-      if (!this.box || !this.box.label)
+      console.log(this.box)
+      if (!this.box || !this.box.label_id)
         return false;
-
       for (let label of this.labels) {
-        if (label.identifier === this.box.label) {
+        if (label.identifier === this.box.label_id) {
           return label.name;
         }
       }

+ 2 - 2
webui/src/components/media/cropped-image.vue

@@ -53,12 +53,12 @@
             if (!this.box)
               return ''
 
-            if (this.box.label == null)
+            if (this.box.label_id == null)
               return 'Unknown'
 
             let name = 'Not Found';
             for (let label of this.labels){
-              if (label.identifier != this.box.label)
+              if (label.identifier != this.box.label_id)
                 continue;
 
               name = label.name;