Skip to content

Commit f8c39f9

Browse files
committed
Refactor resource path handling and update model loading in extract_stamps function
1 parent 84d73d1 commit f8c39f9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

philately_tool.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535

3636
import sqlite_vec
3737
from sqlite_vec import serialize_float32
38+
import os
39+
40+
def resource_path(relative_path):
41+
"""Get absolute path to resource, works for dev and PyInstaller"""
42+
if hasattr(sys, "_MEIPASS"):
43+
return os.path.join(sys._MEIPASS, relative_path)
44+
return os.path.join(os.path.abspath("."), relative_path)
45+
3846

3947
# -----------------------------
4048
# Configuration Management
@@ -166,7 +174,7 @@ def _positional_params(fn):
166174
if on_status:
167175
on_status(msg)
168176

169-
model = YOLO(CFG["model_path"])
177+
model = YOLO(resource_path(CFG["model_path"]))
170178

171179
embedder = None
172180
conn = None
@@ -192,6 +200,11 @@ def _positional_params(fn):
192200
total = len(images)
193201

194202
for idx, img_path in enumerate(images, start=1):
203+
msg = f"Processing File: {img_path.name} ({idx}/{total})"
204+
banner(msg)
205+
if on_status:
206+
on_status(msg)
207+
195208
if on_progress:
196209
on_progress(idx, total)
197210

0 commit comments

Comments
 (0)