lazylabel-gui 1.0.8__py3-none-any.whl → 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lazylabel/__init__.py +9 -0
- lazylabel/config/__init__.py +7 -0
- lazylabel/config/hotkeys.py +169 -0
- lazylabel/config/paths.py +41 -0
- lazylabel/config/settings.py +66 -0
- lazylabel/core/__init__.py +7 -0
- lazylabel/core/file_manager.py +106 -0
- lazylabel/core/model_manager.py +94 -0
- lazylabel/core/segment_manager.py +140 -0
- lazylabel/main.py +10 -1246
- lazylabel/models/__init__.py +5 -0
- lazylabel/models/sam_model.py +154 -0
- lazylabel/ui/__init__.py +8 -0
- lazylabel/ui/control_panel.py +220 -0
- lazylabel/{editable_vertex.py → ui/editable_vertex.py} +25 -3
- lazylabel/ui/hotkey_dialog.py +384 -0
- lazylabel/{hoverable_polygon_item.py → ui/hoverable_polygon_item.py} +17 -1
- lazylabel/ui/main_window.py +1264 -0
- lazylabel/ui/right_panel.py +239 -0
- lazylabel/ui/widgets/__init__.py +7 -0
- lazylabel/ui/widgets/adjustments_widget.py +107 -0
- lazylabel/ui/widgets/model_selection_widget.py +94 -0
- lazylabel/ui/widgets/settings_widget.py +106 -0
- lazylabel/utils/__init__.py +6 -0
- lazylabel/utils/custom_file_system_model.py +132 -0
- {lazylabel_gui-1.0.8.dist-info → lazylabel_gui-1.1.0.dist-info}/METADATA +62 -12
- lazylabel_gui-1.1.0.dist-info/RECORD +36 -0
- lazylabel/controls.py +0 -261
- lazylabel/custom_file_system_model.py +0 -72
- lazylabel/sam_model.py +0 -70
- lazylabel_gui-1.0.8.dist-info/RECORD +0 -17
- /lazylabel/{hoverable_pixelmap_item.py → ui/hoverable_pixelmap_item.py} +0 -0
- /lazylabel/{numeric_table_widget_item.py → ui/numeric_table_widget_item.py} +0 -0
- /lazylabel/{photo_viewer.py → ui/photo_viewer.py} +0 -0
- /lazylabel/{reorderable_class_table.py → ui/reorderable_class_table.py} +0 -0
- /lazylabel/{utils.py → utils/utils.py} +0 -0
- {lazylabel_gui-1.0.8.dist-info → lazylabel_gui-1.1.0.dist-info}/WHEEL +0 -0
- {lazylabel_gui-1.0.8.dist-info → lazylabel_gui-1.1.0.dist-info}/entry_points.txt +0 -0
- {lazylabel_gui-1.0.8.dist-info → lazylabel_gui-1.1.0.dist-info}/licenses/LICENSE +0 -0
- {lazylabel_gui-1.0.8.dist-info → lazylabel_gui-1.1.0.dist-info}/top_level.txt +0 -0
lazylabel/sam_model.py
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import cv2
|
3
|
-
import numpy as np
|
4
|
-
import torch
|
5
|
-
import requests
|
6
|
-
from tqdm import tqdm
|
7
|
-
from segment_anything import sam_model_registry, SamPredictor
|
8
|
-
|
9
|
-
|
10
|
-
def download_model(url, download_path):
|
11
|
-
"""Downloads file with a progress bar."""
|
12
|
-
print(
|
13
|
-
f"SAM model not found. Downloading from Meta's GitHub repository to: {download_path}"
|
14
|
-
)
|
15
|
-
response = requests.get(url, stream=True)
|
16
|
-
response.raise_for_status()
|
17
|
-
total_size_in_bytes = int(response.headers.get("content-length", 0))
|
18
|
-
block_size = 1024 # 1 Kibibyte
|
19
|
-
|
20
|
-
progress_bar = tqdm(total=total_size_in_bytes, unit="iB", unit_scale=True)
|
21
|
-
with open(download_path, "wb") as file:
|
22
|
-
for data in response.iter_content(block_size):
|
23
|
-
progress_bar.update(len(data))
|
24
|
-
file.write(data)
|
25
|
-
progress_bar.close()
|
26
|
-
|
27
|
-
if total_size_in_bytes != 0 and progress_bar.n != total_size_in_bytes:
|
28
|
-
print("ERROR, something went wrong during download")
|
29
|
-
|
30
|
-
|
31
|
-
class SamModel:
|
32
|
-
def __init__(self, model_type, model_filename="sam_vit_h_4b8939.pth"):
|
33
|
-
self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
34
|
-
|
35
|
-
# Define model URL and local cache path
|
36
|
-
model_url = f"https://dl.fbaipublicfiles.com/segment_anything/{model_filename}"
|
37
|
-
cache_dir = os.path.join(os.path.expanduser("~"), ".cache", "lazylabel")
|
38
|
-
os.makedirs(cache_dir, exist_ok=True)
|
39
|
-
model_path = os.path.join(cache_dir, model_filename)
|
40
|
-
|
41
|
-
# Download the model if it doesn't exist
|
42
|
-
if not os.path.exists(model_path):
|
43
|
-
download_model(model_url, model_path)
|
44
|
-
|
45
|
-
print(f"Loading SAM model from {model_path}...")
|
46
|
-
self.model = sam_model_registry[model_type](checkpoint=model_path).to(
|
47
|
-
self.device
|
48
|
-
)
|
49
|
-
self.predictor = SamPredictor(self.model)
|
50
|
-
self.image = None
|
51
|
-
print("SAM model loaded successfully.")
|
52
|
-
|
53
|
-
def set_image(self, image_path):
|
54
|
-
self.image = cv2.imread(image_path)
|
55
|
-
self.image = cv2.cvtColor(self.image, cv2.COLOR_BGR2RGB)
|
56
|
-
self.predictor.set_image(self.image)
|
57
|
-
|
58
|
-
def predict(self, positive_points, negative_points):
|
59
|
-
if not positive_points:
|
60
|
-
return None
|
61
|
-
|
62
|
-
points = np.array(positive_points + negative_points)
|
63
|
-
labels = np.array([1] * len(positive_points) + [0] * len(negative_points))
|
64
|
-
|
65
|
-
masks, _, _ = self.predictor.predict(
|
66
|
-
point_coords=points,
|
67
|
-
point_labels=labels,
|
68
|
-
multimask_output=False,
|
69
|
-
)
|
70
|
-
return masks[0]
|
@@ -1,17 +0,0 @@
|
|
1
|
-
lazylabel/controls.py,sha256=kminJPdKDzrSacTaUuLYXVW_nyTOcoGV_iWlMHyOfsA,10533
|
2
|
-
lazylabel/custom_file_system_model.py,sha256=q4axrAQPQeURVz-sFeVl4s9pyY05OE9A2Ej95Ju1rXM,2488
|
3
|
-
lazylabel/editable_vertex.py,sha256=itGcZG5MyuctGfxjINu8IJBYFFsCGuE_YtsrfHICjiw,1115
|
4
|
-
lazylabel/hoverable_pixelmap_item.py,sha256=kJFOp7WXiyHpNf7l73TZjiob85jgP30b5MZvu_z5L3c,728
|
5
|
-
lazylabel/hoverable_polygon_item.py,sha256=-0l8C8PfsXtJGqvZZ2qtizxHmFwO8RCwz5UfjKpDvzY,775
|
6
|
-
lazylabel/main.py,sha256=C-ZHVFzAbnGPRDFCBTLvn3uBMuu_qq4UUsfF8cZmdns,50862
|
7
|
-
lazylabel/numeric_table_widget_item.py,sha256=dQUlIFu9syCxTGAHVIlmbgkI7aJ3f3wmDPBz1AGK9Bg,283
|
8
|
-
lazylabel/photo_viewer.py,sha256=PNgm0gU2gnIqvRkrGlQugdobGsKwAi3m3X6ZF487lCo,2055
|
9
|
-
lazylabel/reorderable_class_table.py,sha256=4c-iuSkPcmk5Aey5n2zz49O85x9TQPujKG-JLxtuBCo,2406
|
10
|
-
lazylabel/sam_model.py,sha256=9NB51Xq1P5dIxZMBdttwwRlszlJR3U5HRs83QsPLxNE,2595
|
11
|
-
lazylabel/utils.py,sha256=sYSCoXL27OaLgOZaUkCAhgmKZ7YfhR3Cc5F8nDIa3Ig,414
|
12
|
-
lazylabel_gui-1.0.8.dist-info/licenses/LICENSE,sha256=kSDEIgrWAPd1u2UFGGpC9X71dhzrlzBFs8hbDlENnGE,1092
|
13
|
-
lazylabel_gui-1.0.8.dist-info/METADATA,sha256=1JlchgipzdT-mspfXCovQ1FalX0vyg4jdxFfaK1F9eA,6292
|
14
|
-
lazylabel_gui-1.0.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
-
lazylabel_gui-1.0.8.dist-info/entry_points.txt,sha256=Hd0WwEG9OPTa_ziYjiD0aRh7R6Fupt-wdQ3sspdc1mM,54
|
16
|
-
lazylabel_gui-1.0.8.dist-info/top_level.txt,sha256=YN4uIyrpDBq1wiJaBuZLDipIzyZY0jqJOmmXiPIOUkU,10
|
17
|
-
lazylabel_gui-1.0.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|