Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,14 +108,14 @@ async def generate_new_img(hex_code: str, prompt: str = Query(..., description="
|
|
| 108 |
Then from the initial image create a new image that will attract customers to put in an (ad template)
|
| 109 |
Also, use this RGB color {hex_to_rgb(hex_code)} as a tone in the image while image is still recognized as it is original."""
|
| 110 |
if device=="cpu":
|
| 111 |
-
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11f1p_sd15_depth", torch_dtype=torch.float32
|
| 112 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 113 |
-
"runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float32
|
| 114 |
).to(device)
|
| 115 |
else:
|
| 116 |
-
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11f1p_sd15_depth", torch_dtype=torch.float16
|
| 117 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 118 |
-
"runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16
|
| 119 |
).to(device)
|
| 120 |
pipe.enable_model_cpu_offload()
|
| 121 |
|
|
@@ -132,6 +132,7 @@ async def generate_new_img(hex_code: str, prompt: str = Query(..., description="
|
|
| 132 |
image = pipe(
|
| 133 |
ad_prompt, image=init_image
|
| 134 |
).images[0]
|
|
|
|
| 135 |
|
| 136 |
print("Image created")
|
| 137 |
image_data = io.BytesIO()
|
|
|
|
| 108 |
Then from the initial image create a new image that will attract customers to put in an (ad template)
|
| 109 |
Also, use this RGB color {hex_to_rgb(hex_code)} as a tone in the image while image is still recognized as it is original."""
|
| 110 |
if device=="cpu":
|
| 111 |
+
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11f1p_sd15_depth", torch_dtype=torch.float32)
|
| 112 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 113 |
+
"runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float32
|
| 114 |
).to(device)
|
| 115 |
else:
|
| 116 |
+
controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11f1p_sd15_depth", torch_dtype=torch.float16)
|
| 117 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 118 |
+
"runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16
|
| 119 |
).to(device)
|
| 120 |
pipe.enable_model_cpu_offload()
|
| 121 |
|
|
|
|
| 132 |
image = pipe(
|
| 133 |
ad_prompt, image=init_image
|
| 134 |
).images[0]
|
| 135 |
+
print(f"image type: {type(image)}")
|
| 136 |
|
| 137 |
print("Image created")
|
| 138 |
image_data = io.BytesIO()
|