Rooni commited on
Commit
8e12618
·
1 Parent(s): 15a879b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -6
app.py CHANGED
@@ -180,7 +180,7 @@ def txt_to_img(model_path, prompt, n_images, neg_prompt, guidance, steps, width,
180
 
181
  # update_state(f"Done. Seed: {seed}")
182
 
183
- return get_images(result)
184
 
185
  def img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance, steps, width, height, generator, seed):
186
 
@@ -233,7 +233,7 @@ def img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance
233
 
234
  # update_state(f"Done. Seed: {seed}")
235
 
236
- return get_images(result)
237
 
238
  def replace_nsfw_images(results):
239
 
@@ -245,12 +245,27 @@ def replace_nsfw_images(results):
245
  results.images[i] = Image.open("nsfw.png")
246
  return results.images
247
 
248
- def get_images(results):
249
- return results.images
250
-
251
  # css = """.finetuned-diffusion-div div{display:inline-flex;align-items:center;gap:.8rem;font-size:1.75rem}.finetuned-diffusion-div div h1{font-weight:900;margin-bottom:7px}.finetuned-diffusion-div p{margin-bottom:10px;font-size:94%}a{text-decoration:underline}.tabs{margin-top:0;margin-bottom:0}#gallery{min-height:20rem}
252
  # """
253
  with gr.Blocks(css="style.css") as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  with gr.Row():
255
 
256
  with gr.Column(scale=55):
@@ -274,7 +289,7 @@ with gr.Blocks(css="style.css") as demo:
274
  with gr.Column(scale=45):
275
  with gr.Tab("Options"):
276
  with gr.Group():
277
- neg_prompt = gr.Textbox(label="Negative prompt", placeholder="What to exclude from the image", value="[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry")
278
 
279
  n_images = gr.Slider(label="Images", value=1, minimum=1, maximum=4, step=1)
280
 
@@ -312,6 +327,18 @@ with gr.Blocks(css="style.css") as demo:
312
  [models[5].name, "fantasy portrait painting, digital art", 4.0, 20],
313
  ], inputs=[model_name, prompt, guidance, steps], outputs=outputs, fn=inference, cache_examples=False)
314
 
 
 
 
 
 
 
 
 
 
 
 
 
315
 
316
  demo.load(update_state_info, inputs=state_info, outputs=state_info, every=0.5, show_progress=False)
317
 
 
180
 
181
  # update_state(f"Done. Seed: {seed}")
182
 
183
+ return replace_nsfw_images(result)
184
 
185
  def img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance, steps, width, height, generator, seed):
186
 
 
233
 
234
  # update_state(f"Done. Seed: {seed}")
235
 
236
+ return replace_nsfw_images(result)
237
 
238
  def replace_nsfw_images(results):
239
 
 
245
  results.images[i] = Image.open("nsfw.png")
246
  return results.images
247
 
 
 
 
248
  # css = """.finetuned-diffusion-div div{display:inline-flex;align-items:center;gap:.8rem;font-size:1.75rem}.finetuned-diffusion-div div h1{font-weight:900;margin-bottom:7px}.finetuned-diffusion-div p{margin-bottom:10px;font-size:94%}a{text-decoration:underline}.tabs{margin-top:0;margin-bottom:0}#gallery{min-height:20rem}
249
  # """
250
  with gr.Blocks(css="style.css") as demo:
