Spaces:
Runtime error
Runtime error
paul hilders commited on
Commit ·
6d91375
1
Parent(s): d46a4b3
Add NER gallery images
Browse files
app.py
CHANGED
|
@@ -86,15 +86,22 @@ def NER_demo(image, text):
|
|
| 86 |
ent_label = ent.label_
|
| 87 |
highlighed_entities.append((ent_text, ent_label))
|
| 88 |
|
| 89 |
-
|
|
|
|
| 90 |
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
input_img_NER = gr.inputs.Image(type='pil', label="Original Image")
|
| 94 |
input_txt_NER = "text"
|
| 95 |
inputs_NER = [input_img_NER, input_txt_NER]
|
| 96 |
|
| 97 |
-
outputs_NER = ["highlight"]
|
| 98 |
|
| 99 |
|
| 100 |
iface_NER = gr.Interface(fn=NER_demo,
|
|
|
|
| 86 |
ent_label = ent.label_
|
| 87 |
highlighed_entities.append((ent_text, ent_label))
|
| 88 |
|
| 89 |
+
# As the default image, we run the default demo on the input image and text:
|
| 90 |
+
overlapped, highlighted_text = run_demo(image, text)
|
| 91 |
|
| 92 |
+
# Then, we run the demo for each of the named entities:
|
| 93 |
+
gallery_images = [overlapped]
|
| 94 |
+
for ent_text, ent_label in highlighed_entities:
|
| 95 |
+
overlapped_ent, highlighted_text_ent = run_demo(image, ent_text)
|
| 96 |
+
gallery_images.append(overlapped_ent)
|
| 97 |
+
|
| 98 |
+
return highlighed_entities, gallery_images
|
| 99 |
|
| 100 |
input_img_NER = gr.inputs.Image(type='pil', label="Original Image")
|
| 101 |
input_txt_NER = "text"
|
| 102 |
inputs_NER = [input_img_NER, input_txt_NER]
|
| 103 |
|
| 104 |
+
outputs_NER = ["highlight", gr.Gallery(type='pil', label="NER Entity explanations")]
|
| 105 |
|
| 106 |
|
| 107 |
iface_NER = gr.Interface(fn=NER_demo,
|