Update app.py
Browse files
app.py
CHANGED
|
@@ -37,16 +37,16 @@ def test_image(object_image):
|
|
| 37 |
# Convert the file to an opencv image.
|
| 38 |
file_bytes = np.asarray(bytearray(object_image.read()), dtype=np.uint8)
|
| 39 |
opencv_image = cv2.imdecode(file_bytes, 1)
|
| 40 |
-
opencv_image = cv2.resize(opencv_image, (
|
| 41 |
-
opencv_image.shape = (1,
|
| 42 |
opencv_image = preprocess_input(opencv_image)
|
| 43 |
predictions = model.predict(opencv_image)
|
| 44 |
|
| 45 |
if predictions[0, 0] >= 0.5:
|
| 46 |
-
result = '
|
| 47 |
confidence = predictions[0, 0] * 100
|
| 48 |
else:
|
| 49 |
-
result = '
|
| 50 |
confidence = 100 - (predictions[0, 0] * 100)
|
| 51 |
|
| 52 |
return result, round(confidence, 2)
|
|
|
|
| 37 |
# Convert the file to an opencv image.
|
| 38 |
file_bytes = np.asarray(bytearray(object_image.read()), dtype=np.uint8)
|
| 39 |
opencv_image = cv2.imdecode(file_bytes, 1)
|
| 40 |
+
opencv_image = cv2.resize(opencv_image, (160, 160))
|
| 41 |
+
opencv_image.shape = (1, 160, 160, 3)
|
| 42 |
opencv_image = preprocess_input(opencv_image)
|
| 43 |
predictions = model.predict(opencv_image)
|
| 44 |
|
| 45 |
if predictions[0, 0] >= 0.5:
|
| 46 |
+
result = 'Pikachu'
|
| 47 |
confidence = predictions[0, 0] * 100
|
| 48 |
else:
|
| 49 |
+
result = 'Raichu'
|
| 50 |
confidence = 100 - (predictions[0, 0] * 100)
|
| 51 |
|
| 52 |
return result, round(confidence, 2)
|