Lesson 2 - Chihuahua vs Biscuit

Successfully deployed tutorial in lesson 2 into Hugging Face.
It’s an image classification to diff between Chihuahua vs Dog. It’s inspired by a joke with my friend when we started learn machine learning as both image looks familiar & funny.

The Hugging Face URL https://www.kaggle.com/code/budiarsana/dog-cihuahua-biscuit-machine-learning


My Experience:
I found difficulty deploying the model into Hugging Face (HF) due to several factors.

Different version in python
In Kaggle, where the model trained using python v3.1 but HF using python v3.0. This causing the model failed to load correctly with message like torch expect “x” arguments but found “y” arguments. In Kaggle, we can’t downgrade the PHP version and in HF there is no python v3.1 yet.

The model detected as unsafe
Model can’t be loaded using load_learner(…). After research, I believe the issue caused by the model was trained with PIL (following the tutorial) package which make it hash something and detected unsafe.

How I resolve it
I end up and successfully deployed the model with Docker. Since if I using Docker, I have full control each version of software will be installed. I keep using Gradio instead of HF provided Streamlit because I “accidentally” already learnt Gradio while testing the suggested deploy method.

Source code for Dockerfile: Dockerfile · gusdecool/cihuahua-vs-biscuit-docker at main

For the warning when loading the model, I resolve it to ignore the warning at the moment. Since this is only a test case study and the main focus just to successfully to deploy, it should be okay for now.

Example how I ignore the error is at app.py · gusdecool/cihuahua-vs-biscuit-docker at main

Hopefully this help you if you facing the same issue on this lesson. Let me know if you need help on deployment or if there is question.

Cheers,
Budi