Skip to content

Model is missing #13

@spficklin

Description

@spficklin

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions