Spaces:
Runtime error
Runtime error
Upload 6 files
Browse files
Cats_vs_Dogs.model/fingerprint.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:134787d145d753dacf4ca852746b711e7f442c2a8956ba84dd83de85e14a2f60
|
3 |
+
size 56
|
Cats_vs_Dogs.model/keras_metadata.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a5a9283a185b338044e3dcdb2313de9bef6b609d8be8578a8a7576a5b6fb9bd9
|
3 |
+
size 23939
|
Cats_vs_Dogs.model/saved_model.pb
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:184a97c4d95983961884d94fd34261bc41c5dc331e96dd9f1e7a37080a4b423f
|
3 |
+
size 201981
|
Cats_vs_Dogs.model/variables/variables.data-00000-of-00001
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7a54e9eeeb79d4e0830e2f69be5ed40f1f35246204febefaddde6f449e6fcbfc
|
3 |
+
size 2237712
|
Cats_vs_Dogs.model/variables/variables.index
ADDED
Binary file (3 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, render_template, jsonify
|
2 |
+
from flask_cors import CORS
|
3 |
+
import keras
|
4 |
+
import numpy as np
|
5 |
+
from keras.preprocessing import image
|
6 |
+
import io
|
7 |
+
|
8 |
+
app = Flask(__name__)
|
9 |
+
CORS(app)
|
10 |
+
|
11 |
+
model = keras.models.load_model('Cats_vs_Dogs.model')
|
12 |
+
|
13 |
+
@app.route('/')
|
14 |
+
def index():
|
15 |
+
return render_template('index.html', prediction=None)
|
16 |
+
|
17 |
+
@app.route('/predict', methods=['POST'])
|
18 |
+
def predict():
|
19 |
+
imagefile = request.files['imagefile']
|
20 |
+
|
21 |
+
# Read the image file into memory
|
22 |
+
img_stream = imagefile.read()
|
23 |
+
|
24 |
+
# Convert the image to grayscale and resize
|
25 |
+
img = image.load_img(io.BytesIO(img_stream), color_mode='grayscale', target_size=(60, 60))
|
26 |
+
img_array = image.img_to_array(img)
|
27 |
+
img_array = np.expand_dims(img_array, axis=0)
|
28 |
+
img_array /= 255.0
|
29 |
+
|
30 |
+
prediction = model.predict(img_array)
|
31 |
+
predicted_class = "Dog" if prediction[0][1] > prediction[0][0] else "Cat"
|
32 |
+
|
33 |
+
return jsonify({'prediction': predicted_class})
|
34 |
+
|
35 |
+
if __name__ == '__main__':
|
36 |
+
app.run(debug=True)
|