|
@@ -2,6 +2,7 @@ from os import path
|
|
|
|
|
|
from eventlet import tpool
|
|
|
|
|
|
+from pycs.pipeline.Fit import Fit
|
|
|
from pycs.pipeline.Job import Job
|
|
|
|
|
|
|
|
@@ -24,58 +25,22 @@ class PipelineManager:
|
|
|
def run(self, media_file):
|
|
|
# create job list
|
|
|
# TODO update job progress
|
|
|
- job = Job('detect-faces', self.project['id'], media_file)
|
|
|
+ job = Job(self.project['id'], media_file)
|
|
|
result = tpool.execute(lambda p, j: p.execute(j), self.pipeline, job)
|
|
|
|
|
|
# remove existing pipeline predictions from media_fle
|
|
|
media_file.remove_pipeline_results()
|
|
|
|
|
|
# add new predictions
|
|
|
- for prediction in result.predictions:
|
|
|
+ for prediction in result:
|
|
|
media_file.add_result(prediction, origin='pipeline')
|
|
|
|
|
|
def fit(self):
|
|
|
print('PipelineManager', 'fit')
|
|
|
-
|
|
|
data = []
|
|
|
- for identifier in self.project['data']:
|
|
|
- obj = self.project['data'][identifier]
|
|
|
- media = {
|
|
|
- 'type': obj['type'],
|
|
|
- 'name': obj['name'],
|
|
|
- 'extension': obj['extension'],
|
|
|
- 'size': obj['size'],
|
|
|
- 'path': path.join('projects', self.project['id'], 'data', identifier + obj['extension']),
|
|
|
- 'predictionResults': []
|
|
|
- }
|
|
|
-
|
|
|
- for prediction_identifier in obj['predictionResults']:
|
|
|
- prediction = obj['predictionResults'][prediction_identifier]
|
|
|
- if prediction['origin'] != 'user':
|
|
|
- continue
|
|
|
-
|
|
|
- if 'x' not in prediction:
|
|
|
- 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:
|
|
|
- o['type'] = 'labeled-bounding-box'
|
|
|
- o['label'] = prediction['label']
|
|
|
- if 'frame' in prediction:
|
|
|
- o['frame'] = prediction['frame']
|
|
|
-
|
|
|
- media['predictionResults'].append(o)
|
|
|
-
|
|
|
- data.append(media)
|
|
|
+ for identifier in self.project['data']:
|
|
|
+ fit = Fit(self.project['id'], self.project['data'][identifier])
|
|
|
+ data.append(fit)
|
|
|
|
|
|
self.pipeline.fit(data)
|