Spaces:
Running
on
A10G
Running
on
A10G
update
Browse files
app.py
CHANGED
@@ -1,14 +1,17 @@
|
|
1 |
#!/usr/bin/env python
|
2 |
-
"""Demo app for https://github.com/
|
3 |
The code in this repo is partly adapted from the following repository:
|
4 |
https://huggingface.co/spaces/hysts/LoRA-SD-training
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
12 |
"""
|
13 |
|
14 |
from __future__ import annotations
|
@@ -57,9 +60,9 @@ ReVersion
|
|
57 |
|
58 |
ORIGINAL_SPACE_ID = 'Ziqi/ReVersion'
|
59 |
SPACE_ID = os.getenv('SPACE_ID', ORIGINAL_SPACE_ID)
|
60 |
-
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.
|
61 |
-
<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>
|
62 |
-
'''
|
63 |
if os.getenv('SYSTEM') == 'spaces' and SPACE_ID != ORIGINAL_SPACE_ID:
|
64 |
SETTINGS = f'<a href="https://huggingface.co/spaces/{SPACE_ID}/settings">Settings</a>'
|
65 |
|
@@ -107,7 +110,7 @@ def create_inference_demo(func: inference_fn) -> gr.Blocks:
|
|
107 |
value='experiments/painted_on',
|
108 |
label='Relation',
|
109 |
visible=True)
|
110 |
-
reload_button = gr.Button('Reload Weight List')
|
111 |
prompt = gr.Textbox(
|
112 |
label='Prompt',
|
113 |
max_lines=1,
|
@@ -131,11 +134,11 @@ def create_inference_demo(func: inference_fn) -> gr.Blocks:
|
|
131 |
|
132 |
run_button = gr.Button('Generate')
|
133 |
|
134 |
-
gr.Markdown('''
|
135 |
-
- Models with names starting with "custom-diffusion-models/" are the pretrained models provided in the [original repo](https://github.com/adobe-research/custom-diffusion), and the ones with names starting with "results/delta.bin" are your trained models.
|
136 |
-
- After training, you can press "Reload Weight List" button to load your trained model names.
|
137 |
-
- Increase number of steps in Other parameters for better samples qualitatively.
|
138 |
-
''')
|
139 |
with gr.Column():
|
140 |
result = gr.Image(label='Result')
|
141 |
|
@@ -147,6 +150,7 @@ def create_inference_demo(func: inference_fn) -> gr.Blocks:
|
|
147 |
model_id,
|
148 |
prompt,
|
149 |
placeholder_string,
|
|
|
150 |
guidance_scale
|
151 |
],
|
152 |
outputs=result,
|
@@ -156,6 +160,7 @@ def create_inference_demo(func: inference_fn) -> gr.Blocks:
|
|
156 |
model_id,
|
157 |
prompt,
|
158 |
placeholder_string,
|
|
|
159 |
guidance_scale
|
160 |
],
|
161 |
outputs=result,
|
@@ -168,8 +173,8 @@ args.device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
|
168 |
print('*** Now using %s.'%(args.device))
|
169 |
|
170 |
with gr.Blocks(css='style.css') as demo:
|
171 |
-
if os.getenv('IS_SHARED_UI'):
|
172 |
-
|
173 |
if not torch.cuda.is_available():
|
174 |
show_warning(CUDA_NOT_AVAILABLE_WARNING)
|
175 |
|
@@ -178,14 +183,13 @@ with gr.Blocks(css='style.css') as demo:
|
|
178 |
gr.Markdown(DETAILDESCRIPTION)
|
179 |
|
180 |
with gr.Tabs():
|
181 |
-
|
182 |
with gr.TabItem('Test'):
|
183 |
create_inference_demo(inference_fn)
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
# demo.queue(default_enabled=False).launch(server_port=args.port, share=args.share)
|
191 |
|
|
|
1 |
#!/usr/bin/env python
|
2 |
+
"""Demo app for https://github.com/ziqihuangg/ReVersion.
|
3 |
The code in this repo is partly adapted from the following repository:
|
4 |
https://huggingface.co/spaces/hysts/LoRA-SD-training
|
5 |
+
|
6 |
+
S-Lab License 1.0
|
7 |
+
|
8 |
+
Copyright 2022 S-Lab
|
9 |
+
Redistribution and use for non-commercial purpose in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
10 |
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
11 |
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
12 |
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
13 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
14 |
+
4. In the event that redistribution and/or use for commercial purpose in source or binary forms, with or without modification is required, please contact the contributor(s) of the work.
|
15 |
"""
|
16 |
|
17 |
from __future__ import annotations
|
|
|
60 |
|
61 |
ORIGINAL_SPACE_ID = 'Ziqi/ReVersion'
|
62 |
SPACE_ID = os.getenv('SPACE_ID', ORIGINAL_SPACE_ID)
|
63 |
+
# 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.
|
64 |
+
# <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>
|
65 |
+
# '''
|
66 |
if os.getenv('SYSTEM') == 'spaces' and SPACE_ID != ORIGINAL_SPACE_ID:
|
67 |
SETTINGS = f'<a href="https://huggingface.co/spaces/{SPACE_ID}/settings">Settings</a>'
|
68 |
|
|
|
110 |
value='experiments/painted_on',
|
111 |
label='Relation',
|
112 |
visible=True)
|
113 |
+
# reload_button = gr.Button('Reload Weight List')
|
114 |
prompt = gr.Textbox(
|
115 |
label='Prompt',
|
116 |
max_lines=1,
|
|
|
134 |
|
135 |
run_button = gr.Button('Generate')
|
136 |
|
137 |
+
# gr.Markdown('''
|
138 |
+
# - Models with names starting with "custom-diffusion-models/" are the pretrained models provided in the [original repo](https://github.com/adobe-research/custom-diffusion), and the ones with names starting with "results/delta.bin" are your trained models.
|
139 |
+
# - After training, you can press "Reload Weight List" button to load your trained model names.
|
140 |
+
# - Increase number of steps in Other parameters for better samples qualitatively.
|
141 |
+
# ''')
|
142 |
with gr.Column():
|
143 |
result = gr.Image(label='Result')
|
144 |
|
|
|
150 |
model_id,
|
151 |
prompt,
|
152 |
placeholder_string,
|
153 |
+
num_samples,
|
154 |
guidance_scale
|
155 |
],
|
156 |
outputs=result,
|
|
|
160 |
model_id,
|
161 |
prompt,
|
162 |
placeholder_string,
|
163 |
+
num_samples,
|
164 |
guidance_scale
|
165 |
],
|
166 |
outputs=result,
|
|
|
173 |
print('*** Now using %s.'%(args.device))
|
174 |
|
175 |
with gr.Blocks(css='style.css') as demo:
|
176 |
+
# if os.getenv('IS_SHARED_UI'):
|
177 |
+
# show_warning(SHARED_UI_WARNING)
|
178 |
if not torch.cuda.is_available():
|
179 |
show_warning(CUDA_NOT_AVAILABLE_WARNING)
|
180 |
|
|
|
183 |
gr.Markdown(DETAILDESCRIPTION)
|
184 |
|
185 |
with gr.Tabs():
|
|
|
186 |
with gr.TabItem('Test'):
|
187 |
create_inference_demo(inference_fn)
|
188 |
|
189 |
+
demo.launch(
|
190 |
+
enable_queue=args.enable_queue,
|
191 |
+
server_port=args.port,
|
192 |
+
share=args.share,
|
193 |
+
)
|
194 |
# demo.queue(default_enabled=False).launch(server_port=args.port, share=args.share)
|
195 |
|