Cainvas
Model Files
Fish_breed_classification.h5
keras
Model
deepSea Compiled Models
Fish_breed_classification.exe
deepSea
Ubuntu

FISH BREED CLASSIFICATION

Credit: AITS Cainvas Community

Photo by July PJuxa (Puchkova) on Dribbble

IMPORT LIBRARY AND DATA

In [1]:
!pip install wget
import numpy as np 
import pandas as pd
import os
import matplotlib.pyplot as plt
import seaborn as sns
import cv2
from sklearn.model_selection import StratifiedShuffleSplit,train_test_split
import glob
import tensorflow as tf
from sklearn import metrics
from tensorflow import keras
!wget -N 'https://cainvas-static.s3.amazonaws.com/media/user_data/cainvas-admin/fish.tar.gz'
import tarfile
file = tarfile.open('fish.tar.gz')
file.extractall('./')
file.close()
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: wget in ./.local/lib/python3.7/site-packages (3.2)
WARNING: You are using pip version 20.3.1; however, version 21.1.3 is available.
You should consider upgrading via the '/opt/tljh/user/bin/python -m pip install --upgrade pip' command.
--2021-07-13 10:18:37--  https://cainvas-static.s3.amazonaws.com/media/user_data/cainvas-admin/fish.tar.gz
Resolving cainvas-static.s3.amazonaws.com (cainvas-static.s3.amazonaws.com)... 52.219.66.88
Connecting to cainvas-static.s3.amazonaws.com (cainvas-static.s3.amazonaws.com)|52.219.66.88|:443... connected.
HTTP request sent, awaiting response... 304 Not Modified
File ‘fish.tar.gz’ not modified on server. Omitting download.

BASIC ANALYSIS

In [2]:
data = pd.read_csv('fish/data.csv')
display(data)
sns.set_style('darkgrid')
sns.countplot(data = data,y = 'label')
path label
0 fish/Black Sea Sprat/00033.png Black Sea Sprat
1 fish/Black Sea Sprat/00004.png Black Sea Sprat
2 fish/Black Sea Sprat/00023.png Black Sea Sprat
3 fish/Black Sea Sprat/00041.png Black Sea Sprat
4 fish/Black Sea Sprat/00024.png Black Sea Sprat
... ... ...
425 fish/Gilt Head Bream/14.JPG Gilt Head Bream
426 fish/Gilt Head Bream/18.JPG Gilt Head Bream
427 fish/Gilt Head Bream/49.JPG Gilt Head Bream
428 fish/Gilt Head Bream/2.JPG Gilt Head Bream
429 fish/Gilt Head Bream/25.JPG Gilt Head Bream

430 rows × 2 columns

Out[2]:
<AxesSubplot:xlabel='count', ylabel='label'>
In [3]:
def get_img(index):
    img = plt.imread(data.iloc[index]['path'])
    return img
demo = pd.DataFrame(data.groupby('label').first()).reset_index()
fig,ax = plt.subplots(3,3,figsize=(15,15))
for i in range(3):
    for j in range(3):
        ax[i][j].imshow(plt.imread(demo.iloc[i*3+j].path))
        ax[i][j].tick_params(left = False, bottom = False)
        ax[i][j].set_xticks([])
        ax[i][j].set_yticks([])
        ax[i][j].set_title(demo.iloc[i*3+j].label)
display(demo)
fig.savefig('Sample.png')
label path
0 Black Sea Sprat fish/Black Sea Sprat/00033.png
1 Gilt Head Bream fish/Gilt Head Bream/45.JPG
2 Horse Mackerel fish/Horse Mackerel/00033.png
3 Red Mullet fish/Red Mullet/00033.png
4 Red Sea Bream fish/Red Sea Bream/SAM_5577.JPG
5 Sea Bass fish/Sea Bass/45.JPG
6 Shrimp fish/Shrimp/00033.png
7 Striped Red Mullet fish/Striped Red Mullet/00033.png
8 Trout fish/Trout/00004.png