Spaces:
Sleeping
Sleeping
firs version highlight function
Browse files
app.py
CHANGED
@@ -1,7 +1,19 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
+
from io import StringIO, BytesIO
|
2 |
+
|
3 |
import gradio as gr
|
4 |
+
from pdf_miner.high_level import extract_text
|
5 |
+
from transformers import pipeline
|
6 |
+
|
7 |
+
nlp = pipeline("ner", model="carblacac/ner-investing", tokenizer="carblacac/ner-investing")
|
8 |
+
|
9 |
|
10 |
+
def highlight_text(fileObj):
|
11 |
+
path = BytesIO(fileObj)
|
12 |
+
text = extract_text(path)
|
13 |
+
entities = nlp(text)
|
14 |
+
return {"text": text, "entities": entities}
|
15 |
|
16 |
+
iface = gr.Interface(fn=highlight_text,
|
17 |
+
gr.inputs.File(file_count="single", type="bytes"),
|
18 |
+
gr.HighlightedText())
|
19 |
iface.launch()
|