Spaces:
Running on Zero
Running on Zero
File size: 1,074 Bytes
e003cc7 67db0b5 e003cc7 a1a470b 19492df a1a470b e003cc7 c46221c e003cc7 d36e2a3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | """Hosted entry point for the shared research studio."""
import os
from pathlib import Path
import subprocess
import sys
import logging
LOCAL_PROJECT = Path(__file__).resolve().parent.parent.parent
local_checkout = (LOCAL_PROJECT/'demo/gradio_app.py').is_file()
PROJECT = Path(os.environ.get('SAM_DEMO_PROJECT',str(LOCAL_PROJECT) if local_checkout else '/tmp/rethinking-lightweight-sam-paired-v10'))
if local_checkout and not os.environ.get('SPACE_ID'):
os.environ.setdefault('SAM_DEMO_LOCAL','1')
if not (PROJECT/'demo/gradio_app.py').is_file():
subprocess.run(['git','clone','--depth','1',
'https://github.com/thirteen7/Mask-Refinement-and-Efficient-Automatic-Mask-Generation-for-Lightweight-SAM.git',str(PROJECT)],check=True)
sys.path.insert(0,str(PROJECT))
from demo.gradio_app import build_demo
logging.basicConfig(level=logging.INFO,format='%(asctime)s %(levelname)s %(message)s')
demo = build_demo(PROJECT)
if __name__=='__main__':
demo.launch(server_name='0.0.0.0',server_port=int(os.environ.get('PORT','7860')),show_error=True,ssr_mode=False)
|