Spaces:
Sleeping
Sleeping
#!/usr/bin/env python | |
from __future__ import annotations | |
import os | |
import shutil | |
import subprocess | |
import gradio as gr | |
if os.getenv('SYSTEM') == 'spaces': | |
with open('patch') as f: | |
subprocess.run('patch -p1'.split(), cwd='prismer', stdin=f) | |
shutil.copytree('prismer/helpers/images', | |
'prismer/images', | |
dirs_exist_ok=True) | |
from app_caption import create_demo as create_demo_caption | |
from prismer_model import build_deformable_conv, download_models | |
download_models() | |
build_deformable_conv() | |
DESCRIPTION = '# [Prismer](https://github.com/nvlabs/prismer)' | |
if (SPACE_ID := os.getenv('SPACE_ID')) is not None: | |
DESCRIPTION += f'<p>For faster inference without waiting in queue, you may duplicate the space and upgrade to GPU in settings. <a href="https://huggingface.co/spaces/{SPACE_ID}?duplicate=true"><img style="display: inline; margin-top: 0em; margin-bottom: 0em" src="https://bit.ly/3gLdBN6" alt="Duplicate Space" /></a></p>' | |
with gr.Blocks(css='style.css') as demo: | |
gr.Markdown(DESCRIPTION) | |
with gr.Tabs(): | |
with gr.TabItem('Caption'): | |
create_demo_caption() | |
demo.queue(api_open=False).launch() | |