# -*- coding: utf-8 -*- import datetime import os print(f"pip3 uninstall gradio") results = os.popen(f"pip3 uninstall gradio -y") print(results.readlines()) print(f"pip3 uninstall scepter") results = os.popen(f"pip3 uninstall scepter -y") print(results.readlines()) results = os.popen(f"pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple") print(results.readlines()) results = os.popen(f"pip3 install scepter -i https://pypi.tuna.tsinghua.edu.cn/simple") print(results.readlines()) print("finish install") import random import gradio as gr import scepter from scepter.modules.utils.config import Config from scepter.modules.utils.file_system import FS from scepter.modules.utils.logger import get_logger, init_logger def prepare(config): if 'FILE_SYSTEM' in config: for fs_info in config['FILE_SYSTEM']: FS.init_fs_client(fs_info) if 'LOG_FILE' in config: logger = get_logger() tid = '{0:%Y%m%d%H%M%S%f}'.format(datetime.datetime.now()) + ''.join( [str(random.randint(1, 10)) for i in range(3)]) init_logger(logger, log_file=config['LOG_FILE'].format(tid)) class TabManager(): def __init__(self): pass config_file = os.path.join(os.path.dirname(scepter.dirname), "scepter/methods/studio/scepter_ui.yaml") config = Config(load=True, cfg_file=config_file) for v in config.FILE_SYSTEM: v.TEMP_DIR = os.path.join("/home", v.TEMP_DIR) os.makedirs(v.TEMP_DIR, exist_ok=True) prepare(config) language = "en" debug = False tab_manager = TabManager() interfaces = [] for info in config['INTERFACE']: name = info.get('NAME_EN', '') if language == 'en' else info['NAME'] ifid = info['IFID'] if not FS.exists(info['CONFIG']): info['CONFIG'] = os.path.join(os.path.dirname(scepter.dirname), info['CONFIG']) if not FS.exists(info['CONFIG']): raise f"{info['CONFIG']} doesn't exist." interface = None if ifid == 'home': from scepter.studio.home.home import HomeUI interface = HomeUI(info['CONFIG'], is_debug=debug, language=language, root_work_dir=config.WORK_DIR) if ifid == 'inference': from scepter.studio.inference.inference import InferenceUI interface = InferenceUI( info['CONFIG'], is_debug=debug, language=language, root_work_dir=config.WORK_DIR) if ifid == '': pass # TODO: Add New Features if interface: interfaces.append((interface, name, ifid)) setattr(tab_manager, ifid, interface) with gr.Blocks() as demo: if 'BANNER' in config: gr.HTML(config.BANNER) else: gr.Markdown( f"

{config.get('TITLE', 'SCEPTER Studio')}

" ) with gr.Tabs(elem_id='tabs') as tabs: for interface, label, ifid in interfaces: with gr.TabItem(label, id=ifid, elem_id=f'tab_{ifid}'): interface.create_ui() for interface, label, ifid in interfaces: interface.set_callbacks(tab_manager) demo.queue(status_update_rate=1, api_open=False).launch(share=False, show_error=True, enable_queue=True)