Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,20 +30,26 @@ high_threshold = 200
|
|
30 |
# Generator seed,
|
31 |
generator = torch.manual_seed(0)
|
32 |
|
|
|
|
|
33 |
pose_model = OpenposeDetector.from_pretrained("lllyasviel/ControlNet")
|
|
|
34 |
controlnet_pose = ControlNetModel.from_pretrained(
|
35 |
-
"lllyasviel/sd-controlnet-openpose", torch_dtype=
|
36 |
-
)
|
|
|
37 |
pipe_pose = StableDiffusionControlNetPipeline.from_pretrained(
|
38 |
-
"runwayml/stable-diffusion-v1-5",
|
|
|
|
|
|
|
39 |
)
|
|
|
40 |
pipe_pose.scheduler = UniPCMultistepScheduler.from_config(pipe_pose.scheduler.config)
|
41 |
|
42 |
-
# This command loads the individual model components on GPU on-demand. So, we don't
|
43 |
-
# need to explicitly call pipe.to("cuda").
|
44 |
pipe_pose.enable_model_cpu_offload()
|
45 |
|
46 |
-
# xformers
|
47 |
pipe_pose.enable_xformers_memory_efficient_attention()
|
48 |
|
49 |
|
|
|
30 |
# Generator seed,
|
31 |
generator = torch.manual_seed(0)
|
32 |
|
33 |
+
torch_dtype = torch.float16 # or torch.bfloat16 (if needed)
|
34 |
+
|
35 |
pose_model = OpenposeDetector.from_pretrained("lllyasviel/ControlNet")
|
36 |
+
|
37 |
controlnet_pose = ControlNetModel.from_pretrained(
|
38 |
+
"lllyasviel/sd-controlnet-openpose", torch_dtype=torch_dtype
|
39 |
+
).to("cuda") # Load it directly on GPU
|
40 |
+
|
41 |
pipe_pose = StableDiffusionControlNetPipeline.from_pretrained(
|
42 |
+
"runwayml/stable-diffusion-v1-5",
|
43 |
+
controlnet=controlnet_pose,
|
44 |
+
safety_checker=None,
|
45 |
+
torch_dtype=torch_dtype
|
46 |
)
|
47 |
+
|
48 |
pipe_pose.scheduler = UniPCMultistepScheduler.from_config(pipe_pose.scheduler.config)
|
49 |
|
|
|
|
|
50 |
pipe_pose.enable_model_cpu_offload()
|
51 |
|
52 |
+
# ✅ Enable xformers (Optimizes memory usage)
|
53 |
pipe_pose.enable_xformers_memory_efficient_attention()
|
54 |
|
55 |
|