Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,15 +87,26 @@ def classify_image(input_image,model_selection):
|
|
| 87 |
|
| 88 |
def show_preds_image(image_path,model_selection):
|
| 89 |
mux_value = str(classify_image(image_path,model_selection)[0])
|
| 90 |
-
img = cv2.imread(image_path)
|
| 91 |
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 92 |
img = cv2.resize(img, (224, 224))
|
| 93 |
height, width, _ = img.shape
|
| 94 |
text_x = int((width - len(mux_value) * 10) / 2)
|
| 95 |
text_y = int(height / 2)
|
| 96 |
font_scale = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
cv2.putText(img, mux_value, (text_x, text_y), cv2.FONT_HERSHEY_SIMPLEX, font_scale, (255, 0, 0), 2, cv2.LINE_AA)
|
| 98 |
|
|
|
|
| 99 |
conf = (classify_image(image_path,model_selection))
|
| 100 |
informations = information(mux_value)
|
| 101 |
|
|
|
|
| 87 |
|
| 88 |
def show_preds_image(image_path,model_selection):
|
| 89 |
mux_value = str(classify_image(image_path,model_selection)[0])
|
| 90 |
+
"""img = cv2.imread(image_path)
|
| 91 |
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 92 |
img = cv2.resize(img, (224, 224))
|
| 93 |
height, width, _ = img.shape
|
| 94 |
text_x = int((width - len(mux_value) * 10) / 2)
|
| 95 |
text_y = int(height / 2)
|
| 96 |
font_scale = 2
|
| 97 |
+
cv2.putText(img, mux_value, (text_x, text_y), cv2.FONT_HERSHEY_SIMPLEX, font_scale, (255, 0, 0), 2, cv2.LINE_AA)"""
|
| 98 |
+
mg = cv2.imread(image_path)
|
| 99 |
+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
|
| 100 |
+
img = cv2.resize(img, (224, 224))
|
| 101 |
+
height, width, _ = img.shape
|
| 102 |
+
font_scale = width // len(mux_value)
|
| 103 |
+
font_scale = max(min(font_scale, 5), 1)
|
| 104 |
+
text_size = cv2.getTextSize(mux_value, cv2.FONT_HERSHEY_SIMPLEX, fontScale=font_scale, thickness=2)[0]
|
| 105 |
+
text_x = int((width - text_size[0]) / 2)
|
| 106 |
+
text_y = int((height + text_size[1]) / 2)
|
| 107 |
cv2.putText(img, mux_value, (text_x, text_y), cv2.FONT_HERSHEY_SIMPLEX, font_scale, (255, 0, 0), 2, cv2.LINE_AA)
|
| 108 |
|
| 109 |
+
|
| 110 |
conf = (classify_image(image_path,model_selection))
|
| 111 |
informations = information(mux_value)
|
| 112 |
|