def test_setLabelList_DeployWindow(qtbot): widget = DeployWindow(True) qtbot.addWidget(widget) qtbot.mouseClick(widget.list_button, QtCore.Qt.LeftButton) assert widget._path_to_label_list == 'dummy_label_list_filepath'
def test_setUseCase_Classification_DeployWindow(qtbot): widget = DeployWindow() qtbot.addWidget(widget) qtbot.keyClicks(widget.usecase_config_button, 'Counting') assert widget.counting_window.isVisible() is True
def test_setModel_DeployWindow(qtbot): widget = DeployWindow(True) qtbot.addWidget(widget) qtbot.mouseClick(widget.model_button, QtCore.Qt.LeftButton) assert widget._path_to_model == 'dummy_model_filepath'
def __init__(self): ''' The constructor. Sets the size of the window. Calls setButtons function to populate window with button. ''' super().__init__() self.train_window = TrainWindow(False) self.deploy_window = DeployWindow(False) self.isTrainOpen = False self.isDeployOpen = False self._WINDOW_HEIGHT = 375 self._WINDOW_WIDTH = 500 self.setWindowTitle('easy_perception_deployment') self.setGeometry(0, 0, self._WINDOW_WIDTH, self._WINDOW_HEIGHT) self.setButtons()
def test_setUseCase_DeployWindow(qtbot): widget = DeployWindow(True) qtbot.addWidget(widget) classification_index = 0 color_matching_index = 0 for i in range(0, len(widget.usecase_list)): if widget.usecase_list[i] == 'Classification': classification_index = i if widget.usecase_list[i] == 'Color-Matching': color_matching_index = i widget.setUseCase(classification_index) usecase_config_lines = [ line.rstrip('\n') for line in open('../data/usecase_config.txt') ] assert len(usecase_config_lines) == 1 widget.setUseCase(color_matching_index) usecase_config_lines = [ line.rstrip('\n') for line in open('../data/usecase_config.txt') ] assert len(usecase_config_lines) == 2
def test_emptySession_emptyUseCase_DeployWindow(qtbot): widget = DeployWindow() qtbot.addWidget(widget) if (os.path.exists('../data/session_config.txt') and os.path.exists('../data/session_config.txt')): p1 = subprocess.Popen(['rm', '../data/session_config.txt']) p1.communicate() p2 = subprocess.Popen(['rm', '../data/usecase_config.txt']) p2.communicate() assert widget._path_to_model == 'filepath/to/onnx/model' assert widget._path_to_label_list == 'filepath/to/classes/list/txt' assert widget.usecase_mode == 0
def test_deployPackage_DeployWindow(qtbot): widget = DeployWindow() qtbot.addWidget(widget) qtbot.mouseClick(widget.run_button, QtCore.Qt.LeftButton) isDeployScriptRunning = widget._deploy_process.poll() assert isDeployScriptRunning is None assert widget._is_running is True widget._deploy_process.kill() qtbot.mouseClick(widget.run_button, QtCore.Qt.LeftButton) isKillScriptRunning = widget._kill_process.poll() assert isKillScriptRunning is None assert widget._is_running is False
def test_validSession_validUseCase_DeployWindow(qtbot): test_session_config_content = [ '../data/model/p1_example.onnx\n', '../data/label_list/imagenet_classes.txt\n', 'visualize\n' ] outF = open("../data/session_config.txt", "w") for line in test_session_config_content: outF.write(line) outF.close() test_usecase_config_content = ['0\n'] outF = open("../data/usecase_config.txt", "w") for line in test_usecase_config_content: outF.write(line) outF.close() widget = DeployWindow() qtbot.addWidget(widget) assert widget._path_to_model == '../data/model/p1_example.onnx' assert widget._path_to_label_list == '../data/label_list/imagenet_classes.txt' assert widget.usecase_mode == '0'
def test_invalidSession_invalidUseCase_DeployWindow(qtbot): test_session_config_content = [ 'test_filepath_to_model\n', 'test_filepath_to_label_list\n', 'visualize\n' ] outF = open("../data/session_config.txt", "w") for line in test_session_config_content: outF.write(line) outF.close() test_usecase_config_content = ['-1\n'] outF = open("../data/usecase_config.txt", "w") for line in test_usecase_config_content: outF.write(line) outF.close() widget = DeployWindow() qtbot.addWidget(widget) assert widget._path_to_model == 'test_filepath_to_model' assert widget._path_to_label_list == 'test_filepath_to_label_list' assert widget.usecase_mode == '-1'
def test_invalidSession_invalidUseCase_DeployWindow(qtbot): test_session_config_content = ['test_filepath_to_model\n', 'test_filepath_to_label_list\n', 'visualize\n'] # If session_config.txt is not present, create one. outF = open('../data/session_config.txt', 'w+') for line in test_session_config_content: outF.write(line) outF.close() test_usecase_config_content = ['-1\n'] outF = open('../data/usecase_config.txt', 'w+') for line in test_usecase_config_content: outF.write(line) outF.close() widget = DeployWindow() qtbot.addWidget(widget) assert widget._path_to_model == 'filepath/to/onnx/model' assert widget._path_to_label_list == 'filepath/to/classes/list/txt' assert widget.usecase_mode == '-1'
class MainWindow(QWidget): ''' The MainWindow class is a PySide2 Graphical User Interface (GUI) window that starts up as the first user interface. ''' def __init__(self): ''' The constructor. Sets the size of the window. Calls setButtons function to populate window with button. ''' super().__init__() self.train_window = TrainWindow(False) self.deploy_window = DeployWindow(False) self.isTrainOpen = False self.isDeployOpen = False self._WINDOW_HEIGHT = 375 self._WINDOW_WIDTH = 500 self.setWindowTitle('easy_perception_deployment') self.setGeometry(0, 0, self._WINDOW_WIDTH, self._WINDOW_HEIGHT) self.setButtons() def setButtons(self): '''A Mutator function that defines all buttons in MainWindow.''' self.train_button = QPushButton('Train', self) self.train_button.setIcon(QIcon('img/train.png')) self.train_button.setIconSize(QSize(100, 100)) self.train_button.setGeometry(0, 0, self._WINDOW_WIDTH / 2, 250) self.deploy_button = QPushButton('Deploy', self) self.deploy_button.setIcon(QIcon('img/deploy.png')) self.deploy_button.setIconSize(QSize(100, 100)) self.deploy_button.setGeometry(self._WINDOW_WIDTH / 2, 0, self._WINDOW_WIDTH / 2, 250) self.quit_button = QPushButton('Quit', self) self.quit_button.setIcon(QIcon('img/quit.png')) self.quit_button.setIconSize(QSize(250, 250)) self.quit_button.setGeometry(0, 250, self._WINDOW_WIDTH, 125) self.train_button.clicked.connect(self.openTrainWindow) self.deploy_button.clicked.connect(self.deployPackage) self.quit_button.clicked.connect(self.closeWindow) def deployPackage(self): '''A function that is triggered by the button labelled, Deploy.''' # Start Deploy window that allows you to set the self.isDeployOpen = not self.isDeployOpen if (self.isDeployOpen): self.deploy_window.show() else: self.deploy_window.close() def openTrainWindow(self): '''A function that is triggered by the button labelled, Train.''' self.isTrainOpen = not self.isTrainOpen if (self.isTrainOpen): self.train_window.show() else: self.train_window.close() def closeWindow(self): '''A function that is triggered by the button labelled, Quit.''' self.close() self.train_window.close() self.deploy_window.close()