Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model is missing #13

Open
spficklin opened this issue May 29, 2024 · 0 comments
Open

Model is missing #13

spficklin opened this issue May 29, 2024 · 0 comments
Assignees
Milestone

Comments

@spficklin
Copy link
Member

spficklin commented May 29, 2024

When running granny with the demo data we seem to be missing the model for segmentation and we get the following error:

Traceback (most recent call last):
  File "/home/ficklin/.local/bin/granny", line 8, in <module>
    sys.exit(run())
  File "/home/ficklin/.local/lib/python3.10/site-packages/Granny/GrannyBase.py", line 31, in run
    GrannyCLI(parser).run()
  File "/home/ficklin/.local/lib/python3.10/site-packages/Granny/Interfaces/UI/GrannyCLI.py", line 110, in run
    analysis = aclass(images)
  File "/home/ficklin/.local/lib/python3.10/site-packages/Granny/Analyses/Segmentation.py", line 24, in __init__
    self.AIModel.loadModel()
  File "/home/ficklin/.local/lib/python3.10/site-packages/Granny/Models/AIModel/YoloModel.py", line 25, in loadModel
    self.model = YOLO(self.model_dir)
  File "/home/ficklin/.local/lib/python3.10/site-packages/ultralytics/engine/model.py", line 134, in __init__
    self._load(model, task=task)
  File "/home/ficklin/.local/lib/python3.10/site-packages/ultralytics/engine/model.py", line 215, in _load
    self.model, self.ckpt = attempt_load_one_weight(weights)
  File "/home/ficklin/.local/lib/python3.10/site-packages/ultralytics/nn/tasks.py", line 709, in attempt_load_one_weight
    ckpt, weight = torch_safe_load(weight)  # load ckpt
  File "/home/ficklin/.local/lib/python3.10/site-packages/ultralytics/nn/tasks.py", line 634, in torch_safe_load
    ckpt = torch.load(file, map_location="cpu")
  File "/home/ficklin/.local/lib/python3.10/site-packages/torch/serialization.py", line 791, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "/home/ficklin/.local/lib/python3.10/site-packages/torch/serialization.py", line 271, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "/home/ficklin/.local/lib/python3.10/site-packages/torch/serialization.py", line 252, in __init__
    super().__init__(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: '/home/ficklin/.local/lib/python3.10/site-packages/Granny/Analyses/config/Segmentation/granny_v1_yolo8.pt

Solution
We cannot package the model inside of the software. It's too big (~300MB). So, we need to put the model in a public repository so it can be downloaded. Perhaps that can be on the OSF (https://osf.io/). We should name the files in this way granny-v{granny_version}-{model_name}-v{model_version}.pt. We should add a new argument to the segmentation step that indicates where the model is located. If a local path is provided then the local model file is used. If a string of the form {model_name}-v{model_version} is provided, then Granny will download the model file from OSF, store it in the current directory and then use that model.

@spficklin spficklin added this to the Version 1.0 milestone May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants