Update app.py
Browse files
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
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
)
|