示例#1
0
    def onShowStats(self):
        stats = self.data.get_stats()
        stats_str = ""
        for key, val in stats:
            key = '_'.join(key) if type(key) is list else key
            stats_str += f"{key} = {val}\n"

        dlg = MessageDialog('Label stats', stats_str)
        dlg.exec_()
示例#2
0
 def launchSaveChanges(self):
     if not self.changesSaved:
         saveDialog = MessageDialog(
             'Not saved changes!',
             'Some labeled images were not saved, do you want to save the changes?'
         )
         if saveDialog.exec_():
             # save csv
             self.data.save()
示例#3
0
    def onCreateCsv(self, s):
        main_folder = str(
            QFileDialog.getExistingDirectory(self, "Choose dataset directory"))

        # if there is no folder, do nothing
        if not os.path.isdir(main_folder):
            return False

        optDialog = CsvNameDialog()

        # get desired filename and if images are organized from user
        if optDialog.exec_() == CsvNameDialog.Accepted:
            filename, have_labels = optDialog.getValues()
        else:
            # if cancel, do nothing
            return False

        # reset if was labeling
        if self.isLabeling:
            self.stopLabeling()

        # initialize data handler
        self.data = DataHandler(os.path.join(main_folder, filename))
        self.data.create(have_labels)

        if len(self.data) > 0:
            message = "{} images found, save to file?".format(len(self.data))
            title = "Images found"
        else:
            message = "No image were found!"
            title = "No images in folder"

        dlg = MessageDialog(title, message)

        if dlg.exec_():
            # save csv
            self.data.save()
            # start labeling
            self.startLabeling()
        else:
            self.data = None