-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45e6b64
commit 3996641
Showing
109 changed files
with
37,686 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 dineshssdn-867 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# FutureTEST | ||
# fish_species_detection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from flask import Flask, render_template, request, redirect, flash, url_for, render_template_string | ||
import urllib.request | ||
from werkzeug.utils import secure_filename | ||
from fishdetectionui.main_detect_fish import obj_model_predict | ||
from fishdetectionui.main_classify_fish import getPrediction | ||
import os | ||
import numpy as np | ||
import cv2 | ||
import wikipedia | ||
|
||
fish_species_app = Flask(__name__) | ||
|
||
@fish_species_app.route("/") | ||
@fish_species_app.route("/home") | ||
def home(): | ||
return render_template("index.html") | ||
|
||
|
||
@fish_species_app.route('/predict_fish_form', methods=['GET']) | ||
def predict_fish_form(): | ||
return render_template('case-single.html', predicted=False) | ||
|
||
@fish_species_app.route('/count_fish_form', methods=['GET']) | ||
def count_fish_form(): | ||
return render_template('showcases.html', predicted=False) | ||
|
||
|
||
@fish_species_app.route('/classify_fish', methods=['POST']) | ||
def classify_fish(): | ||
print(request.url) | ||
if request.method == 'POST': | ||
if 'image' not in request.files: | ||
flash('No file part') | ||
return redirect(request.referrer) | ||
file = request.files['image'] | ||
if file: | ||
# convert string of image data to uint8 | ||
nparr = np.fromstring(request.files['image'].read(), np.uint8) | ||
# decode image | ||
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR) | ||
label1, acc1 = getPrediction(img) | ||
flash(label1) | ||
flash(acc1) | ||
summary = wikipedia.summary(label1) | ||
return render_template("blog-single.html", label1=label1, acc1=acc1, summary=summary) | ||
|
||
|
||
@fish_species_app.route('/count_fish', methods=['POST']) | ||
def count_fish(): | ||
print(request.url) | ||
if request.method == 'POST': | ||
if 'image' not in request.files: | ||
flash('No file part') | ||
return redirect(request.referrer) | ||
file = request.files['image'] | ||
if file: | ||
# convert string of image data to uint8 | ||
nparr = np.fromstring(request.files['image'].read(), np.uint8) | ||
# decode image | ||
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR) | ||
cv2.imwrite('fish.jpg', img) | ||
filename, count = obj_model_predict('fish.jpg') | ||
print(filename) | ||
print(count) | ||
return render_template("blog-double.html", filename=filename, count=count) | ||
|
||
|
||
if __name__ == "__main__": | ||
fish_species_app.secret_key = 'super secret key' | ||
fish_species_app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import cv2 | ||
import numpy as np | ||
from tensorflow.keras.preprocessing.image import load_img | ||
from tensorflow.keras.preprocessing.image import img_to_array | ||
from tensorflow.keras.applications.mobilenet_v2 import preprocess_input | ||
from tensorflow.keras.applications import MobileNetV2 | ||
from tensorflow.keras.models import Model | ||
from tensorflow.keras.layers import Input, Dense | ||
from tensorflow.keras.layers import GlobalAveragePooling2D | ||
|
||
fish_classes = ['Polyprion americanus', 'Scomber japonicus', | ||
'Trigloporus lastoviza', 'Dasyatis centroura', | ||
'Tetrapturus belone', 'Anthias anthias', 'Coris julis', | ||
'Solea solea', 'Boops boops', 'Chlorophthalmus agassizi', | ||
'Squalus acanthias', 'Trachinus draco', 'Pseudocaranx dentex', | ||
'Belone belone', 'Gobius niger', 'Mugil cephalus', 'Phycis phycis', | ||
'Atherinomorus lacunosus', 'Rhinobatos cemiculus', | ||
'Epinephelus caninus'] | ||
|
||
|
||
def model_initalize(): | ||
# include_top = False means that we doesnt include fully connected top layer we will add them accordingly | ||
mobilenetV2 = MobileNetV2(include_top = False, input_shape = (224,224,3), weights = 'imagenet') | ||
|
||
# training of all the convolution is set to false | ||
for layer in mobilenetV2.layers: | ||
layer.trainable = False | ||
|
||
x = GlobalAveragePooling2D()(mobilenetV2.output) | ||
predictions = Dense(20, activation='softmax')(x) | ||
model_mobilenetV2 = Model(inputs = mobilenetV2.input, outputs = predictions) | ||
model_mobilenetV2.load_weights('model_mobilenetV2.h5') | ||
return model_mobilenetV2 | ||
|
||
model = model_initalize() | ||
|
||
def getPrediction(image): | ||
image = img_to_array(image) | ||
image = cv2.resize(image, (224,224)) | ||
image = image.reshape((1, image.shape[0], image.shape[1], image.shape[2])) | ||
image = preprocess_input(image) | ||
probs = model.predict(image) | ||
yhat = np.argmax(probs) | ||
return str(fish_classes[yhat]), str(probs[0][yhat]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from roboflow import Roboflow | ||
import string | ||
import random | ||
import json | ||
import os | ||
import shutil | ||
|
||
rf = Roboflow(api_key="K57tUktyTD0l9DKKeQBE") | ||
workspace_ = rf.workspace() | ||
project = workspace_.project("detect-for-me") | ||
version = project.version(1) | ||
model = version.model | ||
|
||
def obj_model_predict(image): | ||
prediction = model.predict(image) | ||
res = 'predictions_' + ''.join(random.choices(string.ascii_uppercase + | ||
string.digits, k=7)) + '.jpg' | ||
prediction.save(output_path=res) | ||
shutil.move('/workspace/fish_species_detection/'+res, "/workspace/fish_species_detection/static/predictions/"+res) | ||
count = len(prediction.json()['predictions']) | ||
return "/static/predictions/"+res, str(count) | ||
|
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
absl-py==1.2.0 | ||
astunparse==1.6.3 | ||
beautifulsoup4==4.11.1 | ||
cachetools==5.2.0 | ||
certifi==2021.5.30 | ||
chardet==4.0.0 | ||
charset-normalizer==2.1.0 | ||
click==8.1.3 | ||
cycler==0.10.0 | ||
Flask==2.1.3 | ||
flatbuffers==1.12 | ||
fonttools==4.34.4 | ||
gast==0.4.0 | ||
glob2==0.7 | ||
google-auth==2.9.1 | ||
google-auth-oauthlib==0.4.6 | ||
google-pasta==0.2.0 | ||
grpcio==1.47.0 | ||
h5py==3.7.0 | ||
idna==2.10 | ||
importlib-metadata==4.12.0 | ||
itsdangerous==2.1.2 | ||
Jinja2==3.1.2 | ||
keras==2.9.0 | ||
Keras-Preprocessing==1.1.2 | ||
kiwisolver==1.3.1 | ||
libclang==14.0.1 | ||
Markdown==3.4.1 | ||
MarkupSafe==2.1.1 | ||
matplotlib==3.5.2 | ||
numpy==1.23.1 | ||
oauthlib==3.2.0 | ||
opencv-python-headless==4.2.0.32 | ||
opt-einsum==3.3.0 | ||
packaging==21.3 | ||
Pillow==9.0.1 | ||
protobuf==3.19.4 | ||
pyasn1==0.4.8 | ||
pyasn1-modules==0.2.8 | ||
pyparsing==2.4.7 | ||
python-dateutil==2.8.2 | ||
python-dotenv==0.20.0 | ||
PyYAML==6.0 | ||
requests==2.28.1 | ||
requests-oauthlib==1.3.1 | ||
requests-toolbelt==0.9.1 | ||
roboflow==0.2.11 | ||
rsa==4.9 | ||
six==1.16.0 | ||
soupsieve==2.3.2.post1 | ||
tensorboard==2.9.1 | ||
tensorboard-data-server==0.6.1 | ||
tensorboard-plugin-wit==1.8.1 | ||
tensorflow==2.9.1 | ||
tensorflow-estimator==2.9.0 | ||
tensorflow-io-gcs-filesystem==0.26.0 | ||
termcolor==1.1.0 | ||
tqdm==4.64.0 | ||
typing_extensions==4.3.0 | ||
urllib3==1.26.6 | ||
Werkzeug==2.1.2 | ||
wget==3.2 | ||
wikipedia==1.4.0 | ||
wrapt==1.14.1 | ||
zipp==3.8.1 |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.