Spaces:
Runtime error
Runtime error
paul hilders
commited on
Commit
·
c81ac67
1
Parent(s):
2a6b42b
Add entity label to image title
Browse files
app.py
CHANGED
@@ -83,7 +83,7 @@ def add_label_to_img(img, label, add_entity_label=True):
|
|
83 |
draw = ImageDraw.Draw(img)
|
84 |
font = ImageFont.truetype("arial.ttf", 24)
|
85 |
if add_entity_label:
|
86 |
-
draw.text((0,0), "Entity:
|
87 |
else:
|
88 |
draw.text((0,0), str(label), align="center", fill=(0, 0, 0), font=font)
|
89 |
|
@@ -105,7 +105,7 @@ def NER_demo(image, text):
|
|
105 |
gallery_images = [add_label_to_img(overlapped, "Full explanation", add_entity_label=False)]
|
106 |
for ent_text, ent_label in highlighed_entities:
|
107 |
overlapped_ent, highlighted_text_ent = run_demo(image, ent_text)
|
108 |
-
overlapped_ent_labelled = add_label_to_img(overlapped_ent, ent_text)
|
109 |
|
110 |
gallery_images.append(overlapped_ent_labelled)
|
111 |
|
@@ -122,7 +122,7 @@ iface_NER = gr.Interface(fn=NER_demo,
|
|
122 |
inputs=inputs_NER,
|
123 |
outputs=outputs_NER,
|
124 |
examples=[["example_images/London.png", "In this image we see Big Ben and the London Eye, on both sides of the river Thames."]],
|
125 |
-
|
126 |
|
127 |
demo_tabs = gr.TabbedInterface([iface, iface_NER], ["Default", "NER"])
|
128 |
demo_tabs.launch(debug=True)
|
|
|
83 |
draw = ImageDraw.Draw(img)
|
84 |
font = ImageFont.truetype("arial.ttf", 24)
|
85 |
if add_entity_label:
|
86 |
+
draw.text((0,0), f"Entity: {str(label)}" , align="center", fill=(0, 0, 0), font=font)
|
87 |
else:
|
88 |
draw.text((0,0), str(label), align="center", fill=(0, 0, 0), font=font)
|
89 |
|
|
|
105 |
gallery_images = [add_label_to_img(overlapped, "Full explanation", add_entity_label=False)]
|
106 |
for ent_text, ent_label in highlighed_entities:
|
107 |
overlapped_ent, highlighted_text_ent = run_demo(image, ent_text)
|
108 |
+
overlapped_ent_labelled = add_label_to_img(overlapped_ent, f"{str(ent_text)} ({str(ent_label)})")
|
109 |
|
110 |
gallery_images.append(overlapped_ent_labelled)
|
111 |
|
|
|
122 |
inputs=inputs_NER,
|
123 |
outputs=outputs_NER,
|
124 |
examples=[["example_images/London.png", "In this image we see Big Ben and the London Eye, on both sides of the river Thames."]],
|
125 |
+
cache_examples=False)
|
126 |
|
127 |
demo_tabs = gr.TabbedInterface([iface, iface_NER], ["Default", "NER"])
|
128 |
demo_tabs.launch(debug=True)
|