angtrim commited on
Commit
0d259be
1 Parent(s): 40c6354

controlnet

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -4,7 +4,7 @@ import numpy as np
4
  import modin.pandas as pd
5
  from PIL import Image
6
  from diffusers import DiffusionPipeline
7
- from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
8
 
9
 
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -13,6 +13,8 @@ controlnet = ControlNetModel.from_pretrained("CrucibleAI/ControlNetMediaPipeFace
13
  pipe = StableDiffusionControlNetPipeline.from_pretrained(
14
  "krnl/venereital-IA-23", controlnet=controlnet, torch_dtype=torch.float16
15
  ).to("cuda")
 
 
16
 
17
 
18
 
@@ -21,7 +23,8 @@ def genie (prompt, negative_prompt):
21
  generator = torch.Generator(device=device)
22
  prompt = "photo of sks person, " + prompt
23
  centered = Image.open("centered.png").convert("RGB")
24
- images = pipe(prompt, controlnet_conditioning_scale=0.99, image=centered, negative_prompt=negative_prompt, width=512, height=512, num_inference_steps=20, guidance_scale=3.5, num_images_per_prompt=1).images[0]
25
  return images
26
-
27
- gr.Interface(fn=genie, inputs=[gr.Textbox(label='Descrivi la tua venere ideale (IN ENGLISH) ex: wearing sunglasses'), gr.Textbox(label='Descrivi cosa non vorresti vedere, (IN ENGLISH) ex: wearing hat')], outputs='image', title="Generatore di Venere", description="Genera la tua Venere! Scatena la tua fantsIA!").launch(debug=True, max_threads=True)
 
 
4
  import modin.pandas as pd
5
  from PIL import Image
6
  from diffusers import DiffusionPipeline
7
+ from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
8
 
9
 
10
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
13
  pipe = StableDiffusionControlNetPipeline.from_pretrained(
14
  "krnl/venereital-IA-23", controlnet=controlnet, torch_dtype=torch.float16
15
  ).to("cuda")
16
+ pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
17
+
18
 
19
 
20
 
 
23
  generator = torch.Generator(device=device)
24
  prompt = "photo of sks person, " + prompt
25
  centered = Image.open("centered.png").convert("RGB")
26
+ images = pipe(prompt, controlnet_conditioning_scale=0.99, image=centered, negative_prompt=negative_prompt, width=512, height=512, num_inference_steps=18, guidance_scale=3.5, num_images_per_prompt=1).images[0]
27
  return images
28
+
29
+ desc = "Questo progetto è solo un PoC, sviluppato in circa 3 ore di lavoro. A volte la generazione non funziona, a volte funziona male, a volte funziona davvero bene. (Decliniamo ogni responsabilità per danni a persone, cose, o animali.)"
30
+ gr.Interface(fn=genie, inputs=[gr.Textbox(label='Descrivi la tua venere ideale (IN ENGLISH) ex: wearing sunglasses'), gr.Textbox(label='Descrivi cosa non vorresti vedere, (IN ENGLISH) ex: wearing hat')], outputs='image', title="Generatore di Venere", description=desc).launch(debug=True, max_threads=True)