Spaces:
Sleeping
Sleeping
Ian Frederick Hartanto commited on
Update readme again..
Browse files
README.md
CHANGED
|
@@ -13,5 +13,39 @@ pinned: true
|
|
| 13 |
|
| 14 |
classifies dog emotions from facial expressions using deep learning. This project leverages Transfer Learning with the ResNet50 architecture to identify four core emotional states: Happy, Sad, Relaxed, and Angry.
|
| 15 |
|
| 16 |
-
π Demo
|
| 17 |
You can try the live application on Hugging Face Spaces: π [View Live Demo](https://huggingface.co/spaces/ianhee/dog-emotion-classifier)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
classifies dog emotions from facial expressions using deep learning. This project leverages Transfer Learning with the ResNet50 architecture to identify four core emotional states: Happy, Sad, Relaxed, and Angry.
|
| 15 |
|
| 16 |
+
## π Demo
|
| 17 |
You can try the live application on Hugging Face Spaces: π [View Live Demo](https://huggingface.co/spaces/ianhee/dog-emotion-classifier)
|
| 18 |
+
|
| 19 |
+
## π§ Overview
|
| 20 |
+
I have two dogs, and sometimes maintaining their emotional well-being can be a bit challenging due to their differing communication methods. Communication is crucial for better animal care and well-being, so I thought about creating something that aims to bridge the communication gap between humans and dogs using computer vision.
|
| 21 |
+
|
| 22 |
+
### Features
|
| 23 |
+
- Model : Built on top of the ResNet50 architecture.
|
| 24 |
+
- Transfer Learning : Utilizes pre-trained weights from ImageNet for high-accuracy feature extraction.
|
| 25 |
+
- Robust Preprocessing: Automated image resizing and normalization optimized for canine facial features.
|
| 26 |
+
|
| 27 |
+
## π οΈ Technical Stack
|
| 28 |
+
- Framework: Keras 3.8.0 / TensorFlow 2.18.0
|
| 29 |
+
- Backbone: ResNet50
|
| 30 |
+
- Environment: Google Colab (Training), Hugging Face Spaces (Deployment)
|
| 31 |
+
- Libraries: NumPy, OpenCV, PIL, Gradio, Gdown
|
| 32 |
+
|
| 33 |
+
## π Dataset
|
| 34 |
+
The model was trained on a comprehensive dataset of dog facial expressions sourced from [kaggle](https://www.kaggle.com/datasets/danielshanbalico/dog-emotion/data), containing thousands of annotated images across the following categories:
|
| 35 |
+
- Happy: Open mouth, relaxed eyes.
|
| 36 |
+
- Sad: Lowered head, droopy eyes.
|
| 37 |
+
- Angry: Visible teeth, tensed forehead.
|
| 38 |
+
- Relaxed: Neutral mouth and ears.
|
| 39 |
+
|
| 40 |
+
## π Configuration Note (Keras 3)
|
| 41 |
+
This project was successfully migrated from a legacy environment to Keras 3. To ensure the model loads correctly, the following "Modern Bridge" configuration is used.
|
| 42 |
+
|
| 43 |
+
### Version Missmatch
|
| 44 |
+
At first, the deployment failed with a critical <code style="color: gray;">ValueError: Kernel shape must have the same length as input, but received kernel of shape (3, 3, (None, 7, 7, 2048), 64)</code>
|
| 45 |
+
|
| 46 |
+
**Why this happened:** My model was originally trained in a Keras 2 environment (common in older Colab sessions). When deployed to a modern environment (Hugging Face default), Keras 3 attempted to "rebuild" the model configuration. Because of changes in how shapes are handled between versions, Keras 3 misinterpreted the input metadata, leading to the dimension error as seen above.
|
| 47 |
+
|
| 48 |
+
### The "Modern Bridge"
|
| 49 |
+
To resolve the deployment error, i have done two steps :
|
| 50 |
+
1. Backend Configuration : Adds <code style="color: gray;">os.environ["KERAS_BACKEND"] = "tensorflow"</code>, to ensure Keras 3 uses the correct engine to interpret the saved weight (.keras/.h5) file.
|
| 51 |
+
2. Specify Version : Updates the <code style="color: gray;">requirements.txt</code>, using the <code style="color: gray;">tensorflow==2.18.0 and keras==3.8.0</code>. This combination acts as a 'bridge,' allowing the modern Keras 3 system to correctly translate and load my older model file.
|