Spaces:
Running
on
Zero
Running
on
Zero
SunderAli17
commited on
Commit
•
1fbb135
1
Parent(s):
512dfd4
Update app.py
Browse files
app.py
CHANGED
@@ -151,21 +151,39 @@ def generate_image(
|
|
151 |
img = Image.fromarray((127.5 * (x + 1.0)).cpu().byte().numpy())
|
152 |
return img, str(opts.seed), flux_generator.toonmage_model.debug_img_list
|
153 |
|
154 |
-
|
155 |
-
<
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
-
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
|
164 |
|
165 |
def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_available() else "cpu",
|
166 |
offload: bool = False):
|
167 |
-
with gr.Blocks() as demo:
|
168 |
-
gr.Markdown(
|
169 |
|
170 |
with gr.Row():
|
171 |
with gr.Column():
|
@@ -195,69 +213,29 @@ def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_ava
|
|
195 |
output_image = gr.Image(label="Generated Image")
|
196 |
seed_output = gr.Textbox(label="Used Seed")
|
197 |
intermediate_output = gr.Gallery(label='Output', elem_id="gallery", visible=args.dev)
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
# 4, 4, 10606046113565776207, 1
|
222 |
-
# ],
|
223 |
-
# [
|
224 |
-
# 'a man is holding a sign with text, winter, snowing, top of the mountain',
|
225 |
-
# 'example_inputs/pengwei.jpg',
|
226 |
-
# 4, 4, 2410129802683836089, 1
|
227 |
-
# ],
|
228 |
-
# [
|
229 |
-
# 'portrait, candle light',
|
230 |
-
# 'example_inputs/pengwei.jpg',
|
231 |
-
# 4, 4, 17522759474323955700, 1
|
232 |
-
# ],
|
233 |
-
# [
|
234 |
-
# 'profile shot dark photo of a 25-year-old male with smoke escaping from his mouth, the backlit smoke gives the image an ephemeral quality, natural face, natural eyebrows, natural skin texture, award winning photo, highly detailed face, atmospheric lighting, film grain, monochrome',
|
235 |
-
# 'example_inputs/pengwei.jpg',
|
236 |
-
# 4, 4, 17733156847328193625, 1
|
237 |
-
# ],
|
238 |
-
# [
|
239 |
-
# 'American Comics, 1boy',
|
240 |
-
# 'example_inputs/pengwei.jpg',
|
241 |
-
# 1, 4, 13223174453874179686, 1
|
242 |
-
# ],
|
243 |
-
# [
|
244 |
-
# 'portrait, pixar',
|
245 |
-
# 'example_inputs/pengwei.jpg',
|
246 |
-
# 1, 4, 9445036702517583939, 1
|
247 |
-
# ],
|
248 |
-
# ]
|
249 |
-
# gr.Examples(examples=example_inps, inputs=[prompt, id_image, start_step, guidance, seed, true_cfg],
|
250 |
-
# label='fake CFG')
|
251 |
-
|
252 |
-
# example_inps = [
|
253 |
-
# [
|
254 |
-
# 'portrait, made of ice sculpture',
|
255 |
-
# 'example_inputs/lecun.jpg',
|
256 |
-
# 1, 1, 3811899118709451814, 5
|
257 |
-
# ],
|
258 |
-
# ]
|
259 |
-
# gr.Examples(examples=example_inps, inputs=[prompt, id_image, start_step, guidance, seed, true_cfg],
|
260 |
-
# label='true CFG')
|
261 |
|
262 |
generate_btn.click(
|
263 |
fn=generate_image,
|
|
|
151 |
img = Image.fromarray((127.5 * (x + 1.0)).cpu().byte().numpy())
|
152 |
return img, str(opts.seed), flux_generator.toonmage_model.debug_img_list
|
153 |
|
154 |
+
MARKDOWN = """
|
155 |
+
This demo utilizes <a href="https://huggingface.co/black-forest-labs/FLUX.1-dev">FLUX Pipeline</a> for Image to Image Translation
|
156 |
+
|
157 |
+
**Tips**
|
158 |
+
|
159 |
+
- Smaller value of timestep to start inserting ID would lead to higher fidelity, however, it will reduce the editability; and vice versa.
|
160 |
+
Its value range is from 0 - 4. If you want to generate a stylized scene; use the value of 0 - 1. If you want to generate a photorealistic image; use the value of 4.
|
161 |
+
|
162 |
+
-It is recommended to use fake CFG by setting the true CFG scale value to 1 while you can vary the guidance scale. However, in a few cases, utilizing a true CFG can yield better results.
|
163 |
+
|
164 |
+
Try out with different prompts using your image and do provide your feedback.
|
165 |
+
|
166 |
+
**Demo by [Sunder Ali Khowaja](https://sander-ali.github.io) - [X](https://x.com/SunderAKhowaja) -[Github](https://github.com/sander-ali) -[Hugging Face](https://huggingface.co/SunderAli17)**
|
167 |
+
"""
|
168 |
+
|
169 |
+
theme = gr.themes.Soft(
|
170 |
+
font=[gr.themes.GoogleFont('Source Code Pro'), gr.themes.GoogleFont('Public Sans'), 'system-ui', 'sans-serif'],
|
171 |
+
)
|
172 |
+
js_func = """
|
173 |
+
function refresh() {
|
174 |
+
const url = new URL(window.location);
|
175 |
+
if (url.searchParams.get('__theme') !== 'dark') {
|
176 |
+
url.searchParams.set('__theme', 'dark');
|
177 |
+
window.location.href = url.href;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
"""
|
181 |
|
182 |
|
183 |
def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_available() else "cpu",
|
184 |
offload: bool = False):
|
185 |
+
with gr.Blocks(s = js_func, theme = theme) as demo:
|
186 |
+
gr.Markdown(MARKDOWN)
|
187 |
|
188 |
with gr.Row():
|
189 |
with gr.Column():
|
|
|
213 |
output_image = gr.Image(label="Generated Image")
|
214 |
seed_output = gr.Textbox(label="Used Seed")
|
215 |
intermediate_output = gr.Gallery(label='Output', elem_id="gallery", visible=args.dev)
|
216 |
+
|
217 |
+
|
218 |
+
with gr.Row(), gr.Column():
|
219 |
+
gr.Markdown("## Examples")
|
220 |
+
example_inps = [
|
221 |
+
[
|
222 |
+
'a high quality digital cartoon avatar eating ice cream',
|
223 |
+
'sample_img/image1.png',
|
224 |
+
0, 4, -1, 1
|
225 |
+
],
|
226 |
+
[
|
227 |
+
'a high quality anime character with mountains and lakes in the background',
|
228 |
+
'sample_img/test1.jpg',
|
229 |
+
0, 4, -1, 1
|
230 |
+
],
|
231 |
+
[
|
232 |
+
'a high quality photorealistic image with VR technology atmosphere, revolutionary exceptional magnum with remarkable details',
|
233 |
+
'sample_img/test24.jpg',
|
234 |
+
0, 4, -1, 1
|
235 |
+
]
|
236 |
+
]
|
237 |
+
gr.Examples(examples=example_inps, inputs=[prompt, id_image, start_step, guidance, seed, true_cfg],
|
238 |
+
label='fake CFG')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
generate_btn.click(
|
241 |
fn=generate_image,
|