Spaces:
Sleeping
Sleeping
datt30
commited on
Commit
·
d161d18
1
Parent(s):
9c0e205
changes to torch dtype and CPU support only
Browse files- app.py +1 -0
- geo_painting.py +3 -3
app.py
CHANGED
@@ -4,6 +4,7 @@ from geo_painting import GeoPainting
|
|
4 |
|
5 |
def generate_image(input_promp, control_image):
|
6 |
new_geo_painting = GeoPainting()
|
|
|
7 |
print(type(control_image))
|
8 |
return new_geo_painting.generate_painting(input_promp, control_image)
|
9 |
|
|
|
4 |
|
5 |
def generate_image(input_promp, control_image):
|
6 |
new_geo_painting = GeoPainting()
|
7 |
+
print("::::::::::generate_image:::::::::::::")
|
8 |
print(type(control_image))
|
9 |
return new_geo_painting.generate_painting(input_promp, control_image)
|
10 |
|
geo_painting.py
CHANGED
@@ -13,18 +13,18 @@ class GeoPainting:
|
|
13 |
DEFAULT_DIFFUSER_MODEL = "geospatial_diffuser"
|
14 |
|
15 |
def __init__(self, controlnet_model_path=DEFAULT_CONTROLNET_MODEL, diffuser_model=DEFAULT_DIFFUSER_MODEL):
|
16 |
-
self.controlnet = ControlNetModel.from_pretrained(controlnet_model_path, torch_dtype=torch.
|
17 |
self.generator = torch.Generator(device="cpu").manual_seed(2)
|
18 |
self.pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
19 |
diffuser_model,
|
20 |
low_cpu_mem_usage=False,
|
21 |
device_map=None,
|
22 |
controlnet=self.controlnet,
|
23 |
-
torch_dtype=torch.
|
24 |
)
|
25 |
self.pipe.scheduler = UniPCMultistepScheduler.from_config(self.pipe.scheduler.config)
|
26 |
-
self.pipe.enable_model_cpu_offload()
|
27 |
if torch.cuda.is_available():
|
|
|
28 |
self.pipe.enable_xformers_memory_efficient_attention()
|
29 |
|
30 |
def generate_painting(self, input_promp, control_image):
|
|
|
13 |
DEFAULT_DIFFUSER_MODEL = "geospatial_diffuser"
|
14 |
|
15 |
def __init__(self, controlnet_model_path=DEFAULT_CONTROLNET_MODEL, diffuser_model=DEFAULT_DIFFUSER_MODEL):
|
16 |
+
self.controlnet = ControlNetModel.from_pretrained(controlnet_model_path, torch_dtype=torch.float32)
|
17 |
self.generator = torch.Generator(device="cpu").manual_seed(2)
|
18 |
self.pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
19 |
diffuser_model,
|
20 |
low_cpu_mem_usage=False,
|
21 |
device_map=None,
|
22 |
controlnet=self.controlnet,
|
23 |
+
torch_dtype=torch.float32
|
24 |
)
|
25 |
self.pipe.scheduler = UniPCMultistepScheduler.from_config(self.pipe.scheduler.config)
|
|
|
26 |
if torch.cuda.is_available():
|
27 |
+
self.pipe.enable_model_cpu_offload()
|
28 |
self.pipe.enable_xformers_memory_efficient_attention()
|
29 |
|
30 |
def generate_painting(self, input_promp, control_image):
|