Spaces:
Build error
Build error
Upload 16 files
Browse files- .gitignore +20 -0
- app.py +42 -0
- fish-image-classification.ipynb +0 -0
- fish_cnn_model.h5 +3 -0
- fish_mobilenet_model.h5 +3 -0
- fish_vgg16_model.h5 +3 -0
- requirements.txt +4 -0
- test1.png +0 -0
- test2.png +0 -0
- test3.png +0 -0
- test4.png +0 -0
- test5.png +0 -0
- test6.png +0 -0
- test7.png +0 -0
- test8.png +0 -0
- test9.png +0 -0
.gitignore
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Compiled Python files
|
| 2 |
+
*.pyc
|
| 3 |
+
__pycache__/
|
| 4 |
+
|
| 5 |
+
# Virtual environment
|
| 6 |
+
venv/
|
| 7 |
+
ENV/
|
| 8 |
+
|
| 9 |
+
# Jupyter Notebook checkpoints
|
| 10 |
+
.ipynb_checkpoints/
|
| 11 |
+
|
| 12 |
+
# IDE settings
|
| 13 |
+
.vscode/
|
| 14 |
+
.idea/
|
| 15 |
+
|
| 16 |
+
# Python cache files
|
| 17 |
+
*.pyc
|
| 18 |
+
|
| 19 |
+
# Gradio cache files
|
| 20 |
+
.gradio/
|
app.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import numpy as np
|
| 3 |
+
import cv2
|
| 4 |
+
import tensorflow as tf
|
| 5 |
+
|
| 6 |
+
# Load the model
|
| 7 |
+
vgg16_model = tf.keras.models.load_model('fish_vgg16_model.h5')
|
| 8 |
+
mobilenet_model = tf.keras.models.load_model('fish_mobilenet_model.h5')
|
| 9 |
+
custom_cnn_model = tf.keras.models.load_model('fish_cnn_model.h5')
|
| 10 |
+
|
| 11 |
+
# Define the preprocessing function
|
| 12 |
+
def preprocess_image(image):
|
| 13 |
+
image = cv2.resize(image, (224, 224))
|
| 14 |
+
image = image / 255.0
|
| 15 |
+
return image
|
| 16 |
+
|
| 17 |
+
# Define the prediction function
|
| 18 |
+
def predict(image):
|
| 19 |
+
# Preprocess the image
|
| 20 |
+
processed_image = preprocess_image(image)
|
| 21 |
+
|
| 22 |
+
# Make predictions using the models
|
| 23 |
+
vgg_pred = vgg16_model.predict(np.expand_dims(processed_image, axis=0))[0]
|
| 24 |
+
mobilenet_pred = mobilenet_model.predict(np.expand_dims(processed_image, axis=0))[0]
|
| 25 |
+
custom_cnn_pred = custom_cnn_model.predict(np.expand_dims(processed_image, axis=0))[0]
|
| 26 |
+
|
| 27 |
+
# Get the predicted labels
|
| 28 |
+
vgg_label = np.argmax(vgg_pred)
|
| 29 |
+
mobilenet_label = np.argmax(mobilenet_pred)
|
| 30 |
+
custom_cnn_label = np.argmax(custom_cnn_pred)
|
| 31 |
+
|
| 32 |
+
return {
|
| 33 |
+
"VGG16 Prediction": vgg_label,
|
| 34 |
+
"MobileNet Prediction": mobilenet_label,
|
| 35 |
+
"Custom CNN Prediction": custom_cnn_label
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
# Create the Gradio interface
|
| 39 |
+
inputs = gr.inputs.Image()
|
| 40 |
+
outputs = gr.outputs.Label(num_top_classes=3)
|
| 41 |
+
|
| 42 |
+
gr.Interface(fn=predict, inputs=inputs, outputs=outputs).launch()
|
fish-image-classification.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
fish_cnn_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0ead2b2b8e6f943d65c9b408ee435f3fb4a1d587ff65fed9f5b9ec7d2f7b4dd3
|
| 3 |
+
size 116259088
|
fish_mobilenet_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e25eb25c5e5ad3c261c0097f48e08e3fafef7bcd56a6bd4462bb8459d42cdcc
|
| 3 |
+
size 19440064
|
fish_vgg16_model.h5
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9cb8debb8d6a0e49336daac4c85a9df87412024dc57843829dfee9877f186a48
|
| 3 |
+
size 213127872
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==2.3.6
|
| 2 |
+
opencv-python==4.5.3.56
|
| 3 |
+
numpy==1.19.5
|
| 4 |
+
tensorflow==2.6.0
|
test1.png
ADDED
|
test2.png
ADDED
|
test3.png
ADDED
|
test4.png
ADDED
|
test5.png
ADDED
|
test6.png
ADDED
|
test7.png
ADDED
|
test8.png
ADDED
|
test9.png
ADDED
|