Fix load yolov10 module to my app

Hi. I have a problem. I have try to download my pretrain file from Google Drive using gdown and I try to load it to my yolov10 model path, but this pickle load problem keep exist.
I faced this before when I was using Git LFS and I fix it by create a .gitattributes file. But now im using file downloaded from Google Drive. Is there any fix for this.
Error code here:

  /home/adminuser/venv/lib/python3.11/site-packages/ultralytics/engine/model.p  

  y:141 in __init__                                                             

                                                                                

    138 │   │   if Path(model).suffix in (".yaml", ".yml"):                     

    139 │   │   │   self._new(model, task=task, verbose=verbose)                

    140 │   │   else:                                                           

  ❱ 141 │   │   │   self._load(model, task=task)                                

    142 │                                                                       

    143 │   def __call__(                                                       

    144 │   │   self,                                                           

                                                                                

  /home/adminuser/venv/lib/python3.11/site-packages/ultralytics/engine/model.p  

  y:230 in _load                                                                

                                                                                

    227 │   │   weights = checks.check_model_file_from_stem(weights)  # add su  

    228 │   │                                                                   

    229 │   │   if Path(weights).suffix == ".pt":                               

  ❱ 230 │   │   │   self.model, self.ckpt = attempt_load_one_weight(weights)    

    231 │   │   │   self.task = self.model.args["task"]                         

    232 │   │   │   self.overrides = self.model.args = self._reset_ckpt_args(s  

    233 │   │   │   self.ckpt_path = self.model.pt_path                         

                                                                                

  /home/adminuser/venv/lib/python3.11/site-packages/ultralytics/nn/tasks.py:80  

  7 in attempt_load_one_weight                                                  

                                                                                

     804                                                                        

     805 def attempt_load_one_weight(weight, device=None, inplace=True, fuse=F  

     806 │   """Loads a single model weights."""                                

  ❱  807 │   ckpt, weight = torch_safe_load(weight)  # load ckpt                

     808 │   args = {**DEFAULT_CFG_DICT, **(ckpt.get("train_args", {}))}  # co  

     809 │   model = (ckpt.get("ema") or ckpt["model"]).to(device).float()  #   

     810                                                                        

                                                                                

  /home/adminuser/venv/lib/python3.11/site-packages/ultralytics/nn/tasks.py:73  

  3 in torch_safe_load                                                          

                                                                                

     730 │   │   │   │   "ultralytics.yolo.data": "ultralytics.data",           

     731 │   │   │   }                                                          

     732 │   │   ):  # for legacy 8.0 Classify and Pose models                  

  ❱  733 │   │   │   ckpt = torch.load(file, map_location="cpu")                

     734 │                                                                      

     735 │   except ModuleNotFoundError as e:  # e.name is missing module name  

     736 │   │   if e.name == "models":                                         

                                                                                

  /home/adminuser/venv/lib/python3.11/site-packages/torch/serialization.py:104  

  0 in load                                                                     

                                                                                

    1037 │   │   │   │   return _legacy_load(opened_file, map_location, _weigh  

    1038 │   │   │   except RuntimeError as e:                                  

    1039 │   │   │   │   raise pickle.UnpicklingError(UNSAFE_MESSAGE + str(e))  

  ❱ 1040 │   │   return _legacy_load(opened_file, map_location, pickle_module,  

    1041                                                                        

    1042                                                                        

    1043 # Register pickling support for layout instances such as               

                                                                                

  /home/adminuser/venv/lib/python3.11/site-packages/torch/serialization.py:126  

  2 in _legacy_load                                                             

                                                                                

    1259 │   │   │   f"Received object of type \"{type(f)}\". Please update to  

    1260 │   │   │   "functionality.")                                          

    1261 │                                                                      

  ❱ 1262 │   magic_number = pickle_module.load(f, **pickle_load_args)           

    1263 │   if magic_number != MAGIC_NUMBER:                                   

    1264 │   │   raise RuntimeError("Invalid magic number; corrupt file?")      

    1265 │   protocol_version = pickle_module.load(f, **pickle_load_args)       

────────────────────────────────────────────────────────────────────────────────

UnpicklingError: invalid load key, '<'.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.