Spaces:
Build error
Build error
Commit
·
7063992
1
Parent(s):
f4d1ba3
Update app.py
Browse files
app.py
CHANGED
@@ -51,6 +51,7 @@ models = [
|
|
51 |
Model("Spider-Verse", "nitrosocke/spider-verse-diffusion", "spiderverse style "),
|
52 |
Model("Robo Diffusion", "nousr/robo-diffusion"),
|
53 |
Model("U Pron", "stablediffusionapi/urpm", "pron"),
|
|
|
54 |
Model("test", "Jackflack09/mrsrm1", "testing"),
|
55 |
Model("test2", "Jackflack09/mrsrm", "testing2"),
|
56 |
Model("Epic Diffusion", "johnslegers/epic-diffusion")
|
@@ -238,6 +239,31 @@ def img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance
|
|
238 |
|
239 |
# update_state(f"Done. Seed: {seed}")
|
240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
return replace_nsfw_images(result)
|
242 |
|
243 |
def replace_nsfw_images(results):
|
@@ -264,15 +290,6 @@ with gr.Blocks(css="style.css") as demo:
|
|
264 |
<div>
|
265 |
<h1>Finetuned Diffusion</h1>
|
266 |
</div>
|
267 |
-
<p>
|
268 |
-
Demo for multiple fine-tuned Stable Diffusion models, trained on different styles: <br>
|
269 |
-
<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 🤗.
|
270 |
-
</p>
|
271 |
-
<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>
|
272 |
-
Running on <b>{device}</b>{(" in a <b>Google Colab</b>." if is_colab else "")}
|
273 |
-
</p>
|
274 |
-
<p>You can also duplicate this space and upgrade to gpu by going to settings:<br>
|
275 |
-
<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>
|
276 |
</div>
|
277 |
"""
|
278 |
)
|
@@ -308,8 +325,8 @@ with gr.Blocks(css="style.css") as demo:
|
|
308 |
steps = gr.Slider(label="Steps", value=current_steps, minimum=2, maximum=75, step=1)
|
309 |
|
310 |
with gr.Row():
|
311 |
-
width = gr.Slider(label="Width", value=512, minimum=64, maximum=
|
312 |
-
height = gr.Slider(label="Height", value=512, minimum=64, maximum=
|
313 |
|
314 |
seed = gr.Slider(0, 2147483647, label='Seed (0 = random)', value=0, step=1)
|
315 |
|
|
|
51 |
Model("Spider-Verse", "nitrosocke/spider-verse-diffusion", "spiderverse style "),
|
52 |
Model("Robo Diffusion", "nousr/robo-diffusion"),
|
53 |
Model("U Pron", "stablediffusionapi/urpm", "pron"),
|
54 |
+
Model("U Pron2", "lilpotat/urp", "pron2"),
|
55 |
Model("test", "Jackflack09/mrsrm1", "testing"),
|
56 |
Model("test2", "Jackflack09/mrsrm", "testing2"),
|
57 |
Model("Epic Diffusion", "johnslegers/epic-diffusion")
|
|
|
239 |
|
240 |
# update_state(f"Done. Seed: {seed}")
|
241 |
|
242 |
+
# Inpainting function
|
243 |
+
def inpaint(image, mask):
|
244 |
+
# Convert PIL Image to OpenCV format
|
245 |
+
image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
|
246 |
+
mask = cv2.cvtColor(np.array(mask), cv2.COLOR_RGB2BGR)
|
247 |
+
|
248 |
+
# Perform inpainting
|
249 |
+
inpainted = cv2.inpaint(image, mask, 3, cv2.INPAINT_TELEA)
|
250 |
+
|
251 |
+
# Convert back to PIL Image
|
252 |
+
inpainted = Image.fromarray(cv2.cvtColor(inpainted, cv2.COLOR_BGR2RGB))
|
253 |
+
|
254 |
+
return inpainted
|
255 |
+
|
256 |
+
# Gradio interface
|
257 |
+
image = gr.inputs.Image()
|
258 |
+
mask = gr.inputs.Image()
|
259 |
+
|
260 |
+
iface = gr.Interface(
|
261 |
+
fn=inpaint,
|
262 |
+
inputs=[image, mask],
|
263 |
+
outputs="image"
|
264 |
+
)
|
265 |
+
|
266 |
+
iface.launch()
|
267 |
return replace_nsfw_images(result)
|
268 |
|
269 |
def replace_nsfw_images(results):
|
|
|
290 |
<div>
|
291 |
<h1>Finetuned Diffusion</h1>
|
292 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
</div>
|
294 |
"""
|
295 |
)
|
|
|
325 |
steps = gr.Slider(label="Steps", value=current_steps, minimum=2, maximum=75, step=1)
|
326 |
|
327 |
with gr.Row():
|
328 |
+
width = gr.Slider(label="Width", value=512, minimum=64, maximum=2048, step=8)
|
329 |
+
height = gr.Slider(label="Height", value=512, minimum=64, maximum=2048, step=8)
|
330 |
|
331 |
seed = gr.Slider(0, 2147483647, label='Seed (0 = random)', value=0, step=1)
|
332 |
|