251
+ gr.HTML(
252
+ f"""
253
+ <div class="finetuned-diffusion-div">
254
+ <div>
255
+ <h1>Finetuned Diffusion</h1>
256
+ </div>
257
+ <p>
258
+ Demo for multiple fine-tuned Stable Diffusion models, trained on different styles: <br>
259
+ <a href="https://huggingface.co/nitrosocke/Arcane-Diffusion">Arcane</a>, <a href="https://huggingface.co/nitrosocke/archer-diffusion">Archer</a>, <a href="https://huggingface.co/nitrosocke/elden-ring-diffusion">Elden Ring</a>, <a href="https://huggingface.co/nitrosocke/spider-verse-diffusion">Spider-Verse</a>, <a href="https://huggingface.co/nitrosocke/mo-di-diffusion">Modern Disney</a>, <a href="https://huggingface.co/nitrosocke/classic-anim-diffusion">Classic Disney</a>, <a href="https://huggingface.co/dallinmackay/Van-Gogh-diffusion">Loving Vincent (Van Gogh)</a>, <a href="https://huggingface.co/nitrosocke/redshift-diffusion">Redshift renderer (Cinema4D)</a>, <a href="https://huggingface.co/prompthero/midjourney-v4-diffusion">Midjourney v4 style</a>, <a href="https://huggingface.co/hakurei/waifu-diffusion">Waifu</a>, <a href="https://huggingface.co/lambdalabs/sd-pokemon-diffusers">Pokémon</a>, <a href="https://huggingface.co/AstraliteHeart/pony-diffusion">Pony Diffusion</a>, <a href="https://huggingface.co/nousr/robo-diffusion">Robo Diffusion</a>, <a href="https://huggingface.co/DGSpitzer/Cyberpunk-Anime-Diffusion">Cyberpunk Anime</a>, <a href="https://huggingface.co/dallinmackay/Tron-Legacy-diffusion">Tron Legacy</a>, <a href="https://huggingface.co/Fictiverse/Stable_Diffusion_BalloonArt_Model">Balloon Art</a> + in colab notebook you can load any other Diffusers 🧨 SD model hosted on HuggingFace 🤗.
260
+ </p>
261
+ <p>You can skip the queue and load custom models in the colab: <a href="https://colab.research.google.com/gist/qunash/42112fb104509c24fd3aa6d1c11dd6e0/copy-of-fine-tuned-diffusion-gradio.ipynb"><img data-canonical-src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab" src="https://camo.githubusercontent.com/84f0493939e0c4de4e6dbe113251b4bfb5353e57134ffd9fcab6b8714514d4d1/68747470733a2f2f636f6c61622e72657365617263682e676f6f676c652e636f6d2f6173736574732f636f6c61622d62616467652e737667"></a></p>
262
+ Running on <b>{device}</b>{(" in a <b>Google Colab</b>." if is_colab else "")}
263
+ </p>
264
+ <p>You can also duplicate this space and upgrade to gpu by going to settings:<br>
265
+ <a style="display:inline-block" href="https://huggingface.co/spaces/anzorq/finetuned_diffusion?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>
266
+ </div>
267
+ """
268
+ )
269
  with gr.Row():
270
 
271
  with gr.Column(scale=55):
 
289
  with gr.Column(scale=45):
290
  with gr.Tab("Options"):
291
  with gr.Group():
292
+ neg_prompt = gr.Textbox(label="Negative prompt", placeholder="What to exclude from the image")
293
 
294
  n_images = gr.Slider(label="Images", value=1, minimum=1, maximum=4, step=1)
295
 
 
327
  [models[5].name, "fantasy portrait painting, digital art", 4.0, 20],
328
  ], inputs=[model_name, prompt, guidance, steps], outputs=outputs, fn=inference, cache_examples=False)
329
 
330
+ gr.HTML("""
331
+ <div style="border-top: 1px solid #303030;">
332
+ <br>
333
+ <p>Models by <a href="https://huggingface.co/nitrosocke">@nitrosocke</a>, <a href="https://twitter.com/haruu1367">@haruu1367</a>, <a href="https://twitter.com/DGSpitzer">@Helixngc7293</a>, <a href="https://twitter.com/dal_mack">@dal_mack</a>, <a href="https://twitter.com/prompthero">@prompthero</a> and others. ❤️</p>
334
+ <p>This space uses the <a href="https://github.com/LuChengTHU/dpm-solver">DPM-Solver++</a> sampler by <a href="https://arxiv.org/abs/2206.00927">Cheng Lu, et al.</a>.</p>
335
+ <p>Space by:<br>
336
+ <a href="https://twitter.com/hahahahohohe"><img src="https://img.shields.io/twitter/follow/hahahahohohe?label=%40anzorq&style=social" alt="Twitter Follow"></a><br>
337
+ <a href="https://github.com/qunash"><img alt="GitHub followers" src="https://img.shields.io/github/followers/qunash?style=social" alt="Github Follow"></a></p><br><br>
338
+ <a href="https://www.buymeacoffee.com/anzorq" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 45px !important;width: 162px !important;" ></a><br><br>
339
+ <p><img src="https://visitor-badge.glitch.me/badge?page_id=anzorq.finetuned_diffusion" alt="visitors"></p>
340
+ </div>
341
+ """)
342
 
343
  demo.load(update_state_info, inputs=state_info, outputs=state_info, every=0.5, show_progress=False)
344