Exemplo n.º 1
0
def PreviewInferenceDialogue(self):
    """
    Load preview inference dialogue.
    """
    if self.trainInProgress:
        QtWidgets.QMessageBox.information(self.previewInferenceDialogue, "Cannot Preview Model", "Training is already in progress.", QtWidgets.QMessageBox.Ok)
    else:
        # Set generate XML variable
        self.generateXML = False

        # Load preview images number
        ui_general.SetPreviewImagesNum(self, self.previewInferenceDialogue)

        # Load snapshots
        dataSets, errorMsg = general.ModelNames(config.snapshots)
        if errorMsg is not None:
            errorMessage = "There was an error with preprocessing.get_all_files(). Reason: " + errorMsg
            self.previewInferenceDialogue.textEdit.append(errorMessage)

        # Insert snapshots
        error, errorMsg = ui_general.InsertModels(self.previewInferenceDialogue, dataSets)
        if error:
            errorMessage = "Could not add datasets to dialogue. Reason: " + errorMsg
            self.previewInferenceDialogue.textEdit.append(errorMessage)

        # Save datasets
        self.updatePIDatasets = dataSets

        # Set confidence threshold
        ui_general.SetConfThresh(self, self.previewInferenceDialogue)

        # Update model name
        SetModelName(self)

        # Update delete models checkbox
        self.previewInferenceDialogue.deleteModelsCheckBox.setChecked(self.deleteModels)

        # Make dialogue cursor invisible
        self.previewInferenceDialogue.textEdit.setCursorWidth(0)

        # Enable widgets in dialogue
        EnablePiWidgets(self)

        # Start update combo timer
        StartUpdateTimer(self)

        # Set default button
        ui_general.DefaultButton(self.previewInferenceDialogue)

        # Show dialogue
        self.previewInferenceDialogue.show()

        # Cancel all if dialogue is rejected (x button is clicked)
        if self.previewInferenceDialogue.exec_() == QtWidgets.QDialog.Rejected:
            # Cancel threads
            ui_general.CancelButton(self, self.previewInferenceDialogue)

            # Cancel toggle timer
            StopTogglePiWidgets(self)
Exemplo n.º 2
0
def TrainingDialogue2(self):
    """
    Load training config dialogue.
    """
    # Ensure that training is not already in progress
    if self.trainInProgress:
        QtWidgets.QMessageBox.information(self.trainDialogue2,
                                          "Cannot Edit Training Settings",
                                          "Training is already in progress.",
                                          QtWidgets.QMessageBox.Ok)
    else:
        # Set generate XML variable
        self.generateXML = False

        # Set text widgets
        self.trainDialogue2.epochsText.setText(str(self.epochs))
        self.trainDialogue2.batchSizeText.setText(str(self.batchSize))

        # Start update combo timer
        StartUpdateCombo(self)

        # Load pretrained models
        dataSets, errorMsg = general.ModelNames(config.pretrainedModels)
        if errorMsg is not None:
            errorMessage = "There was an error with preprocessing.get_all_files(). Reason: " + errorMsg
            self.textEdit.append(errorMessage)

        # Insert pretrained models
        error, errorMsg = ui_general.InsertModels(self.trainDialogue2,
                                                  dataSets)
        if error:
            errorMessage = "Could not add datasets to dialogue. Reason: " + errorMsg
            self.textEdit.append(errorMessage)

        # Select pretrained model in train dialogue 2
        ui_general.SelectPretrainedModel(self)

        # Save datasets
        self.updateTRDatasets = dataSets

        #Set framework combobox
        self.trainDialogue2.frameworkComboBox.addItem("RetinaNet")

        # Load training settings
        ui_general.SetTrainSettings(self)

        # Show training configuration dialogue
        self.trainDialogue2.show()

        # Cancel all if dialogue is rejected (x button is clicked)
        if self.trainDialogue2.exec_() == QtWidgets.QDialog.Rejected:
            ui_general.CancelButton(self, self.trainDialogue2)
Exemplo n.º 3
0
def UpdateCombo(self):
    """
    Updates combo box when directory changes.
    """
    # Load snapshots
    dataSets, errorMsg = general.ModelNames(config.snapshots)
    if errorMsg is not None:
        errorMessage = "There was an error with preprocessing.get_all_files(). Reason: " + errorMsg
        self.previewInferenceDialogue.textEdit.append(errorMessage)

    if dataSets != self.updatePIDatasets:
        self.updatePIDatasets = dataSets

        # Insert snapshots
        error, errorMsg = ui_general.InsertModels(self, self.previewInferenceDialogue, dataSets)
        if error:
            errorMessage = "Could not add datasets to dialogue. Reason: " + errorMsg
            self.previewInferenceDialogue.textEdit.append(errorMessage)
Exemplo n.º 4
0
def UpdateCombo(self):
    """
    Updates combo box when directory changes.
    """
    # Load pretrained models
    dataSets, errorMsg = general.ModelNames(config.pretrainedModels)
    if errorMsg is not None:
        errorMessage = "There was an error with preprocessing.get_all_files(). Reason: " + errorMsg
        self.textEdit.append(errorMessage)

    if dataSets != self.updateTRDatasets:
        self.updateTRDatasets = dataSets

        # Insert pretrained models
        error, errorMsg = ui_general.InsertModels(self.trainDialogue2,
                                                  dataSets)
        if error:
            errorMessage = "Could not add datasets to dialogue. Reason: " + errorMsg
            self.textEdit.append(errorMessage)
