Spaces:
Build error

tsaddev commited on
Commit
3772e56
·
verified ·
1 Parent(s): 30f252b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -43
app.py CHANGED
@@ -1,7 +1,5 @@
1
  import gradio as gr
2
  import model1 as m1
3
- import model2 as m2
4
-
5
  cars = []
6
  lps = []
7
  lp_texts = []
@@ -14,13 +12,6 @@ def model1(image):
14
  counter = 0
15
  return cars[0], lps[0], lp_texts[0]
16
 
17
- # this is the main function that passes the images to the model 1
18
- def model2(image):
19
- global lps, lp_texts, counter
20
- (lps, lp_texts) = m2.run([image])
21
- counter = 0
22
- return lps[0], lp_texts[0]
23
-
24
  # function to go to next detected car licence plate
25
  def next_img():
26
  global counter
@@ -35,21 +26,6 @@ def prev_img():
35
  index = int(counter % len(cars))
36
  return cars[index], lps[index], lp_texts[index]
37
 
38
-
39
- # function to go to next detected licence plate
40
- def next_img_lp():
41
- global counter
42
- counter += 1
43
- index = int(counter % len(lps))
44
- return lps[index], lp_texts[index]
45
-
46
- # function to go to prev detected licence plate
47
- def prev_img_lp():
48
- global counter
49
- counter -= 1
50
- index = int(counter % len(lps))
51
- return lps[index], lp_texts[index]
52
-
53
  # this code is responcible for the front end part of the page
54
  with gr.Blocks() as demo:
55
  gr.Markdown("## ANPR Project")
@@ -71,24 +47,5 @@ with gr.Blocks() as demo:
71
  submit.click(model1, inputs=[img], outputs=[car, lp, lp_text])
72
  next.click(next_img, outputs=[car, lp, lp_text])
73
  prev.click(prev_img, outputs=[car, lp, lp_text])
74
-
75
- with gr.Tab("Model 2"):
76
- gr.Markdown("Using 2 different ML models")
77
- gr.Markdown("YOLOv8m for car dection + easy ocr for text detection")
78
- gr.Markdown("YOLOv8m for car dection is trained on a large dataset of 25K training images")
79
- img2 = gr.Image(label="Input")
80
- submit2 = gr.Button(value="submit")
81
-
82
- with gr.Row():
83
- lp2 = gr.Image(label="Licence Plate")
84
- lp_text2 = gr.Text(label="Plate Number")
85
-
86
- with gr.Row():
87
- next2 = gr.Button(value="next")
88
- prev2 = gr.Button(value="prev")
89
-
90
- submit2.click(model2, inputs=[img2], outputs=[lp2, lp_text2])
91
- next2.click(next_img_lp, outputs=[lp2, lp_text2])
92
- prev2.click(prev_img_lp, outputs=[lp2, lp_text2])
93
 
94
  demo.launch(share=False)
 
1
  import gradio as gr
2
  import model1 as m1
 
 
3
  cars = []
4
  lps = []
5
  lp_texts = []
 
12
  counter = 0
13
  return cars[0], lps[0], lp_texts[0]
14
 
 
 
 
 
 
 
 
15
  # function to go to next detected car licence plate
16
  def next_img():
17
  global counter
 
26
  index = int(counter % len(cars))
27
  return cars[index], lps[index], lp_texts[index]
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  # this code is responcible for the front end part of the page
30
  with gr.Blocks() as demo:
31
  gr.Markdown("## ANPR Project")
 
47
  submit.click(model1, inputs=[img], outputs=[car, lp, lp_text])
48
  next.click(next_img, outputs=[car, lp, lp_text])
49
  prev.click(prev_img, outputs=[car, lp, lp_text])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  demo.launch(share=False)