karthi12334r5 commited on
Commit
1265cca
·
verified ·
1 Parent(s): f98d1c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
3
+ import torch
4
+
5
+ controlnet = ControlNetModel.from_pretrained(
6
+ "lllyasviel/control_v11p_sd15_openpose", torch_dtype=torch.float16
7
+ )
8
+
9
+ pipe = StableDiffusionControlNetPipeline.from_pretrained(
10
+ "runwayml/stable-diffusion-v1-5",
11
+ controlnet=controlnet,
12
+ torch_dtype=torch.float16,
13
+ safety_checker=None
14
+ ).to("cuda")
15
+
16
+ pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
17
+
18
+ def generate(image, prompt="a person posing"):
19
+ result = pipe(prompt=prompt, image=image, num_inference_steps=20).images[0]
20
+ return result
21
+
22
+ demo = gr.Interface(fn=generate, inputs=[gr.Image(type="pil"), gr.Textbox()], outputs="image")
23
+ demo.launch()