Browse Source

Resolve "package releases"

Eric Tröbs 4 years ago
parent
commit
7d75135c2d

+ 2 - 0
.gitlab-ci.yml

@@ -141,3 +141,5 @@ bundle:
       - app.py
       - pycs/
       - webui/
+      - labels
+      - models

+ 1 - 1
README.md

@@ -24,7 +24,7 @@ source env/bin/activate
 install python dependencies
 
 ```bash
-pip install numpy Pillow scipy tensorflow
+pip install numpy opencv-python Pillow scipy
 pip install eventlet flask python-socketio
 ```
 

+ 41 - 0
labels/fixed_label_provider/Provider.py

@@ -0,0 +1,41 @@
+import typing
+
+from pycs.labels.LabelProvider import LabelProvider
+
+
+class Provider(LabelProvider):
+    def __init__(self, root_folder, configuration):
+        pass
+
+    def close(self):
+        pass
+
+    def get_labels(self) -> typing.List[dict]:
+        return list(map(
+            lambda l: self.create_label(l.lower(), l),
+            [
+                'Dog',
+                'Turtle',
+                'Rabbit',
+                'Parrot',
+                'Cat',
+                'Goldfish',
+                'Mouse',
+                'Hamster',
+                'Cow',
+                'Rabbit',
+                'Duck',
+                'Shrimp',
+                'Pig',
+                'Goat',
+                'Crab',
+                'Deer',
+                'Bee',
+                'Sheep',
+                'Fish',
+                'Turkey',
+                'Dove',
+                'Chicken',
+                'Horse'
+            ]
+        ))

+ 8 - 0
labels/fixed_label_provider/configuration.json

@@ -0,0 +1,8 @@
+{
+  "id": "flpv1",
+  "name": "Fixed Label Provider v1",
+  "code": {
+    "module": "Provider",
+    "class": "Provider"
+  }
+}

+ 42 - 0
models/fixed_model/Pipeline.py

@@ -0,0 +1,42 @@
+from json import dump, load
+from os import path
+from typing import List
+
+from pycs.pipeline.Fit import Fit
+from pycs.pipeline.Job import Job
+from pycs.pipeline.Pipeline import Pipeline as Interface
+
+
+class Pipeline(Interface):
+    def __init__(self, root_folder, distribution):
+        print('fmv1 init')
+        self.root_folder = root_folder
+
+    def close(self):
+        print('fmv1 close')
+
+    def execute(self, job: Job) -> List[dict]:
+        print('fmv1 execute')
+        data_file = path.join(self.root_folder, 'data.json')
+
+        if path.exists(data_file):
+            with open(data_file, 'r') as file:
+                result = load(file)
+        else:
+            result = {}
+
+        if job.path in result:
+            return result[job.path]
+        else:
+            return []
+
+    def fit(self, fit: List[Fit]):
+        print('fmv1 fit')
+        result = {}
+
+        for f in fit:
+            result[f.path] = f.result
+
+        data_file = path.join(self.root_folder, 'data.json')
+        with open(data_file, 'w') as file:
+            dump(result, file, indent=4)

+ 12 - 0
models/fixed_model/distribution.json

@@ -0,0 +1,12 @@
+{
+  "id": "fmv1",
+  "name": "Fixed Base Model v1",
+  "supports": [
+    "labeled-bounding-boxes",
+    "fit"
+  ],
+  "code": {
+    "module": "Pipeline",
+    "class": "Pipeline"
+  }
+}

+ 10 - 1
pycs/frontend/WebServer.py

@@ -23,7 +23,12 @@ class WebServer:
 
             # find svg icons and add them as separate static files to
             # set their correct mime type / content_type
-            static_files = {'/': 'webui/'}
+            static_files = {}
+
+            for file_path in glob('webui/*'):
+                file_path = file_path.replace('\\', '/')
+                static_files[file_path[5:]] = file_path
+
             for svg_path in glob('webui/img/*.svg'):
                 svg_path = svg_path.replace('\\', '/')
                 static_files[svg_path[5:]] = {'content_type': 'image/svg+xml', 'filename': svg_path}
@@ -37,6 +42,10 @@ class WebServer:
                     return make_response()
                 else:
                     return make_response(data)
+
+            @self.__flask.route('/', methods=['GET'])
+            def index():
+                return send_from_directory(path.join(getcwd(), 'webui'), 'index.html')
         else:
             print('development build')
 

+ 5 - 1
pycs/projects/ProjectManager.py

@@ -1,6 +1,7 @@
 from glob import glob
 from json import load, dump
 from os import path, mkdir
+from os.path import exists
 from shutil import rmtree, copytree
 from time import time
 from uuid import uuid1
@@ -12,9 +13,12 @@ from pycs.projects.Project import Project
 
 class ProjectManager(ObservableDict):
     def __init__(self, app_status: ApplicationStatus):
-        # TODO create projects folder if it does not exist
         self.app_status = app_status
 
+        # create projects folder if it does not exist
+        if not exists('projects/'):
+            mkdir('projects/')
+
         # initialize observable dict with no keys and
         # app_status object as parent
         super().__init__({}, app_status)