Update app.py
Browse files
app.py
CHANGED
|
@@ -84,28 +84,20 @@ def fig2img(fig):
|
|
| 84 |
return img
|
| 85 |
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
return "
|
| 99 |
-
|
| 100 |
-
return "
|
| 101 |
-
if 15 < avg_h < 35 and avg_s > 80:
|
| 102 |
-
return "Yellow Plate (Commercial)"
|
| 103 |
-
if 80 < avg_h < 130:
|
| 104 |
-
return "Blue Plate (Diplomatic)"
|
| 105 |
-
if 35 < avg_h < 85:
|
| 106 |
-
return "Green Plate (Electric)"
|
| 107 |
-
|
| 108 |
-
return "Unknown Plate"
|
| 109 |
|
| 110 |
|
| 111 |
# ---------------- Visualization ----------------
|
|
@@ -246,8 +238,7 @@ Supports:
|
|
| 246 |
"""
|
| 247 |
|
| 248 |
models = [
|
| 249 |
-
"nickmuchi/yolos-small-finetuned-license-plate-detection"
|
| 250 |
-
"nickmuchi/detr-resnet50-license-plate-detection"
|
| 251 |
]
|
| 252 |
|
| 253 |
css = '''
|
|
|
|
| 84 |
return img
|
| 85 |
|
| 86 |
|
| 87 |
+
def classify_plate_color(plate_img):
|
| 88 |
+
img = np.array(plate_img)
|
| 89 |
+
hsv = cv2.cvtColor(img, cv2.COLOR_RGB2HSV)
|
| 90 |
+
|
| 91 |
+
green = np.sum(cv2.inRange(hsv, (35, 40, 40), (85, 255, 255)))
|
| 92 |
+
yellow = np.sum(cv2.inRange(hsv, (15, 50, 50), (35, 255, 255)))
|
| 93 |
+
white = np.sum(cv2.inRange(hsv, (0, 0, 200), (180, 30, 255)))
|
| 94 |
+
|
| 95 |
+
if green > yellow and green > white:
|
| 96 |
+
return "EV"
|
| 97 |
+
elif yellow > green and yellow > white:
|
| 98 |
+
return "Commercial"
|
| 99 |
+
else:
|
| 100 |
+
return "Personal"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
|
| 103 |
# ---------------- Visualization ----------------
|
|
|
|
| 238 |
"""
|
| 239 |
|
| 240 |
models = [
|
| 241 |
+
"nickmuchi/yolos-small-finetuned-license-plate-detection"
|
|
|
|
| 242 |
]
|
| 243 |
|
| 244 |
css = '''
|