Spaces:
Build error
Build error
Commit
·
c9a46eb
1
Parent(s):
abbc40e
Update app.py
Browse files
app.py
CHANGED
@@ -12,10 +12,15 @@ import time
|
|
12 |
import psutil
|
13 |
import random
|
14 |
|
|
|
|
|
|
|
|
|
15 |
|
16 |
pipe = DiffusionPipeline.from_pretrained("timbrooks/instruct-pix2pix", torch_dtype=torch.float16, safety_checker=None)
|
17 |
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
18 |
-
|
|
|
19 |
pipe.unet.to(memory_format=torch.channels_last)
|
20 |
|
21 |
device = "GPU 🔥" if torch.cuda.is_available() else "CPU 🥶"
|
@@ -190,6 +195,15 @@ article = """
|
|
190 |
"""
|
191 |
|
192 |
with gr.Blocks(css='style.css') as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
with gr.Column(elem_id="col-container"):
|
194 |
gr.HTML(title)
|
195 |
with gr.Row():
|
|
|
12 |
import psutil
|
13 |
import random
|
14 |
|
15 |
+
### [Start] Duplicate only tag ###
|
16 |
+
is_shared_ui = True if "AIFILMS/Pix2Pix-Video" in os.environ['SPACE_ID'] else False
|
17 |
+
### [End] Duplicate only tag ###
|
18 |
+
|
19 |
|
20 |
pipe = DiffusionPipeline.from_pretrained("timbrooks/instruct-pix2pix", torch_dtype=torch.float16, safety_checker=None)
|
21 |
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
22 |
+
if(not is_shared_ui):
|
23 |
+
pipe.enable_xformers_memory_efficient_attention()
|
24 |
pipe.unet.to(memory_format=torch.channels_last)
|
25 |
|
26 |
device = "GPU 🔥" if torch.cuda.is_available() else "CPU 🥶"
|
|
|
195 |
"""
|
196 |
|
197 |
with gr.Blocks(css='style.css') as demo:
|
198 |
+
if(is_shared_ui):
|
199 |
+
top_description = gr.HTML(f'''
|
200 |
+
<div class="gr-prose" style="max-width: 80%">
|
201 |
+
<h2>Attention - This Space doesn't work in this shared UI</h2>
|
202 |
+
<p>For it to work, you can either run locally or duplicate the Space and run it on your own profile using a (paid) private T4-small or A10G-small GPU for training. A T4 costs US$0.60/h, so it should cost < US$1 to train most models using default settings with it! <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>
|
203 |
+
<img class="instruction" src="file=duplicate.png">
|
204 |
+
<img class="arrow" src="file=arrow.png" />
|
205 |
+
</div>
|
206 |
+
''')
|
207 |
with gr.Column(elem_id="col-container"):
|
208 |
gr.HTML(title)
|
209 |
with gr.Row():
|