Skip to content

Commit 721fdd2

Browse files
committed
Add pkg_resources for yolo model
1 parent c590889 commit 721fdd2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

operate/models/apis.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
ANSI_RED,
3232
ANSI_RESET,
3333
)
34+
import pkg_resources
3435

3536

3637
# Load configuration
@@ -191,8 +192,11 @@ def call_gemini_pro_vision(messages, objective):
191192
async def call_gpt_4_vision_preview_labeled(messages, objective):
192193
time.sleep(1)
193194
client = config.initialize_openai()
195+
196+
# Construct the path to the file within the package
194197
try:
195-
yolo_model = YOLO("./operate/models/weights/best.pt") # Load your trained model
198+
file_path = pkg_resources.resource_filename("operate.models.weights", "best.pt")
199+
yolo_model = YOLO(file_path) # Load your trained model
196200
screenshots_dir = "screenshots"
197201
if not os.path.exists(screenshots_dir):
198202
os.makedirs(screenshots_dir)

operate/models/weights/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)