Commit
·
fce94af
1
Parent(s):
b2d6a88
Updated input and output code to components
Browse files
app.py
CHANGED
|
@@ -28,6 +28,7 @@ dataset = load_dataset("darentang/generated", split="test")
|
|
| 28 |
Image.open(dataset[2]["image_path"]).convert("RGB").save("example1.png")
|
| 29 |
Image.open(dataset[1]["image_path"]).convert("RGB").save("example2.png")
|
| 30 |
Image.open(dataset[0]["image_path"]).convert("RGB").save("example3.png")
|
|
|
|
| 31 |
# define id2label, label2color
|
| 32 |
labels = dataset.features['ner_tags'].feature.names
|
| 33 |
id2label = {v: k for v, k in enumerate(labels)}
|
|
@@ -100,8 +101,8 @@ article="<b>References</b><br>[1] Y. Xu et al., “LayoutLMv3: Pre-training for
|
|
| 100 |
css = """.output_image, .input_image {height: 600px !important}"""
|
| 101 |
|
| 102 |
iface = gr.Interface(fn=process_image,
|
| 103 |
-
inputs=gr.
|
| 104 |
-
outputs=gr.
|
| 105 |
title=title,
|
| 106 |
description=description,
|
| 107 |
article=article,
|
|
|
|
| 28 |
Image.open(dataset[2]["image_path"]).convert("RGB").save("example1.png")
|
| 29 |
Image.open(dataset[1]["image_path"]).convert("RGB").save("example2.png")
|
| 30 |
Image.open(dataset[0]["image_path"]).convert("RGB").save("example3.png")
|
| 31 |
+
|
| 32 |
# define id2label, label2color
|
| 33 |
labels = dataset.features['ner_tags'].feature.names
|
| 34 |
id2label = {v: k for v, k in enumerate(labels)}
|
|
|
|
| 101 |
css = """.output_image, .input_image {height: 600px !important}"""
|
| 102 |
|
| 103 |
iface = gr.Interface(fn=process_image,
|
| 104 |
+
inputs=gr.components.Image(type="pil"),
|
| 105 |
+
outputs=gr.components.Image(type="pil", label="annotated image"),
|
| 106 |
title=title,
|
| 107 |
description=description,
|
| 108 |
article=article,
|