def done_work(result):
     self._loading_dialog.hide()
     pred_out, err = result
     if err:
         raise err
     if pred_out:
         pred_type, pred_res = pred_out
         if pred_type == "mask":
             for class_idx, contours in pred_res.items():
                 if len(contours) > 0:
                     for c in contours:
                         points = []
                         for i in range(0, len(c), 10):
                             points.append(c[i])
                         if len(points) > 5:
                             polygon = EditablePolygon()
                             polygon.tag = self.tag.dataset
                             self.image_viewer._scene.addItem(polygon)
                             bbox: QRectF = self.image_viewer.pixmap.boundingRect(
                             )
                             offset = QPointF(bbox.width() / 2,
                                              bbox.height() / 2)
                             for point in points:
                                 if isinstance(
                                         point,
                                         list) and len(point) == 2:
                                     polygon.addPoint(
                                         QPoint(point[0] - offset.x(),
                                                point[1] - offset.y()))
         else:
             class_id, class_name = pred_res
             GUIUtilities.show_info_message(
                 "predicted label : `{}`".format(class_name),
                 "prediction result")
 def accept(self) -> None:
     if self.result.color and self.result.name:
         super(NewLabelForm, self).accept()
     else:
         GUIUtilities.show_info_message(
             "The color and name fields are required", "info")
     return
            def done_work(result):
                annots, err = result
                if err:
                    raise err
                if annots:
                    output_file = Path(selected_folder) \
                        .joinpath("annotations.{}".format(export_format))
                    if export_format == "csv":
                        df = pd.DataFrame(annots)
                        df.to_csv(str(output_file), index=False)
                    else:

                        def dumper(obj):
                            try:
                                return obj.toJSON()
                            except:
                                return obj.__dict__

                        with open(output_file, "w") as f:
                            f.write(
                                json.dumps(annots, default=dumper, indent=2))
                    GUIUtilities.show_info_message(
                        "Annotations exported successfully", "Done")
                else:
                    GUIUtilities.show_info_message(
                        "Not annotations found for the dataset {}".format(
                            dataset_vo.name), "Done")
Exemple #4
0
                def done_work(result):
                    data, error = result
                    if error:
                        raise error
                    images =itertools.groupby(data,lambda x: x["image"])
                    if action_text == self.JSON:
                        self.annotations2json(images, selected_folder)
                    elif action_text == self.PASCAL_VOC:
                        self.annotations2pascal(images,selected_folder)

                    GUIUtilities.show_info_message("Annotations exported successfully", "Done")
 def done_work(result):
     annotations, err = result
     if err:
         raise err
     if annotations:
         GUIUtilities.show_info_message(
             "Annotations exported successfully", "Done")
     else:
         GUIUtilities.show_info_message(
             "Not annotations found for the dataset {}".format(
                 dataset_vo.name), "Done")
 def done_work(result):
     data, error = result
     if error:
         raise error
     if len(data) > 0:
         GUIUtilities.show_info_message(
             "Annotations imported successfully",
             "Import annotations status")
     else:
         GUIUtilities.show_info_message(
             "No annotations found",
             "Import annotations status")
Exemple #7
0
 def accept(self) -> None:
     if not self.nameLineEdit.text():
         GUIUtilities.show_info_message("The name field is required", "info")
         return
     if self._value is None:
         usr_folder = FileUtilities.get_usr_folder()
         new_folder = FileUtilities.create_new_folder(usr_folder)
         vo = DatasetVO()
         ds_folder = os.path.basename(new_folder)
         vo.folder = ds_folder
         self._value = vo
     else:
         vo = self._value
     vo.name = self.nameLineEdit.text()
     vo.description = self.descriptionEditText.toPlainText()
     # dataset_vo.data_type=self.typeComboBox.currentText()
     return QDialog.accept(self)
 def done_work(result):
     _, err = result
     if err:
         raise err
     GUIUtilities.show_info_message(
         "Annotations saved successfully", "Information")