Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import numpy as np
|
|
8 |
from scipy import ndimage
|
9 |
from PIL import Image
|
10 |
import matplotlib.pyplot as plt
|
|
|
11 |
model = load_model('Densenet.h5')
|
12 |
model.load_weights("pretrained_model.h5")
|
13 |
layer_name = 'conv5_block16_concat'
|
@@ -63,11 +64,14 @@ def classify_image(img):
|
|
63 |
mean = np.mean(img_array, axis=(0, 1))
|
64 |
std = np.std(img_array, axis=(0, 1))
|
65 |
img_array = (img_array - mean) / std
|
66 |
-
zoom_factor = 1.2
|
|
|
|
|
|
|
|
|
67 |
|
68 |
-
img_array = np.expand_dims(
|
69 |
img_array = preprocess_input(img_array)
|
70 |
-
img_array = ndimage.zoom(img_array, zoom_factor, order=1)
|
71 |
|
72 |
|
73 |
predictions1 = model.predict(img_array)
|
|
|
8 |
from scipy import ndimage
|
9 |
from PIL import Image
|
10 |
import matplotlib.pyplot as plt
|
11 |
+
import cv2
|
12 |
model = load_model('Densenet.h5')
|
13 |
model.load_weights("pretrained_model.h5")
|
14 |
layer_name = 'conv5_block16_concat'
|
|
|
64 |
mean = np.mean(img_array, axis=(0, 1))
|
65 |
std = np.std(img_array, axis=(0, 1))
|
66 |
img_array = (img_array - mean) / std
|
67 |
+
zoom_factor = 1.2
|
68 |
+
zoomed_img = cv2.resize(img_array, (0, 0), fx=zoom_factor, fy=zoom_factor)
|
69 |
+
|
70 |
+
# Crop the zoomed image to maintain the original size
|
71 |
+
zoomed_img = zoomed_img[:224, :224, :]# 20% zoom
|
72 |
|
73 |
+
img_array = np.expand_dims(zoomed_img, axis=0)
|
74 |
img_array = preprocess_input(img_array)
|
|
|
75 |
|
76 |
|
77 |
predictions1 = model.predict(img_array)
|