Spaces:
Runtime error
Runtime error
from __future__ import annotations | |
import os | |
import pathlib | |
import gradio as gr | |
from prismer_model import run_experts | |
def create_demo(): | |
with gr.Row(): | |
with gr.Column(): | |
image = gr.Image(label='Input', type='filepath') | |
model_name = gr.Dropdown(label='Model', choices=['prismer_base'], value='prismer_base') | |
run_button = gr.Button('Run') | |
with gr.Column(scale=1.5): | |
caption = gr.Text(label='Caption') | |
with gr.Row(): | |
depth = gr.Image(label='Depth') | |
edge = gr.Image(label='Edge') | |
normals = gr.Image(label='Normals') | |
with gr.Row(): | |
segmentation = gr.Image(label='Segmentation') | |
object_detection = gr.Image(label='Object Detection') | |
ocr = gr.Image(label='OCR Detection') | |
inputs = [image, model_name] | |
outputs = [depth, edge, normals] | |
paths = sorted(pathlib.Path('prismer/images').glob('*')) | |
examples = [[path.as_posix(), 'prismer_base'] for path in paths] | |
gr.Examples(examples=examples, | |
inputs=inputs, | |
outputs=outputs, | |
fn=run_experts, | |
cache_examples=os.getenv('SYSTEM') == 'spaces') | |
run_button.click(fn=run_experts, inputs=inputs, outputs=outputs) | |
if __name__ == '__main__': | |
demo = create_demo() | |
demo.queue().launch() | |