shamimjony1000 commited on
Commit
c7141a5
·
1 Parent(s): a80b4b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -23,6 +23,9 @@ def detect_objects_on_image(image_path):
23
  "NP": "Number Plate"
24
  }
25
 
 
 
 
26
  for box in result.boxes:
27
  x1, y1, x2, y2 = [round(x) for x in box.xyxy[0].tolist()]
28
  class_id = box.cls[0].item()
@@ -30,6 +33,12 @@ def detect_objects_on_image(image_path):
30
 
31
  class_name = class_names_mapping.get(result.names[class_id], result.names[class_id])
32
 
 
 
 
 
 
 
33
  output.append([
34
  x1, y1, x2, y2, class_name, prob
35
  ])
@@ -48,6 +57,7 @@ def detect_objects_on_image(image_path):
48
  return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
49
 
50
 
 
51
  inputs_image = [
52
  gr.components.Image(type="filepath", label="Input Image"),
53
  ]
 
23
  "NP": "Number Plate"
24
  }
25
 
26
+ # Add some space around the text
27
+ text_padding = 5
28
+
29
  for box in result.boxes:
30
  x1, y1, x2, y2 = [round(x) for x in box.xyxy[0].tolist()]
31
  class_id = box.cls[0].item()
 
33
 
34
  class_name = class_names_mapping.get(result.names[class_id], result.names[class_id])
35
 
36
+ # Adjust the rectangle coordinates to add space around the text
37
+ x1 -= text_padding
38
+ y1 -= text_padding
39
+ x2 += text_padding
40
+ y2 += text_padding
41
+
42
  output.append([
43
  x1, y1, x2, y2, class_name, prob
44
  ])
 
57
  return cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
58
 
59
 
60
+
61
  inputs_image = [
62
  gr.components.Image(type="filepath", label="Input Image"),
63
  ]