Spaces:
Build error
Build error
Upload 3 files
Browse files- app.py +40 -0
- predictor.py +28 -0
- requirements.txt +55 -0
app.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from flask import Flask, render_template, request
|
| 3 |
+
from predictor import check
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
author = 'TEAM DELTA'
|
| 7 |
+
|
| 8 |
+
app = Flask(__name__, static_folder="images")
|
| 9 |
+
|
| 10 |
+
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
@app.route('/')
|
| 14 |
+
@app.route('/index')
|
| 15 |
+
def index():
|
| 16 |
+
return render_template('upload.html')
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
@app.route('/upload', methods=['GET', 'POST'])
|
| 20 |
+
def upload():
|
| 21 |
+
target = os.path.join(APP_ROOT, 'images/')
|
| 22 |
+
print(target)
|
| 23 |
+
|
| 24 |
+
if not os.path.isdir(target):
|
| 25 |
+
os.mkdir(target)
|
| 26 |
+
|
| 27 |
+
for file in request.files.getlist('file'):
|
| 28 |
+
print(file)
|
| 29 |
+
filename = file.filename
|
| 30 |
+
print(filename)
|
| 31 |
+
dest = '/'.join([target, filename])
|
| 32 |
+
print(dest)
|
| 33 |
+
file.save(dest)
|
| 34 |
+
|
| 35 |
+
status = check(filename)
|
| 36 |
+
|
| 37 |
+
return render_template('complete.html', image_name=filename, predvalue=status)
|
| 38 |
+
|
| 39 |
+
if __name__ == "main":
|
| 40 |
+
app.run(port=4555, debug=True)
|
predictor.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
from keras.preprocessing import image
|
| 3 |
+
from tensorflow.keras.models import load_model
|
| 4 |
+
saved_model = load_model("model/VGG_model.h5")
|
| 5 |
+
status = True
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def check(input_img):
|
| 9 |
+
print(" your image is : " + input_img)
|
| 10 |
+
print(input_img)
|
| 11 |
+
|
| 12 |
+
img = image.load_img("images/" + input_img, target_size=(224, 224))
|
| 13 |
+
img = np.asarray(img)
|
| 14 |
+
print(img)
|
| 15 |
+
|
| 16 |
+
img = np.expand_dims(img, axis=0)
|
| 17 |
+
|
| 18 |
+
print(img)
|
| 19 |
+
output = saved_model.predict(img)
|
| 20 |
+
|
| 21 |
+
print(output)
|
| 22 |
+
if output[0][0] == 1:
|
| 23 |
+
status = True
|
| 24 |
+
else:
|
| 25 |
+
status = False
|
| 26 |
+
|
| 27 |
+
print(status)
|
| 28 |
+
return status
|
requirements.txt
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
absl-py==0.12.0
|
| 2 |
+
astor==0.8.1
|
| 3 |
+
astunparse==1.6.3
|
| 4 |
+
cached-property==1.5.2
|
| 5 |
+
cachetools==4.2.1
|
| 6 |
+
certifi==2020.12.5
|
| 7 |
+
chardet==4.0.0
|
| 8 |
+
click==7.1.2
|
| 9 |
+
cycler==0.10.0
|
| 10 |
+
Flask==1.1.2
|
| 11 |
+
flatbuffers==1.12
|
| 12 |
+
gast==0.4.0
|
| 13 |
+
google-auth==1.28.1
|
| 14 |
+
google-auth-oauthlib==0.4.4
|
| 15 |
+
google-pasta==0.2.0
|
| 16 |
+
grpcio==1.37.0
|
| 17 |
+
h5py==2.10.0
|
| 18 |
+
idna==3.1
|
| 19 |
+
importlib-metadata==3.10.0
|
| 20 |
+
itsdangerous==1.1.0
|
| 21 |
+
Jinja2==2.11.3
|
| 22 |
+
Keras==2.4.3
|
| 23 |
+
Keras-Applications==1.0.8
|
| 24 |
+
Keras-Preprocessing==1.1.2
|
| 25 |
+
kiwisolver==1.3.1
|
| 26 |
+
Markdown==3.3.4
|
| 27 |
+
MarkupSafe==1.1.1
|
| 28 |
+
matplotlib==3.4.1
|
| 29 |
+
numpy==1.20.2
|
| 30 |
+
oauthlib==3.1.0
|
| 31 |
+
opt-einsum==3.3.0
|
| 32 |
+
pandas==1.2.3
|
| 33 |
+
Pillow==8.2.0
|
| 34 |
+
protobuf==3.15.8
|
| 35 |
+
pyasn1==0.4.8
|
| 36 |
+
pyasn1-modules==0.2.8
|
| 37 |
+
pyparsing==2.4.7
|
| 38 |
+
python-dateutil==2.8.1
|
| 39 |
+
pytz==2021.1
|
| 40 |
+
PyYAML==5.4.1
|
| 41 |
+
requests==2.25.1
|
| 42 |
+
requests-oauthlib==1.3.0
|
| 43 |
+
rsa==4.7.2
|
| 44 |
+
scipy==1.6.2
|
| 45 |
+
six==1.15.0
|
| 46 |
+
tensorboard==2.4.1
|
| 47 |
+
tensorboard-plugin-wit==1.8.0
|
| 48 |
+
tensorflow==2.4.1
|
| 49 |
+
tensorflow-estimator==2.4.0
|
| 50 |
+
termcolor==1.1.0
|
| 51 |
+
typing-extensions==3.7.4.3
|
| 52 |
+
urllib3==1.26.4
|
| 53 |
+
Werkzeug==1.0.1
|
| 54 |
+
wrapt==1.12.1
|
| 55 |
+
zipp==3.4.1
|