Spaces:
Running
Running
Commit
·
269e4c2
1
Parent(s):
2e73fb1
Added in the NER function to the text retrieved
Browse files
app.py
CHANGED
|
@@ -20,7 +20,7 @@ def get_named_entities(ocr_text: str):
|
|
| 20 |
tagger.predict(sentence)
|
| 21 |
|
| 22 |
entities = [entity for entity in sent.get_spans("ner") for sent in sentence]
|
| 23 |
-
|
| 24 |
return entities
|
| 25 |
|
| 26 |
|
|
@@ -46,7 +46,9 @@ def get_named_entities(ocr_text: str):
|
|
| 46 |
|
| 47 |
def run(image, lang=None):
|
| 48 |
result = pytesseract.image_to_string(image, lang=None if lang == [] else lang)
|
| 49 |
-
|
|
|
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
with gr.Blocks() as demo:
|
|
@@ -58,9 +60,9 @@ with gr.Blocks() as demo:
|
|
| 58 |
btn = gr.Button("Run")
|
| 59 |
with gr.Column():
|
| 60 |
text_out = gr.TextArea()
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
|
| 63 |
-
# image_in, lang], outputs=[text_out], cache_examples=False)
|
| 64 |
-
btn.click(fn=run, inputs=[image_in, lang], outputs=[text_out])
|
| 65 |
|
| 66 |
demo.launch()
|
|
|
|
| 20 |
tagger.predict(sentence)
|
| 21 |
|
| 22 |
entities = [entity for entity in sent.get_spans("ner") for sent in sentence]
|
| 23 |
+
print("Entities ", entities)
|
| 24 |
return entities
|
| 25 |
|
| 26 |
|
|
|
|
| 46 |
|
| 47 |
def run(image, lang=None):
|
| 48 |
result = pytesseract.image_to_string(image, lang=None if lang == [] else lang)
|
| 49 |
+
|
| 50 |
+
ner = get_named_entities(result)
|
| 51 |
+
return [result, ner]
|
| 52 |
|
| 53 |
|
| 54 |
with gr.Blocks() as demo:
|
|
|
|
| 60 |
btn = gr.Button("Run")
|
| 61 |
with gr.Column():
|
| 62 |
text_out = gr.TextArea()
|
| 63 |
+
with gr.Column():
|
| 64 |
+
ner = gr.TextArea()
|
| 65 |
|
| 66 |
+
btn.click(fn=run, inputs=[image_in, lang], outputs=[text_out, ner])
|
|
|
|
|
|
|
| 67 |
|
| 68 |
demo.launch()
|