Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ def load_image_with_cv2(image_path):
|
|
| 12 |
img = cv2.resize(img, (224, 224))
|
| 13 |
img_array = img.astype(np.float32) / 255.0
|
| 14 |
img_array = np.expand_dims(img_array, axis=0)
|
|
|
|
| 15 |
return img_array
|
| 16 |
|
| 17 |
def classify_image(input_image):
|
|
@@ -26,14 +27,13 @@ def classify_image(input_image):
|
|
| 26 |
classes = ['Ajloun Castle', 'Jerash', 'Jerash', 'Petra', 'Roman amphitheater', 'Roman amphitheater', 'Wadi Rum']
|
| 27 |
predicted_class = classes[predicted_class_index]
|
| 28 |
confidence = max(outputs[0][0])
|
|
|
|
| 29 |
return predicted_class, confidence
|
| 30 |
|
| 31 |
def show_preds_image(image_path):
|
| 32 |
mux_value = str(classify_image(image_path))
|
| 33 |
-
print(mux_value)
|
| 34 |
img = cv2.imread(image_path)
|
| 35 |
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 36 |
-
|
| 37 |
height, width, _ = img.shape
|
| 38 |
text_x = int((width - len(mux_value) * 10) / 2)
|
| 39 |
text_y = int(height / 2)
|
|
|
|
| 12 |
img = cv2.resize(img, (224, 224))
|
| 13 |
img_array = img.astype(np.float32) / 255.0
|
| 14 |
img_array = np.expand_dims(img_array, axis=0)
|
| 15 |
+
|
| 16 |
return img_array
|
| 17 |
|
| 18 |
def classify_image(input_image):
|
|
|
|
| 27 |
classes = ['Ajloun Castle', 'Jerash', 'Jerash', 'Petra', 'Roman amphitheater', 'Roman amphitheater', 'Wadi Rum']
|
| 28 |
predicted_class = classes[predicted_class_index]
|
| 29 |
confidence = max(outputs[0][0])
|
| 30 |
+
|
| 31 |
return predicted_class, confidence
|
| 32 |
|
| 33 |
def show_preds_image(image_path):
|
| 34 |
mux_value = str(classify_image(image_path))
|
|
|
|
| 35 |
img = cv2.imread(image_path)
|
| 36 |
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
|
|
|
| 37 |
height, width, _ = img.shape
|
| 38 |
text_x = int((width - len(mux_value) * 10) / 2)
|
| 39 |
text_y = int(height / 2)
|