Dirner commited on
Commit
cd1ae25
·
verified ·
1 Parent(s): 01a3bf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -13
app.py CHANGED
@@ -34,21 +34,27 @@ def normalize_vin(text):
34
 
35
  def recognize_vin(image):
36
  ocr = get_reader()
37
-
38
  results = ocr.readtext(image, detail=0)
39
 
40
  raw_text = " ".join(results)
41
-
42
  vin = normalize_vin(raw_text)
43
 
44
- return f"VIN: {vin}\n\nRAW TEXT:\n{raw_text}"
45
-
46
-
47
- demo = gr.Interface(
48
- fn=recognize_vin,
49
- inputs=gr.Image(type="numpy"),
50
- outputs=gr.Textbox(),
51
- title="VIN OCR"
52
- )
53
-
54
- demo.launch(share=True)
 
 
 
 
 
 
 
 
 
34
 
35
  def recognize_vin(image):
36
  ocr = get_reader()
 
37
  results = ocr.readtext(image, detail=0)
38
 
39
  raw_text = " ".join(results)
 
40
  vin = normalize_vin(raw_text)
41
 
42
+ return "VIN: " + vin + "\n\nRAW TEXT:\n" + raw_text
43
+
44
+
45
+ with gr.Blocks() as demo:
46
+ gr.Markdown("# VIN OCR")
47
+ image_input = gr.Image(type="numpy", label="Upload VIN image")
48
+ output_text = gr.Textbox(label="Result", lines=8)
49
+ button = gr.Button("Recognize VIN")
50
+ button.click(
51
+ fn=recognize_vin,
52
+ inputs=image_input,
53
+ outputs=output_text,
54
+ api_name=False
55
+ )
56
+
57
+ demo.launch(
58
+ server_name="0.0.0.0",
59
+ server_port=7860
60
+ )