Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
def inference(filepath):
|
| 5 |
+
return os.popen(f'djpeg {filepath} | gocr -').read().strip()
|
| 6 |
+
|
| 7 |
+
title = "GOCR"
|
| 8 |
+
description = "Gradio demo for GOCR. GOCR is an OCR (Optical Character Recognition) program, developed under the GNU Public License. It converts scanned images of text back to text files."
|
| 9 |
+
article = "<p style='text-align: center'><a href='http://jocr.sourceforge.net/' target='_blank'>GOCR</a></p>"
|
| 10 |
+
gr.Interface(
|
| 11 |
+
inference,
|
| 12 |
+
[gr.inputs.Image(type="filepath", label="Input")],
|
| 13 |
+
'text',
|
| 14 |
+
title=title,
|
| 15 |
+
description=description,
|
| 16 |
+
article=article,
|
| 17 |
+
examples=['handwrt1.jpg']
|
| 18 |
+
).launch(enable_queue=True,cache_examples=True)
|