Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -25,11 +25,10 @@ import gradio as gr
|
|
25 |
import numpy as np
|
26 |
|
27 |
from mmdet.apis import init_detector, inference_detector
|
28 |
-
from utils import show_result
|
29 |
from mmcv import Config
|
30 |
import openpsg
|
31 |
|
32 |
-
|
33 |
DESCRIPTION = '''# ECCV'22 | Panoptic Scene Graph Generation
|
34 |
|
35 |
|
@@ -55,7 +54,6 @@ Inference takes 10-30 seconds per image. The model is PSGTR (60 epochs).
|
|
55 |
'''
|
56 |
FOOTER = '<img id="visitor-badge" src="https://visitor-badge.glitch.me/badge?page_id=c-liangyu.openpsg" alt="visitor badge" />'
|
57 |
|
58 |
-
|
59 |
def parse_args() -> argparse.Namespace:
|
60 |
parser = argparse.ArgumentParser()
|
61 |
parser.add_argument('--device', type=str, default='cpu')
|
@@ -88,12 +86,14 @@ class Model:
|
|
88 |
|
89 |
def infer(self, input_image, num_rel):
|
90 |
result = inference_detector(self.model, input_image)
|
91 |
-
|
92 |
result,
|
93 |
is_one_stage=True,
|
94 |
num_rel=num_rel,
|
95 |
show=True
|
96 |
)
|
|
|
|
|
97 |
|
98 |
|
99 |
def main():
|
@@ -121,7 +121,9 @@ def main():
|
|
121 |
run_button = gr.Button(value='Run')
|
122 |
with gr.Column():
|
123 |
with gr.Row():
|
124 |
-
|
|
|
|
|
125 |
|
126 |
with gr.Row():
|
127 |
paths = sorted(pathlib.Path('images').rglob('*.jpg'))
|
@@ -139,7 +141,7 @@ def main():
|
|
139 |
inputs=[
|
140 |
input_image, num_rel
|
141 |
],
|
142 |
-
outputs=
|
143 |
|
144 |
example_images.click(fn=set_example_image,
|
145 |
inputs=example_images,
|
|
|
25 |
import numpy as np
|
26 |
|
27 |
from mmdet.apis import init_detector, inference_detector
|
28 |
+
from utils import make_gif, show_result
|
29 |
from mmcv import Config
|
30 |
import openpsg
|
31 |
|
|
|
32 |
DESCRIPTION = '''# ECCV'22 | Panoptic Scene Graph Generation
|
33 |
|
34 |
|
|
|
54 |
'''
|
55 |
FOOTER = '<img id="visitor-badge" src="https://visitor-badge.glitch.me/badge?page_id=c-liangyu.openpsg" alt="visitor badge" />'
|
56 |
|
|
|
57 |
def parse_args() -> argparse.Namespace:
|
58 |
parser = argparse.ArgumentParser()
|
59 |
parser.add_argument('--device', type=str, default='cpu')
|
|
|
86 |
|
87 |
def infer(self, input_image, num_rel):
|
88 |
result = inference_detector(self.model, input_image)
|
89 |
+
displays = show_result(input_image,
|
90 |
result,
|
91 |
is_one_stage=True,
|
92 |
num_rel=num_rel,
|
93 |
show=True
|
94 |
)
|
95 |
+
gif = make_gif(displays[:10] if len(displays) > 10 else displays)
|
96 |
+
return gif, displays
|
97 |
|
98 |
|
99 |
def main():
|
|
|
121 |
run_button = gr.Button(value='Run')
|
122 |
with gr.Column():
|
123 |
with gr.Row():
|
124 |
+
gif = gr.Image(label='Top Relations')
|
125 |
+
with gr.Row():
|
126 |
+
displays = gr.Gallery(label='PSGTR Result', type='numpy')
|
127 |
|
128 |
with gr.Row():
|
129 |
paths = sorted(pathlib.Path('images').rglob('*.jpg'))
|
|
|
141 |
inputs=[
|
142 |
input_image, num_rel
|
143 |
],
|
144 |
+
outputs=[gif, displays])
|
145 |
|
146 |
example_images.click(fn=set_example_image,
|
147 |
inputs=example_images,
|