Spaces:
Sleeping
Sleeping
File size: 2,992 Bytes
0287c29 1ca5362 0287c29 fe65e01 0287c29 1ca5362 0287c29 1ca5362 0287c29 1ca5362 0224f0d 0c6ac88 0224f0d 0c6ac88 c27bdc0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | ---
title: FishClassifier_CNN
emoji: π
colorFrom: blue
colorTo: green
sdk: streamlit
app_file: src/streamlit_app.py
pinned: false
short_description: CNN from scratch for 9-class fish classification.
license: mit
---
# π Fish Classification (CNN From Scratch)
This project builds a **Convolutional Neural Network (CNN) from scratch** to classify images from the **"A Large Scale Fish Dataset"**, containing 9 different fish species.
This model is part of a larger deep learning assignment where the goal is to build:
1. A CNN **without transfer learning**
2. A CNN **with transfer learning** (e.g., ResNet50)
3. A Streamlit app for each model
4. A technical PDF report for each dataset
---
## π Dataset
**A Large Scale Fish Dataset**
Kaggle link: https://www.kaggle.com/datasets/crowww/a-large-scale-fish-dataset
Dataset structure (after download):
Fish_Dataset/
βββ Black Sea Sprat
βββ Gilt-Head Bream
βββ Horse Mackerel
βββ Red Mullet
βββ Red Sea Bream
βββ Sea Bass
βββ Shrimp
βββ Striped Red Mullet
βββ Trout
yaml
Code kopieren
---
## π§ Model Overview
The CNN was built using Keras Sequential API with:
- **5 Convolutional Layers**
- **3 MaxPooling Layers**
- **1 Dense Layer (256 units)**
- **Dropout (0.5)**
- **Softmax output layer (9 classes)**
**Training Setup:**
- Loss: `sparse_categorical_crossentropy`
- Optimizer: `Adam(lr=0.0005)`
- Metrics:
- `accuracy`
- `top-3 accuracy`
- Callbacks:
- EarlyStopping
- ModelCheckpoint (`best_fish_cnn.keras`)
- ReduceLROnPlateau
---
## π Results
Final model performance on validation data:
- **Accuracy:** ~84%
- **Top-3 Accuracy:** ~99%
- **Validation Loss:** ~0.45
The model performed very well on distinct species (Shrimp, Red Mullet, Trout).
Classes that look visually similar (Sea Bass, Bream types) caused some confusion.
The technical report (PDF) contains:
- Classification Report
- Confusion Matrix
- Full explanation of methods & reflection
---
## π Usage
### How to Use the Model (CNN From Scratch)
__Load the model__
import tensorflow as tf
model = tf.keras.models.load_model("best_fish_cnn.keras")
_Predict on a new image_
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) / 255.0 # normalize
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βs prediction
View confidence scores for all 9 fish classes
__Project Files__
File Description
best_fish_cnn.keras Saved CNN model (from scratch, no transfer learning)
streamlit_app.py Streamlit app code
requirements.txt Required Python packages
Fish_CNN_Report_English.pdf Technical report (simple English)
## π€ Author
**Enes Yamac**
Machine Learning & Computer Vision Project (2025) |