Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,17 +11,42 @@ openpose = OpenposeDetector.from_pretrained('lllyasviel/ControlNet')
|
|
| 11 |
controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-openpose", torch_dtype=torch.float16)
|
| 12 |
pipe = StableDiffusionControlNetPipeline.from_pretrained("helkoo/jelaba_2HR", controlnet=controlnet, safety_checker=None, torch_dtype=torch.float16)
|
| 13 |
|
| 14 |
-
|
| 15 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
| 16 |
-
pipe.enable_xformers_memory_efficient_attention()
|
| 17 |
-
pipe.enable_model_cpu_offload()
|
| 18 |
-
|
| 19 |
|
| 20 |
def generate(image,prompt):
|
| 21 |
image = openpose(image)
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
image = pipe(prompt, image, num_inference_steps=20).images[0]
|
| 24 |
return image
|
| 25 |
|
| 26 |
-
gr.Interface(fn=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
|
|
|
| 11 |
controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-openpose", torch_dtype=torch.float16)
|
| 12 |
pipe = StableDiffusionControlNetPipeline.from_pretrained("helkoo/jelaba_2HR", controlnet=controlnet, safety_checker=None, torch_dtype=torch.float16)
|
| 13 |
|
| 14 |
+
#optimizations
|
| 15 |
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
| 16 |
+
#pipe.enable_xformers_memory_efficient_attention()
|
| 17 |
+
#pipe.enable_model_cpu_offload()
|
| 18 |
+
pipe = pipe.to("cuda")
|
| 19 |
|
| 20 |
def generate(image,prompt):
|
| 21 |
image = openpose(image)
|
| 22 |
+
#image = image
|
| 23 |
+
image = pipe(prompt, image, num_inference_steps=20).images[0]
|
| 24 |
+
return image
|
| 25 |
+
|
| 26 |
+
gr.Interface(fn=generate, inputs=["image","text"], outputs="image").launch(share=True, debug=True)
|
| 27 |
+
|
| 28 |
+
import numpy as np
|
| 29 |
+
import requests
|
| 30 |
+
def generate2(prompt,taille):
|
| 31 |
+
if taille == "S":
|
| 32 |
+
image = Image.open(requests.get('https://mode-et-caftan.com/757-large_default/jellaba-salsa-marocaine-femme.jpg', stream=True).raw)
|
| 33 |
+
|
| 34 |
+
if taille == "XL":
|
| 35 |
+
image = Image.open(requests.get('https://i.pinimg.com/236x/03/f1/36/03f136b83bb37c9f17c3764f1b36f9fa--big-is-beautiful-curvy-fashion.jpg', stream=True).raw)
|
| 36 |
+
|
| 37 |
+
if taille == "L":
|
| 38 |
+
image = Image.open(requests.get('https://mode-et-caftan.com/757-large_default/jellaba-salsa-marocaine-femme.jpg', stream=True).raw)
|
| 39 |
+
|
| 40 |
+
# convert image to numpy array
|
| 41 |
+
image = np.array(image)
|
| 42 |
+
image = openpose(image)
|
| 43 |
+
#image = image
|
| 44 |
image = pipe(prompt, image, num_inference_steps=20).images[0]
|
| 45 |
return image
|
| 46 |
|
| 47 |
+
gr.Interface(fn=generate2, inputs=["text",
|
| 48 |
+
gr.Dropdown(
|
| 49 |
+
["S", "L", "XL"], label="taille", info="choisie la taille"
|
| 50 |
+
),
|
| 51 |
+
], outputs="image").launch(share=True, debug=True)
|
| 52 |
|