NotImplementedError: Unable to load model='foduucom/table-detection-and-extraction'. As an example try model='yolov8n.pt' or model='yolov8n.yaml'

#15
by np-neupane - opened

Hi there,

I am trying to test the performance of the model in the table detection. While I am running the model on the Google colab by following the provided information in model card, it is not loaded and throws the following error.

--------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/ultralyticsplus/ultralytics_utils.py in __init__(self, model, type, hf_token)
     55             if Path(model).suffix not in (".pt", ".yaml"):
---> 56                 self._load_from_hf_hub(model, hf_token=hf_token)
     57             elif suffix == ".yaml":

5 frames
UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint. 
    (1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
    (2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
    WeightsUnpickler error: Unsupported global: GLOBAL ultralytics.nn.tasks.DetectionModel was not an allowed global by default. Please use `torch.serialization.add_safe_globals([DetectionModel])` or the `torch.serialization.safe_globals([DetectionModel])` context manager to allowlist this global if you trust this class/function.

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

The above exception was the direct cause of the following exception:

NotImplementedError                       Traceback (most recent call last)
/usr/local/lib/python3.11/dist-packages/ultralyticsplus/ultralytics_utils.py in __init__(self, model, type, hf_token)
     60                 self._load(model)
     61         except Exception as e:
---> 62             raise NotImplementedError(
     63                 f"Unable to load model='{model}'. "
     64                 f"As an example try model='yolov8n.pt' or model='yolov8n.yaml'"

NotImplementedError: Unable to load model='foduucom/table-detection-and-extraction'. As an example try model='yolov8n.pt' or model='yolov8n.yaml'

Do you have any idea behind the issue. If yes, the what is the solution for the problem. Thank you in advance.

Hey

It looks like the error you're encountering is because you're trying to load the model incorrectly. To resolve the issue, you need to use the correct path to the model.

Please follow these steps :
First, clone the model using the following command :

git clone https://huggingface.co/foduucom/stockmarket-future-prediction

Once the model is cloned, you can load it using this code :

model = YOLO('stockmarket-future-prediction/best.pt')

Make sure you are loading the 'best.pt' model given in the files

Thanks

Sign up or log in to comment