Spaces:
Runtime error
Runtime error
sberbank-ai
commited on
Commit
·
4bb3965
1
Parent(s):
e44462b
refactor: Minor refactor
Browse files
app.py
CHANGED
@@ -40,19 +40,19 @@ def predict(image_path):
|
|
40 |
image = cv2.imread(image_path)
|
41 |
rotated_image, pred_data = PREDICTOR(image)
|
42 |
structured_text = get_structured_text(pred_data, ['shrinked_text'])
|
43 |
-
|
44 |
result_text = [' '.join(line_text) for page_text in structured_text
|
45 |
for line_text in page_text]
|
46 |
return '\n'.join(result_text)
|
47 |
|
48 |
|
49 |
-
|
|
|
50 |
|
51 |
-
PREDICTOR = PipelinePredictor(pipeline_config_path=PIPELINE_CONFIG_PATH)
|
52 |
|
53 |
-
gr.Interface(
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
).launch()
|
|
|
40 |
image = cv2.imread(image_path)
|
41 |
rotated_image, pred_data = PREDICTOR(image)
|
42 |
structured_text = get_structured_text(pred_data, ['shrinked_text'])
|
|
|
43 |
result_text = [' '.join(line_text) for page_text in structured_text
|
44 |
for line_text in page_text]
|
45 |
return '\n'.join(result_text)
|
46 |
|
47 |
|
48 |
+
if __name__ == '__main__':
|
49 |
+
PIPELINE_CONFIG_PATH = get_config_and_download_weights("sberbank-ai/ReadingPipeline-Peter")
|
50 |
|
51 |
+
PREDICTOR = PipelinePredictor(pipeline_config_path=PIPELINE_CONFIG_PATH)
|
52 |
|
53 |
+
gr.Interface(
|
54 |
+
predict,
|
55 |
+
inputs=gr.Image(label="Upload an image", type="filepath"),
|
56 |
+
outputs=gr.Textbox(label="Text on the image"),
|
57 |
+
title="Text on the image",
|
58 |
+
).launch()
|