I have getting this error:-
FileNotFoundError: [Errno 2] No such file or directory: ‘C:/Users/HP/Repositories/Projects/candy_images/models/runs/detect/train/weights\weights/best.pt’
So if you pass a directory that already ends with weights, the code will try to open …/weights/weights/best.pt, which of course does not exist. (docs.roboflow.com)
Option 1 – point one level higher
workspace.deploy_model(
model_type="yolov8",
# directory that *contains* the `weights/` folder
model_path=r"C:\Users\HP\Repositories\Projects\candy_images\models\runs\detect\train",
project_ids=["<your-project-id>"],
model_name="yolov8-my_model"
)
Option 2 – keep the same folder but override the filename
workspace.deploy_model(
model_type="yolov8",
model_path=r"C:\Users\HP\Repositories\Projects\candy_images\models\runs\detect\train\weights",
filename="best.pt", # no extra `weights/` added
project_ids=["<your-project-id>"],
model_name="yolov8-my_model"
)