Sarvamangalak commited on
Commit
d783b9a
·
verified ·
1 Parent(s): 906908a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -24
app.py CHANGED
@@ -84,28 +84,20 @@ def fig2img(fig):
84
  return img
85
 
86
 
87
- # ---------------- Plate Color Classification ----------------
88
-
89
- def classify_plate_color(crop_img):
90
- img = cv2.cvtColor(np.array(crop_img), cv2.COLOR_RGB2BGR)
91
- hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
92
- h, s, v = cv2.split(hsv)
93
-
94
- avg_h, avg_s, avg_v = np.mean(h), np.mean(s), np.mean(v)
95
-
96
- # Heuristic thresholds (India-style)
97
- if avg_v < 80:
98
- return "Black Plate (Commercial)"
99
- if avg_s < 40 and avg_v > 180:
100
- return "White Plate (Private)"
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 = '''