EnYa32/LargeScaleFishClassification
π 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:
- A CNN without transfer learning
- A CNN with transfer learning (e.g., ResNet50)
- A Streamlit app for each model
- 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:
accuracytop-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.loadmodel("bestfish_cnn.keras")
Predict on a new image import numpy as np from tensorflow.keras.preprocessing import image
img = image.loadimg("yourimage.jpg", targetsize=(224, 224)) imgarray = np.expanddims(image.imgto_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 bestfishcnn.keras Saved CNN model (from scratch, no transfer learning) streamlitapp.py Streamlit app code requirements.txt Required Python packages FishCNNReport_English.pdf Technical report (simple English)
π€ Author
Enes Yamac
Machine Learning & Computer Vision Project (2025)
