Spaces:
Runtime error
Runtime error
Commit
•
e9eed9e
1
Parent(s):
d1442c6
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,7 @@ from huggingface_hub import snapshot_download
|
|
19 |
|
20 |
is_spaces = True if "SPACE_ID" in os.environ else False
|
21 |
is_shared_ui = True if "IS_SHARED_UI" in os.environ else False
|
|
|
22 |
|
23 |
css = '''
|
24 |
.instruction{position: absolute; top: 0;right: 0;margin-top: 0px !important}
|
@@ -29,7 +30,7 @@ css = '''
|
|
29 |
maximum_concepts = 3
|
30 |
|
31 |
#Pre download the files
|
32 |
-
if(not is_shared_ui):
|
33 |
model_v1 = snapshot_download(repo_id="multimodalart/sd-fine-tunable")
|
34 |
model_v2 = snapshot_download(repo_id="stabilityai/stable-diffusion-2")
|
35 |
model_v2_512 = snapshot_download(repo_id="stabilityai/stable-diffusion-2-base")
|
@@ -57,7 +58,7 @@ def swap_text(option, base):
|
|
57 |
return [f"You are going to train a `style`, upload 10-20 images of the style you are planning on training on. You can use services like <a style='text-decoration: underline' href='https://www.birme.net/?target_width={resize_width}&target_height={resize_width}'>birme</a> for smart cropping. Name the files with the words you would like {mandatory_liability}:", '''<img src="file/trsl_style.png" />''', f"You should name your concept with a unique made up word that has low chance of the model already knowing it (e.g.: `{instance_prompt_example}` here). Images will be automatically cropped to {resize_width}x{resize_width}", freeze_for, gr.update(visible=False)]
|
58 |
|
59 |
def swap_base_model(selected_model):
|
60 |
-
if(not is_shared_ui):
|
61 |
global model_to_load
|
62 |
if(selected_model == "v1-5"):
|
63 |
model_to_load = model_v1
|
@@ -447,12 +448,20 @@ with gr.Blocks(css=css) as demo:
|
|
447 |
</div>
|
448 |
''')
|
449 |
elif(is_spaces):
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
else:
|
457 |
top_description = gr.HTML(f'''
|
458 |
<div class="gr-prose" style="max-width: 80%">
|
|
|
19 |
|
20 |
is_spaces = True if "SPACE_ID" in os.environ else False
|
21 |
is_shared_ui = True if "IS_SHARED_UI" in os.environ else False
|
22 |
+
is_gpu_associated = torch.cuda.is_available()
|
23 |
|
24 |
css = '''
|
25 |
.instruction{position: absolute; top: 0;right: 0;margin-top: 0px !important}
|
|
|
30 |
maximum_concepts = 3
|
31 |
|
32 |
#Pre download the files
|
33 |
+
if(not is_shared_ui or not is_gpu_associated):
|
34 |
model_v1 = snapshot_download(repo_id="multimodalart/sd-fine-tunable")
|
35 |
model_v2 = snapshot_download(repo_id="stabilityai/stable-diffusion-2")
|
36 |
model_v2_512 = snapshot_download(repo_id="stabilityai/stable-diffusion-2-base")
|
|
|
58 |
return [f"You are going to train a `style`, upload 10-20 images of the style you are planning on training on. You can use services like <a style='text-decoration: underline' href='https://www.birme.net/?target_width={resize_width}&target_height={resize_width}'>birme</a> for smart cropping. Name the files with the words you would like {mandatory_liability}:", '''<img src="file/trsl_style.png" />''', f"You should name your concept with a unique made up word that has low chance of the model already knowing it (e.g.: `{instance_prompt_example}` here). Images will be automatically cropped to {resize_width}x{resize_width}", freeze_for, gr.update(visible=False)]
|
59 |
|
60 |
def swap_base_model(selected_model):
|
61 |
+
if(not is_shared_ui or not is_gpu_associated):
|
62 |
global model_to_load
|
63 |
if(selected_model == "v1-5"):
|
64 |
model_to_load = model_v1
|
|
|
448 |
</div>
|
449 |
''')
|
450 |
elif(is_spaces):
|
451 |
+
if(is_gpu_associated):
|
452 |
+
top_description = gr.HTML(f'''
|
453 |
+
<div class="gr-prose" style="max-width: 80%">
|
454 |
+
<h2>You have successfully associated a GPU to the Dreambooth Training Space 🎉</h2>
|
455 |
+
<p>Certify that you got a T4. You can now train your model! You will be billed by the minute from when you activated the GPU until when it is turned it off.</p>
|
456 |
+
</div>
|
457 |
+
''')
|
458 |
+
else:
|
459 |
+
top_description = gr.HTML(f'''
|
460 |
+
<div class="gr-prose" style="max-width: 80%">
|
461 |
+
<h2>You have successfully duplicated the Dreambooth Training Space 🎉</h2>
|
462 |
+
<p>There's only one step left before you can train your model: <a href="https://huggingface.co/spaces/{os.environ['SPACE_ID']}/settings" style="text-decoration: underline">attribute a <b>T4 GPU</b> to it (via the Settings tab)</a> and run the training below. Other GPUs are not compatible for now. You will be billed by the minute from when you activate the GPU until when it is turned it off.</p>
|
463 |
+
</div>
|
464 |
+
''')
|
465 |
else:
|
466 |
top_description = gr.HTML(f'''
|
467 |
<div class="gr-prose" style="max-width: 80%">
|