Error Description:
When running my app.py in my Hugging Face Space, I get the following runtime error:
===== Application Startup at 2025-10-22 17:41:38 =====
Traceback (most recent call last):
File "/home/user/app/app.py", line 10, in <module>
learn = load_learner('final_model.pkl')
File "/usr/local/lib/python3.10/site-packages/fastai/learner.py", line 446, in load_learner
try: res = torch.load(fname, map_location=map_loc, pickle_module=pickle_module)
File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 1025, in load
return _load(opened_zipfile,
File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 1446, in _load
result = unpickler.load()
File "/usr/local/lib/python3.10/site-packages/torch/serialization.py", line 1439, in find_class
return super().find_class(mod_name, name)
ModuleNotFoundError: No module named 'fasttransform'
What I’ve Tried So Far:
-
Used the model
.pklexported from Google Colab – Colab notebook link – this failed with the sameModuleNotFoundError. -
Used my personal PC version of the
.pklfile – same error persists. -
Retrained and exported a new model directly in WSL (Linux environment), ensuring compatibility – still got the same
fasttransformerror when loading the model in the HF Space. -
Checked dependencies and confirmed that
fasttransformis not explicitly part of my code. -
Removed older
.pklfiles and tried using only the new one.
Additional Info:
-
The same Gradio interface works correctly when run in Jupyter Notebook locally.
-
The issue only occurs when running in Hugging Face Spaces.
Current Status:
The Space fails to load the model due to a missing fasttransform dependency during load_learner. This dependency is not present in my code, but the .pkl file seems to reference internal fastai transforms or legacy objects that were part of the original training environment, which aren’t available in the HF Space environment.