roboflow / notebooks

Examples and tutorials on using SOTA computer vision models and techniques. Learn everything from old-school ResNet, through YOLO and object-detection transformers like DETR, to the latest models like Grounding DINO and SAM.
https://roboflow.com/models
5.09k stars 788 forks source link

Deploy bug #51

Closed mikearney closed 1 year ago

mikearney commented 1 year ago

Search before asking

Notebook name

train-yolov8-object-detection-on-custom-dataset.ipynb

Bug

image
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
[<ipython-input-19-cec2a1551afa>](https://localhost:8080/#) in <module>
----> 1 project.version(dataset.version).deploy(model_type="yolov8", model_path=f"/content/runs/detect/train")

3 frames
[/usr/local/lib/python3.8/dist-packages/roboflow/core/version.py](https://localhost:8080/#) in deploy(self, model_type, model_path)
    311         # add logic to save torch state dict safely
    312         if model_type == "yolov8":
--> 313             model = torch.load(model_path + "weights/best.pt")
    314 
    315             class_names = []

[/usr/local/lib/python3.8/dist-packages/torch/serialization.py](https://localhost:8080/#) in load(f, map_location, pickle_module, weights_only, **pickle_load_args)
    769         pickle_load_args['encoding'] = 'utf-8'
    770 
--> 771     with _open_file_like(f, 'rb') as opened_file:
    772         if _is_zipfile(opened_file):
    773             # The zipfile reader is going to advance the current file position.

[/usr/local/lib/python3.8/dist-packages/torch/serialization.py](https://localhost:8080/#) in _open_file_like(name_or_buffer, mode)
    268 def _open_file_like(name_or_buffer, mode):
    269     if _is_path(name_or_buffer):
--> 270         return _open_file(name_or_buffer, mode)
    271     else:
    272         if 'w' in mode:

[/usr/local/lib/python3.8/dist-packages/torch/serialization.py](https://localhost:8080/#) in __init__(self, name, mode)
    249 class _open_file(_opener):
    250     def __init__(self, name, mode):
--> 251         super(_open_file, self).__init__(open(name, mode))
    252 
    253     def __exit__(self, *args):

FileNotFoundError: [Errno 2] No such file or directory: '/content/runs/detect/trainweights/best.pt'

Colab

Minimal Reproducible Example

No response

Additional

Hope this is not another oversight from me, but I'm stuck :(

Are you willing to submit a PR?

mo-traor3-ai commented 1 year ago

@mikearney All I'm seeing is that the path to your model weights isn't being found.

FileNotFoundError: [Errno 2] No such file or directory: '/content/runs/detect/trainweights/best.pt'

Did you run that cell before updating the path to "{HOME}/runs/detect/train/", or while it was still "{HOME}/runs/detect/train"?

The only thing causing the error is missing a / in the path to your model weights:

image
Jacobsolawetz commented 1 year ago

@mikearney I was thinking the same thing perhaps as @mo-traor3-ai

SkalskiP commented 1 year ago

@mikearney I also submitted a PR to roboflow pip package to make that / just optional.

SkalskiP commented 1 year ago

@mikearney please let me know if those tips solved your issue.

mikearney commented 1 year ago

Solved. Thank you