CoolFace
Apppublic

EnYa32/LargeScaleFishClassification

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes
App README

🐟 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. 1.A CNN without transfer learning
  2. 2.A CNN with transfer learning (e.g., ResNet50)
  3. 3.A Streamlit app for each model
  4. 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.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)