Spaces:
Sleeping
Sleeping
Upload zerogpu_controller.py
Browse files- sd/zerogpu_controller.py +10 -0
sd/zerogpu_controller.py
CHANGED
@@ -34,6 +34,8 @@ def get_first_result(img, prompt, negative_prompt,
|
|
34 |
substrate, resized_image = sketch_process(img)
|
35 |
prompt=prompt_preprocess(prompt)
|
36 |
|
|
|
|
|
37 |
result=FIRST_PIPE(image=substrate,
|
38 |
control_image=resized_image,
|
39 |
strength=strength,
|
@@ -44,6 +46,8 @@ def get_first_result(img, prompt, negative_prompt,
|
|
44 |
num_inference_steps=n_steps,
|
45 |
eta=eta)
|
46 |
|
|
|
|
|
47 |
return result.images[0]
|
48 |
|
49 |
|
@@ -52,6 +56,9 @@ def get_second_result(img, prompt, negative_prompt,
|
|
52 |
g_scale=7.5, n_steps=25,
|
53 |
adapter_scale=0.9, adapter_factor=1.0):
|
54 |
|
|
|
|
|
|
|
55 |
preprocessed_img=DETECTOR(img,
|
56 |
detect_resolution=1024,
|
57 |
image_resolution=1024,
|
@@ -66,6 +73,9 @@ def get_second_result(img, prompt, negative_prompt,
|
|
66 |
adapter_conditioning_factor=adapter_factor,
|
67 |
generator = torch.manual_seed(42))
|
68 |
|
|
|
|
|
|
|
69 |
return result.images[0]
|
70 |
|
71 |
|
|
|
34 |
substrate, resized_image = sketch_process(img)
|
35 |
prompt=prompt_preprocess(prompt)
|
36 |
|
37 |
+
FIRST_PIPE.to('cuda')
|
38 |
+
|
39 |
result=FIRST_PIPE(image=substrate,
|
40 |
control_image=resized_image,
|
41 |
strength=strength,
|
|
|
46 |
num_inference_steps=n_steps,
|
47 |
eta=eta)
|
48 |
|
49 |
+
FIRST_PIPE.to('cpu')
|
50 |
+
|
51 |
return result.images[0]
|
52 |
|
53 |
|
|
|
56 |
g_scale=7.5, n_steps=25,
|
57 |
adapter_scale=0.9, adapter_factor=1.0):
|
58 |
|
59 |
+
DETECTOR.to('cuda')
|
60 |
+
SECOND_PIPE.to('cuda')
|
61 |
+
|
62 |
preprocessed_img=DETECTOR(img,
|
63 |
detect_resolution=1024,
|
64 |
image_resolution=1024,
|
|
|
73 |
adapter_conditioning_factor=adapter_factor,
|
74 |
generator = torch.manual_seed(42))
|
75 |
|
76 |
+
DETECTOR.to('cpu')
|
77 |
+
SECOND_PIPE.to('cpu')
|
78 |
+
|
79 |
return result.images[0]
|
80 |
|
81 |
|