|
@@ -6,7 +6,6 @@ from PyQt5 import uic, QtWidgets, QtCore, QtGui
|
|
|
|
|
|
from . import AboutDialog
|
|
|
from .NewProjectWizard import NewProjectWizard
|
|
|
-from .PredictionDialog import PredictionDialog
|
|
|
from ..project import Project
|
|
|
from ..utils import Video
|
|
|
|
|
@@ -213,11 +212,55 @@ class MainWindow:
|
|
|
# Prediction actions and management #
|
|
|
#####################################
|
|
|
def _predict_via_dialog(self):
|
|
|
+ # '''
|
|
|
+ # {'filename': filename, 'filetype': filetype, 'jobs': ['detect-faces']}
|
|
|
+ image_extensions = ['.jpg', '.png', '.jpeg']
|
|
|
+ video_extensions = ['.mp4', '.avi', '.mkv', '.mpg', '.mpeg']
|
|
|
+
|
|
|
+ name_list = ' '.join(['*' + extension for extension in image_extensions + video_extensions])
|
|
|
+ extensions = f'All supported files ({name_list})'
|
|
|
+
|
|
|
+ jobs = []
|
|
|
+ selection = QtWidgets.QFileDialog.getOpenFileNames(self.ui, 'Select Files To Add', filter=extensions)
|
|
|
+ for filename in selection[0]:
|
|
|
+ _, extension = os.path.splitext(filename)
|
|
|
+ extension = extension.lower()
|
|
|
+
|
|
|
+ if extension in image_extensions:
|
|
|
+ jobs.append({
|
|
|
+ 'filename': filename,
|
|
|
+ 'filetype': 'image',
|
|
|
+ 'jobs': ['detect-faces']
|
|
|
+ })
|
|
|
+ elif extension in video_extensions:
|
|
|
+ jobs.append({
|
|
|
+ 'filename': filename,
|
|
|
+ 'filetype': 'image',
|
|
|
+ 'jobs': ['detect-faces']
|
|
|
+ })
|
|
|
+
|
|
|
+ progress_dialog = QtWidgets.QProgressDialog('Executing prediction jobs...', 'Abort', 0, 1000, self.ui)
|
|
|
+ progress_dialog.setWindowModality(QtCore.Qt.WindowModal)
|
|
|
+
|
|
|
+ def callback(progress):
|
|
|
+ progress_dialog.setValue(int(progress * 1000))
|
|
|
+ for i in range(10):
|
|
|
+ QtWidgets.QApplication.processEvents()
|
|
|
+
|
|
|
+ self._project.execute(jobs, callback=callback)
|
|
|
+
|
|
|
+ progress_dialog.close()
|
|
|
+ self._predictions += jobs
|
|
|
+
|
|
|
+ '''
|
|
|
+ TODO: remove PredictionDialog.py
|
|
|
+
|
|
|
prediction_dialog = PredictionDialog(parent=self.ui)
|
|
|
if prediction_dialog.exec_():
|
|
|
|
|
|
# TODO extract callback and progress dialog to make it reusable
|
|
|
jobs = copy.deepcopy(prediction_dialog.jobs)
|
|
|
+ print(jobs)
|
|
|
progress_dialog = QtWidgets.QProgressDialog('Executing prediction jobs...', 'Abort', 0, 1000, self.ui)
|
|
|
progress_dialog.setWindowModality(QtCore.Qt.WindowModal)
|
|
|
|
|
@@ -230,6 +273,7 @@ class MainWindow:
|
|
|
|
|
|
progress_dialog.close()
|
|
|
self._predictions += jobs
|
|
|
+ '''
|
|
|
|
|
|
def _update_prediction_ui(self):
|
|
|
# TODO implement better sync
|