I get this error. At the begging I thought it was a thing about hugging face app, but running this locally I get the same error. Any Idea on how to fix it?
python3.10/site-packages/fastai/learner.py:455: UserWarning: load_learner` uses Python's insecure pickle module, which can execute malicious arbitrary code when loading. Only load files you trust.
If you only need to load model weights and optimizer state, use the safe `Learner.load` instead.
warn("load_learner` uses Python's insecure pickle module, which can execute malicious arbitrary code when loading. Only load files you trust.\nIf you only need to load model weights and optimizer state, use the safe `Learner.load` instead.")
When you create ârequirements.txtâ file for Hugging face it should also tells the version of fastai library.
you can check
import fastai
fastai.version
requirement file should be like this in hugging face
ââ"
fastai==2.7.19
gradio
scikit-image
Hello!
The âerrorâ youâre seeing from fastai is actually a UserWarning about Pythonâs pickle module, not a fatal error. Itâs a security alert advising that load_learner can execute arbitrary code if the model.pkl file comes from an untrusted source. If you created the HumanToDog com file or trust its origin, you can safely proceed in your local environment. For a more secure approach, especially if you only need model weights, use Learner.load() after defining your model architecture, as it avoids pickleâs potential security risks.
@AntonioML I end up using Docker to deploy into Hugging Face as even after I resolved that unsecure model because of using PIL library to train. I end up with another issue with Python version missmatch between Kaggle where I train the model and Hugging Face version.
Sorry I didnât answer, Havenât had much time lately. Iâm not sure how to mark as trusted the file on Hugging face.
But the manually setting the version of fastai solved the issue for me.