|
Download README.md from EnYa32/LargeFishClassifcationResNet50: direct link, hf CLI and curl.
- Browser
- Download file 2.81 kB
-
https://huggingface.co/spaces/EnYa32/LargeFishClassifcationResNet50/resolve/main/README.md
- Command line
-
hf download hf://spaces/EnYa32/LargeFishClassifcationResNet50/README.md
-
curl -L -o README.md https://huggingface.co/spaces/EnYa32/LargeFishClassifcationResNet50/resolve/main/README.md
2.81 kB
| title: FishClassifier_CNN_ResNet50 | |
| emoji: π | |
| colorFrom: blue | |
| colorTo: green | |
| sdk: streamlit | |
| app_file: src/streamlit_app.py | |
| pinned: false | |
| short_description: CNN with ResNet50 for 9-class fish classification. | |
| license: mit | |
| # π Fish Species Classification β ResNet50 Transfer Learning | |
| This project uses **Transfer Learning with ResNet50** to classify images of 9 different fish species. | |
| The model was trained using the **A Large Scale Fish Dataset** from Kaggle. | |
| The goal of this project is to build a strong image classifier as part of my Deep Learning assignments. | |
| I also built a CNN model without transfer learning for comparison. | |
| --- | |
| ## π¦ Dataset | |
| The dataset contains 9 fish classes: | |
| - Black Sea Sprat | |
| - Gilt-Head Bream | |
| - Horse Mackerel | |
| - Red Mullet | |
| - Red Sea Bream | |
| - Sea Bass | |
| - Shrimp | |
| - Striped Red Mullet | |
| - Trout | |
| The dataset is balanced and includes several thousand images. | |
| Source: https://www.kaggle.com/datasets/crowww/a-large-scale-fish-dataset | |
| --- | |
| ## π§ Model Overview (ResNet50) | |
| This project uses **ResNet50 with ImageNet weights** as a feature extractor. | |
| ### Model pipeline: | |
| 1. Load ResNet50 without top layers (`include_top=False`) | |
| 2. Freeze all base layers | |
| 3. Add custom layers: | |
| - GlobalAveragePooling2D | |
| - Dense(256, activation='relu') | |
| - Dropout(0.5) | |
| - Dense(9, activation='softmax') | |
| ### Training Settings | |
| - Loss: `sparse_categorical_crossentropy` | |
| - Optimizer: Adam (learning rate reduced automatically) | |
| - Metrics: | |
| - Accuracy | |
| - Top-3 Accuracy | |
| - Callbacks: | |
| - EarlyStopping | |
| - ReduceLROnPlateau | |
| - ModelCheckpoint (saves the best model) | |
| --- | |
| ## π Model Performance | |
| Results on validation data: | |
| - **Validation Accuracy:** ~98.5% | |
| - **Top-3 Accuracy:** 100% | |
| - **Validation Loss:** ~0.05 | |
| The ResNet50 model performs extremely well and clearly outperforms the CNN built from scratch. | |
| --- | |
| ## π How to Use the Model | |
| ### Load model: | |
| ```python | |
| import tensorflow as tf | |
| model = tf.keras.models.load_model("best_fish_resnet50.keras") | |
| Predict: | |
| python | |
| import numpy as np | |
| from tensorflow.keras.preprocessing import image | |
| img = image.load_img("your_image.jpg", target_size=(224, 224)) | |
| img_array = np.expand_dims(image.img_to_array(img), axis=0) | |
| pred = model.predict(img_array) | |
| print(pred) | |
| π Streamlit App | |
| This HuggingFace Space includes an interactive Streamlit app where you can: | |
| Upload a fish image | |
| See the model prediction | |
| View confidence scores for all 9 classes | |
| π Project Files | |
| File Description | |
| best_fish_resnet50.keras Saved ResNet50 model | |
| streamlit_app.py Streamlit app code | |
| requirements.txt Required Python packages | |
| ResNet50_Fish_Report.pdf Technical report | |
| fish_resnet50_history.pkl Training history | |
| ## π€ Author | |
| **Enes Yamac** | |
| Machine Learning & Computer Vision Project (2025) |