from __future__ import annotations import os import gradio as gr from gradio_caption import create_demo as create_caption from gradio_vqa import create_demo as create_vqa from prismer_model import build_deformable_conv, download_models # Prepare Prismer checkpoints download_models() build_deformable_conv() # Official Demo here description = """ # Prismer The official demo for **Prismer: A Vision-Language Model with An Ensemble of Experts**. Please refer to our [project page](https://shikun.io/projects/prismer) or [github](https://github.com/NVlabs/prismer) for more details. """ if (SPACE_ID := os.getenv('SPACE_ID')) is not None: description += f'For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. Duplicate Space' with gr.Blocks() as demo: gr.Markdown(description) with gr.Tab("Zero-shot Image Captioning"): create_caption() with gr.Tab("Visual Question Answering"): create_vqa() demo.queue(api_open=False).launch()