Hello Everyone. When I am loading Model exported model I am getting blow error.
I am not resolve the issue. Please help
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[6], line 1
----> 1 learn2 = load_learner('/kaggle/working/asl_sign_multi_resnet18_02.pkl')
File /opt/conda/lib/python3.10/site-packages/fastai/learner.py:446, in load_learner(fname, cpu, pickle_module)
444 distrib_barrier()
445 map_loc = 'cpu' if cpu else default_device()
--> 446 try: res = torch.load(fname, map_location=map_loc, pickle_module=pickle_module)
447 except AttributeError as e:
448 e.args = [f"Custom classes or functions exported with your `Learner` not available in namespace.\Re-declare/import before loading:\n\t{e.args[0]}"]
File /opt/conda/lib/python3.10/site-packages/torch/serialization.py:1014, in load(f, map_location, pickle_module, weights_only, mmap, **pickle_load_args)
1012 except RuntimeError as e:
1013 raise pickle.UnpicklingError(UNSAFE_MESSAGE + str(e)) from None
-> 1014 return _load(opened_zipfile,
1015 map_location,
1016 pickle_module,
1017 overall_storage=overall_storage,
1018 **pickle_load_args)
1019 if mmap:
1020 raise RuntimeError("mmap can only be used with files saved with ",
1021 "`torch.save(_use_new_zipfile_serialization=True), "
1022 "please torch.save your checkpoint with this option in order to use mmap.")
File /opt/conda/lib/python3.10/site-packages/torch/serialization.py:1422, in _load(zip_file, map_location, pickle_module, pickle_file, overall_storage, **pickle_load_args)
1420 unpickler = UnpicklerWrapper(data_file, **pickle_load_args)
1421 unpickler.persistent_load = persistent_load
-> 1422 result = unpickler.load()
1424 torch._utils._validate_loaded_sparse_tensors()
1425 torch._C._log_api_usage_metadata(
1426 "torch.load.metadata", {"serialization_id": zip_file.serialization_id()}
1427 )
File /opt/conda/lib/python3.10/site-packages/torch/serialization.py:1415, in _load.<locals>.UnpicklerWrapper.find_class(self, mod_name, name)
1413 pass
1414 mod_name = load_module_mapping.get(mod_name, mod_name)
-> 1415 return super().find_class(mod_name, name)
AttributeError: Custom classes or functions exported with your `Learner` not available in namespace.\Re-declare/import before loading:
Can't get attribute 'label_to_class' on <module '__main__'>