Spaces:
Runtime error
Runtime error
Commit
·
8aa0e27
1
Parent(s):
6b2b912
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2 |
os.system('pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu')
|
3 |
os.system('sudo apt-get install tesseract-ocr')
|
4 |
os.system('pip install -q pytesseract')
|
|
|
5 |
import gradio as gr
|
6 |
import torch
|
7 |
from datasets import load_dataset, ClassLabel
|
@@ -116,9 +117,8 @@ def image_render(image):
|
|
116 |
predicted_label = iob_to_label(prediction)
|
117 |
draw.rectangle(box, outline=label_colour(predicted_label))
|
118 |
draw.text((box[0]+10, box[1]-10), text=predicted_label, fill=label_colour(predicted_label), font=font)
|
119 |
-
|
120 |
words = text_extraction(image)
|
121 |
-
print(words)
|
122 |
extracted_words = convert_results(words,true_predictions)
|
123 |
|
124 |
return image,extracted_words
|
@@ -133,6 +133,7 @@ demo = gr.Interface(fn = image_render,
|
|
133 |
allow_flagging=True,
|
134 |
flagging_options=["incorrect", "correct"],
|
135 |
flagging_callback = gr.CSVLogger(),
|
136 |
-
flagging_dir = "flagged"
|
|
|
137 |
)
|
138 |
-
demo.launch(
|
|
|
2 |
os.system('pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu')
|
3 |
os.system('sudo apt-get install tesseract-ocr')
|
4 |
os.system('pip install -q pytesseract')
|
5 |
+
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
6 |
import gradio as gr
|
7 |
import torch
|
8 |
from datasets import load_dataset, ClassLabel
|
|
|
117 |
predicted_label = iob_to_label(prediction)
|
118 |
draw.rectangle(box, outline=label_colour(predicted_label))
|
119 |
draw.text((box[0]+10, box[1]-10), text=predicted_label, fill=label_colour(predicted_label), font=font)
|
120 |
+
|
121 |
words = text_extraction(image)
|
|
|
122 |
extracted_words = convert_results(words,true_predictions)
|
123 |
|
124 |
return image,extracted_words
|
|
|
133 |
allow_flagging=True,
|
134 |
flagging_options=["incorrect", "correct"],
|
135 |
flagging_callback = gr.CSVLogger(),
|
136 |
+
flagging_dir = "flagged",
|
137 |
+
analytics_enabled = True, enable_queue=True
|
138 |
)
|
139 |
+
demo.launch(inline=False, share=False, debug=False)
|