Spaces:
Runtime error
Runtime error
Commit
·
1aabba7
1
Parent(s):
15de16d
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
from __future__ import annotations
|
4 |
|
5 |
import os
|
|
|
6 |
|
7 |
import gradio as gr
|
8 |
import torch
|
@@ -17,7 +18,8 @@ TITLE = '# [Tune-A-Video](https://tuneavideo.github.io/) Training UI'
|
|
17 |
|
18 |
ORIGINAL_SPACE_ID = 'Tune-A-Video-library/Tune-A-Video-Training-UI'
|
19 |
SPACE_ID = os.getenv('SPACE_ID', ORIGINAL_SPACE_ID)
|
20 |
-
|
|
|
21 |
|
22 |
<center><a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/{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></center>
|
23 |
'''
|
@@ -26,20 +28,25 @@ if os.getenv('SYSTEM') == 'spaces' and SPACE_ID != ORIGINAL_SPACE_ID:
|
|
26 |
SETTINGS = f'<a href="https://huggingface.co/spaces/{SPACE_ID}/settings">Settings</a>'
|
27 |
else:
|
28 |
SETTINGS = 'Settings'
|
29 |
-
|
|
|
|
|
|
|
30 |
<center>
|
31 |
You can assign a GPU in the {SETTINGS} tab if you are running this on HF Spaces.
|
32 |
-
You can use "T4 small/medium"
|
33 |
</center>
|
34 |
'''
|
35 |
|
36 |
-
HF_TOKEN_NOT_SPECIFIED_WARNING = f'''
|
37 |
<center>
|
38 |
You can check and create your Hugging Face tokens <a href="https://huggingface.co/settings/tokens" target="_blank">here</a>.
|
39 |
You can specify environment variables in the "Repository secrets" section of the {SETTINGS} tab.
|
40 |
</center>
|
41 |
'''
|
42 |
|
|
|
|
|
43 |
HF_TOKEN = os.getenv('HF_TOKEN')
|
44 |
|
45 |
|
@@ -56,6 +63,8 @@ trainer = Trainer(HF_TOKEN)
|
|
56 |
with gr.Blocks(css='style.css') as demo:
|
57 |
if SPACE_ID != ORIGINAL_SPACE_ID:
|
58 |
show_warning(SHARED_UI_WARNING)
|
|
|
|
|
59 |
elif not torch.cuda.is_available():
|
60 |
show_warning(CUDA_NOT_AVAILABLE_WARNING)
|
61 |
|
@@ -74,4 +83,4 @@ with gr.Blocks(css='style.css') as demo:
|
|
74 |
if not HF_TOKEN:
|
75 |
show_warning(HF_TOKEN_NOT_SPECIFIED_WARNING)
|
76 |
|
77 |
-
demo.queue(max_size=1).launch(share=False)
|
|
|
3 |
from __future__ import annotations
|
4 |
|
5 |
import os
|
6 |
+
from subprocess import getoutput
|
7 |
|
8 |
import gradio as gr
|
9 |
import torch
|
|
|
18 |
|
19 |
ORIGINAL_SPACE_ID = 'Tune-A-Video-library/Tune-A-Video-Training-UI'
|
20 |
SPACE_ID = os.getenv('SPACE_ID', ORIGINAL_SPACE_ID)
|
21 |
+
GPU_DATA = getoutput('nvidia-smi')
|
22 |
+
SHARED_UI_WARNING = f'''## Attention - This Space doesn't work in this shared UI. You can duplicate and use it with a paid private T4 GPU.
|
23 |
|
24 |
<center><a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/{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></center>
|
25 |
'''
|
|
|
28 |
SETTINGS = f'<a href="https://huggingface.co/spaces/{SPACE_ID}/settings">Settings</a>'
|
29 |
else:
|
30 |
SETTINGS = 'Settings'
|
31 |
+
|
32 |
+
INVALID_GPU_WARNING = f'''## Attention - the specified GPU is invalid. Training may not work. Make sure you have selected a `T4 GPU` for this task.'''
|
33 |
+
|
34 |
+
CUDA_NOT_AVAILABLE_WARNING = f'''## Attention - Running on CPU.
|
35 |
<center>
|
36 |
You can assign a GPU in the {SETTINGS} tab if you are running this on HF Spaces.
|
37 |
+
You can use "T4 small/medium" to run this demo.
|
38 |
</center>
|
39 |
'''
|
40 |
|
41 |
+
HF_TOKEN_NOT_SPECIFIED_WARNING = f'''The environment variable `HF_TOKEN` is not specified. Feel free to specify your Hugging Face token with write permission if you don't want to manually provide it for every run.
|
42 |
<center>
|
43 |
You can check and create your Hugging Face tokens <a href="https://huggingface.co/settings/tokens" target="_blank">here</a>.
|
44 |
You can specify environment variables in the "Repository secrets" section of the {SETTINGS} tab.
|
45 |
</center>
|
46 |
'''
|
47 |
|
48 |
+
|
49 |
+
|
50 |
HF_TOKEN = os.getenv('HF_TOKEN')
|
51 |
|
52 |
|
|
|
63 |
with gr.Blocks(css='style.css') as demo:
|
64 |
if SPACE_ID != ORIGINAL_SPACE_ID:
|
65 |
show_warning(SHARED_UI_WARNING)
|
66 |
+
elif(not "T4" in GPU_DATA):
|
67 |
+
show_warning(INVALID_GPU_WARNING)
|
68 |
elif not torch.cuda.is_available():
|
69 |
show_warning(CUDA_NOT_AVAILABLE_WARNING)
|
70 |
|
|
|
83 |
if not HF_TOKEN:
|
84 |
show_warning(HF_TOKEN_NOT_SPECIFIED_WARNING)
|
85 |
|
86 |
+
demo.queue(max_size=1).launch(share=False)
|