Skip to content

Commit f035afe

Browse files
Fix/studio (#947)
1 parent c6c1cdf commit f035afe

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

swift/ui/app.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
},
3232
}
3333

34+
is_spaces = True if 'SPACE_ID' in os.environ else False
35+
if is_spaces:
36+
is_shared_ui = True if 'modelscope/swift' in os.environ['SPACE_ID'] else False
37+
else:
38+
is_shared_ui = False
39+
3440

3541
def run_ui():
3642
LLMTrain.set_lang(lang)
@@ -39,6 +45,16 @@ def run_ui():
3945
gr.HTML(f"<h1><center>{locale_dict['title'][lang]}</center></h1>")
4046
gr.HTML(f"<h3><center>{locale_dict['sub_title'][lang]}</center></h3>")
4147
gr.HTML(f"<h3><center>{locale_dict['star_beggar'][lang]}</center></h3>")
48+
if is_shared_ui:
49+
gr.HTML(f'''
50+
<div class="gr-prose" style="max-width: 80%">
51+
<p>If the waiting queue is too long, you can either run locally or duplicate the Space and run it on your own profile using a (paid) private A10G-large GPU for training. A A10G-large costs US$3.15/h. &nbsp;&nbsp;<a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/{os.environ['SPACE_ID']}?duplicate=true"><img src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&logoWidth=14" alt="Duplicate Space"></a></p> # noqa
52+
<img style="position: absolute; top: 0;right: 0; height: 100%;margin-top: 0px !important" src="file=duplicate.png"> # noqa
53+
</div>
54+
''')
55+
elif is_spaces and os.environ.get('MODELSCOPE_ENVIRONMENT') == 'studio':
56+
gr.HTML('<p><center>You have duplicated the space, remember remove the `MODELSCOPE_ENVIRONMENT` '
57+
'variable to start an unlimited version</center></p>')
4258
with gr.Tabs():
4359
LLMTrain.build_ui(LLMTrain)
4460
LLMInfer.build_ui(LLMInfer)

0 commit comments

Comments
 (0)