Spaces:
Running
Running
Add example image.
Browse files- app.py +5 -4
- images/1.jpg +0 -0
app.py
CHANGED
|
@@ -88,8 +88,7 @@ def visualize(image_path, boxes, txts, scores,
|
|
| 88 |
return image_save
|
| 89 |
|
| 90 |
|
| 91 |
-
def inference(
|
| 92 |
-
img_path = img.name
|
| 93 |
img = cv2.imread(img_path)
|
| 94 |
ocr_result, _ = rapid_ocr(img, box_thresh=box_thresh,
|
| 95 |
unclip_ratio=unclip_ratio,
|
|
@@ -105,13 +104,14 @@ title = 'RapidOCR Demo (捷智OCR)'
|
|
| 105 |
description = 'Gradio demo for RapidOCR. Github Repo: https://github.com/RapidAI/RapidOCR'
|
| 106 |
article = "<p style='text-align: center'> Completely open source, free and support offline deployment of multi-platform and multi-language OCR SDK <a href='https://github.com/RapidAI/RapidOCR'>Github Repo</a></p>"
|
| 107 |
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
|
|
|
|
| 108 |
|
| 109 |
rapid_ocr = RapidOCR()
|
| 110 |
|
| 111 |
gr.Interface(
|
| 112 |
inference,
|
| 113 |
inputs=[
|
| 114 |
-
gr.inputs.Image(type='
|
| 115 |
gr.Slider(minimum=0, maximum=1.0, value=0.5,
|
| 116 |
label='box_thresh', step=0.1),
|
| 117 |
gr.Slider(minimum=1.5, maximum=2.0, value=1.6,
|
|
@@ -120,11 +120,12 @@ gr.Interface(
|
|
| 120 |
label='text_score', step=0.1),
|
| 121 |
],
|
| 122 |
outputs=[
|
| 123 |
-
gr.outputs.Image(type='
|
| 124 |
gr.outputs.Textbox(type='text', label='Output_text')
|
| 125 |
],
|
| 126 |
title=title,
|
| 127 |
description=description,
|
|
|
|
| 128 |
article=article,
|
| 129 |
css=css,
|
| 130 |
allow_flagging='never',
|
|
|
|
| 88 |
return image_save
|
| 89 |
|
| 90 |
|
| 91 |
+
def inference(img_path, box_thresh, unclip_ratio, text_score):
|
|
|
|
| 92 |
img = cv2.imread(img_path)
|
| 93 |
ocr_result, _ = rapid_ocr(img, box_thresh=box_thresh,
|
| 94 |
unclip_ratio=unclip_ratio,
|
|
|
|
| 104 |
description = 'Gradio demo for RapidOCR. Github Repo: https://github.com/RapidAI/RapidOCR'
|
| 105 |
article = "<p style='text-align: center'> Completely open source, free and support offline deployment of multi-platform and multi-language OCR SDK <a href='https://github.com/RapidAI/RapidOCR'>Github Repo</a></p>"
|
| 106 |
css = ".output_image, .input_image {height: 40rem !important; width: 100% !important;}"
|
| 107 |
+
examples = [['images/1.jpg']]
|
| 108 |
|
| 109 |
rapid_ocr = RapidOCR()
|
| 110 |
|
| 111 |
gr.Interface(
|
| 112 |
inference,
|
| 113 |
inputs=[
|
| 114 |
+
gr.inputs.Image(type='filepath', label='Input'),
|
| 115 |
gr.Slider(minimum=0, maximum=1.0, value=0.5,
|
| 116 |
label='box_thresh', step=0.1),
|
| 117 |
gr.Slider(minimum=1.5, maximum=2.0, value=1.6,
|
|
|
|
| 120 |
label='text_score', step=0.1),
|
| 121 |
],
|
| 122 |
outputs=[
|
| 123 |
+
gr.outputs.Image(type='filepath', label='Output_image'),
|
| 124 |
gr.outputs.Textbox(type='text', label='Output_text')
|
| 125 |
],
|
| 126 |
title=title,
|
| 127 |
description=description,
|
| 128 |
+
examples=examples,
|
| 129 |
article=article,
|
| 130 |
css=css,
|
| 131 |
allow_flagging='never',
|
images/1.jpg
ADDED
|