Skip to content

Commit

Permalink
Finish merge prepare to PR
Browse files Browse the repository at this point in the history
  • Loading branch information
9xEzreaL committed Apr 25, 2023
1 parent 5f2d086 commit bd85198
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 20 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/salt.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions salt/dataset_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def init_coco(dataset_folder, image_names, categories, coco_json_path):
"id": i,
"file_name": image_name,
"width": im.shape[1],
"height": im.shape[0],
"status": 0
"height": im.shape[0]
}
)
with open(coco_json_path, "w") as f:
Expand Down Expand Up @@ -157,7 +156,6 @@ def get_num_images(self):

def get_image_data(self, image_id):
image_name = self.coco_json["images"][image_id]["file_name"]
image_status = self.coco_json["images"][image_id]["status"]
image_path = os.path.join(self.dataset_folder, image_name)
embedding_path = os.path.join(
self.dataset_folder,
Expand All @@ -174,7 +172,7 @@ def get_image_data(self, image_id):
image_bgr = copy.deepcopy(image)

image_embedding = np.load(embedding_path)
return image, image_bgr, image_embedding, image_name, image_status
return image, image_bgr, image_embedding, image_name

def __add_to_our_annotation_dict(self, annotation):
image_id = annotation["image_id"]
Expand Down
4 changes: 3 additions & 1 deletion salt/display_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys
sys.setrecursionlimit(200000)
import cv2
import numpy as np
from pycocotools import mask as coco_mask
Expand Down Expand Up @@ -57,7 +59,7 @@ def draw_box_on_image(self, image, ann, color):

def draw_annotations(self, image, annotations, colors):
for ann, color in zip(annotations, colors):
# image = self.draw_box_on_image(image, ann, color)
image = self.draw_box_on_image(image, ann, color)
mask = self.__convert_ann_to_mask(ann, image.shape[0], image.shape[1])
image = self.overlay_mask_on_image(image, mask, color)
return image
Expand Down
16 changes: 6 additions & 10 deletions salt/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def __init__(
self.image_bgr,
self.image_embedding,
self.name,
self.status
) = self.dataset_explorer.get_image_data(self.image_id)
self.curr_inputs.set_xy(self.image.shape[:2])
self.display = self.image_bgr.copy()
Expand Down Expand Up @@ -143,8 +142,6 @@ def __draw_known_annotations(self, selected_annotations=[]):
colors[i] = (0, 0, 0)
# Use this to list the annotations
self.display = self.du.draw_annotations(self.display, anns, colors)
if self.show_other_anns:
self.__draw_known_annotations(selected_annotations)

def add_click(self, new_pt, new_label, selected_annotations=[]):
self.curr_inputs.add_input_click(new_pt, new_label)
Expand Down Expand Up @@ -197,21 +194,23 @@ def save_ann(self):

elif self.curr_inputs.curr_point_mask is not None:
tmp_combination = self.curr_inputs.curr_point_mask
tmp_combination[tmp_combination > 0] = True
tmp_combination[tmp_combination < 0] = False
# tmp_combination[tmp_combination > 0] = True
# tmp_combination[tmp_combination < 0] = False

else:
tmp_combination = None

self.dataset_explorer.add_annotation(
self.image_id, self.category_id, tmp_combination
)
# print(self.curr_inputs.curr_point_mask)
# self.dataset_explorer.add_annotation(
# self.image_id, self.category_id, self.curr_inputs.curr_mask
# self.image_id, self.category_id, self.curr_inputs.curr_point_mask
# )

def save(self):
self.dataset_explorer.save_annotation()
self.dataset_explorer.save_status(self.image_id, self.status)
# self.dataset_explorer.save_status(self.image_id, self.status)

def next_image(self):
if self.image_id == self.dataset_explorer.get_num_images() - 1:
Expand All @@ -222,7 +221,6 @@ def next_image(self):
self.image_bgr,
self.image_embedding,
self.name,
self.status
) = self.dataset_explorer.get_image_data(self.image_id)
self.display = self.image_bgr.copy()
self.onnx_helper.set_image_resolution(self.image.shape[1], self.image.shape[0])
Expand All @@ -235,7 +233,6 @@ def jump2image(self, image_id):
self.image_bgr,
self.image_embedding,
self.name,
self.status
) = self.dataset_explorer.get_image_data(self.image_id)

self.display = self.image_bgr.copy()
Expand All @@ -251,7 +248,6 @@ def prev_image(self):
self.image_bgr,
self.image_embedding,
self.name,
self.status
) = self.dataset_explorer.get_image_data(self.image_id)
self.display = self.image_bgr.copy()
self.onnx_helper.set_image_resolution(self.image.shape[1], self.image.shape[0])
Expand Down
10 changes: 5 additions & 5 deletions salt/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ def __init__(self, app, editor, panel_size=(1920, 1080)):

self.layout.addLayout(self.main_window)

self.status_panel = self.get_review_side_panel()
self.main_window.addWidget(self.status_panel)
self.layout.addLayout(self.main_window)
# self.status_panel = self.get_review_side_panel()
# self.main_window.addWidget(self.status_panel)
# self.layout.addLayout(self.main_window)

self.label = QLabel()
self.label.resize(200, 100)
self.label.setText(f'{self.editor.name} ... 1/{self.editor.dataset_explorer.get_num_images()} ... {self.editor.get_status_name()}')
self.label.setText(f'{self.editor.name} ... 1/{self.editor.dataset_explorer.get_num_images()}')
self.layout.addWidget(self.label)

self.setLayout(self.layout)
Expand Down Expand Up @@ -317,7 +317,7 @@ def annotation_list_item_clicked(self, item):
# return panel

def _update_label(self, name, image_id):
self.label.setText(f'{name} ... {image_id+1}/{self.editor.dataset_explorer.get_num_images()} ... {self.editor.get_status_name()}')
self.label.setText(f'{name} ... {image_id+1}/{self.editor.dataset_explorer.get_num_images()}')
self.layout.addWidget(self.label)
self.setLayout(self.layout)

Expand Down

0 comments on commit bd85198

Please sign in to comment.