Exemplo n.º 5
0
def MultiClassCheckBox(self):
    """
    Changes value if the checkbox is checked/unchecked.
    """
    if self.autoAnnotateDialogue.multiClassCheckBox.isChecked() is False:
        self.multiClassCheckBox = False

        # Remove pretrained models
        dataSets = []
        error, errorMsg = InsertAnnotateModels(self.autoAnnotateDialogue,
                                               dataSets)
        if error:
            errorMessage = "Could not add datasets to dialogue. Reason: " + errorMsg
            self.autoAnnotateDialogue.textEdit.append(errorMessage)
    else:
        # Update multi class checkbox value
        self.multiClassCheckBox = True

        # Reset classes set
        self.annotateClassesSet = {}

        # Load pretrained models
        dataSets, errorMsg = general.ModelNames(config.snapshots)
        if errorMsg is not None:
            errorMessage = "There was an error with preprocessing.get_all_files(). Reason: " + errorMsg
            self.autoAnnotateDialogue.textEdit.append(errorMessage)

        # Insert pretrained models
        error, errorMsg = InsertAnnotateModels(self.autoAnnotateDialogue,
                                               dataSets)
        if error:
            errorMessage = "Could not add datasets to dialogue. Reason: " + errorMsg
            self.autoAnnotateDialogue.textEdit.append(errorMessage)

        # Save datasets
        self.updateAAAnnotateDatasets = dataSets

    # Disable/enable single class name
    ToggleSingleClassName(self)
Exemplo n.º 6
0
def UpdateCombos(self):
    """
    Updates combo boxes when directory changes.
    """
    # Load datasets
    modelList, errorMsg = general.ReturnDirNames(config.datasets)
    if errorMsg is not None:
        errorMessage = "Could not add pretrained models. Reason: " + errorMsg
        self.autoAnnotateDialogue.textEdit.append(errorMessage)

    if modelList != self.updateAADatasets:
        self.updateAADatasets = modelList

        # Insert pretrained models
        error, errorMsg = ui_general.InsertModels(self.autoAnnotateDialogue,
                                                  modelList)
        if error:
            errorMessage = "Could not add datasets to dialogue. Reason: " + errorMsg
            self.autoAnnotationDialogue.textEdit.append(errorMessage)

    if self.multiClassCheckBox:
        # Load pretrained models
        dataSets, errorMsg = general.ModelNames(config.snapshots)
        if errorMsg is not None:
            errorMessage = "There was an error with preprocessing.get_all_files(). Reason: " + errorMsg
            self.autoAnnotateDialogue.textEdit.append(errorMessage)

        if dataSets != self.updateAAAnnotateDatasets:
            self.updateAAAnnotateDatasets = dataSets

            # Insert pretrained models
            error, errorMsg = InsertAnnotateModels(self.autoAnnotateDialogue,
                                                   dataSets)
            if error:
                errorMessage = "Could not add datasets to dialogue. Reason: " + errorMsg
                self.autoAnnotateDialogue.textEdit.append(errorMessage)
Exemplo n.º 7
0
def RunInferenceDialogue(self):
    """
    Load run inference dialogue.
    """
    if self.trainInProgress:
        QtWidgets.QMessageBox.information(self, "Object Detection Unavailable",
                                          "Training is already in progress.",
                                          QtWidgets.QMessageBox.Ok)
    else:
        # Set generate XML variable
        self.generateXML = False

        # Load models
        dataSets, errorMsg = general.ModelNames(config.pretrainedModels)
        if errorMsg is not None:
            errorMessage = "There was an error with preprocessing.get_all_files(). Reason: " + errorMsg
            self.previewInferenceDialogue.textEdit.append(errorMessage)

        # Insert models
        error, errorMsg = ui_general.InsertModels(self.runInferenceDialogue,
                                                  dataSets)
        if error:
            errorMessage = "Could not add datasets to dialogue. Reason: " + errorMsg
            self.previewInferenceDialogue.textEdit.append(errorMessage)

        # Save datasets
        self.updateRIDatasets = dataSets

        # Set confidence threshold
        ui_general.SetConfThresh(self, self.runInferenceDialogue)

        # Make dialogue cursor invisible
        self.runInferenceDialogue.textEdit.setCursorWidth(0)

        # Update self.generateReport value
        self.generateReport = self.generateReportRi

        # Update showImagesCheckBox
        self.runInferenceDialogue.showImagesCheckBox.setChecked(
            self.showImages)

        # Update reportCheckBox
        self.runInferenceDialogue.reportCheckBox.setChecked(
            self.generateReport)

        # Update image count, if directory already previously selected
        if self.testImagesPath is not None:
            GetRunImagesCount(self, False)

        # Update reportTitle
        UpdateReportTitle(self)

        # Disable/enable report title
        ToggleReportTitle(self)

        # Enable widgets in dialogue
        EnableRiWidgets(self)

        # Start update combo timer
        StartUpdateTimer(self)

        # Set default button
        ui_general.DefaultButton(self.runInferenceDialogue)

        # Show dialogue
        self.runInferenceDialogue.show()

        # Close threads, if dialogue is rejected (x button is clicked)
        if self.runInferenceDialogue.exec_() == QtWidgets.QDialog.Rejected:
            ui_general.CancelButton(self, self.runInferenceDialogue)

            # Cancel toggle timer
            StopToggleRiWidgets(self)