Skip to content

Commit 13fd97f

Browse files
committed
Fix problems related to lack of trailing / at the end of model_path. roboflow/notebooks#51
1 parent be09139 commit 13fd97f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

roboflow/core/version.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def deploy(self, model_type: str, model_path: str) -> None:
310310

311311
# add logic to save torch state dict safely
312312
if model_type == "yolov8":
313-
model = torch.load(model_path + "weights/best.pt")
313+
model = torch.load(os.path.join(model_path + "weights/best.pt"))
314314

315315
class_names = []
316316
for i, val in enumerate(model["model"].names):
@@ -345,21 +345,21 @@ def deploy(self, model_type: str, model_path: str) -> None:
345345
"model_type": model_type,
346346
}
347347

348-
with open(model_path + "model_artifacts.json", "w") as fp:
348+
with open(os.path.join(model_path + "model_artifacts.json", "w")) as fp:
349349
json.dump(model_artifacts, fp)
350350

351-
torch.save(model["model"].state_dict(), model_path + "state_dict.pt")
351+
torch.save(model["model"].state_dict(), os.path.join(model_path + "state_dict.pt"))
352352

353353
lista_files = [
354354
"results.csv",
355355
"results.png",
356356
"model_artifacts.json",
357357
"state_dict.pt",
358358
]
359-
with zipfile.ZipFile(model_path + "roboflow_deploy.zip", "w") as zipMe:
359+
with zipfile.ZipFile(os.path.join(model_path + "roboflow_deploy.zip", "w")) as zipMe:
360360
for file in lista_files:
361361
zipMe.write(
362-
model_path + file,
362+
os.path.join(model_path + file),
363363
arcname=file,
364364
compress_type=zipfile.ZIP_DEFLATED,
365365
)
@@ -379,7 +379,7 @@ def deploy(self, model_type: str, model_path: str) -> None:
379379
return
380380

381381
res = requests.put(
382-
res.json()["url"], data=open(model_path + "roboflow_deploy.zip", "rb")
382+
res.json()["url"], data=open(os.path.join(model_path + "roboflow_deploy.zip", "rb"))
383383
)
384384
try:
385385
res.raise_for_status()

0 commit comments

Comments
 (0)