Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,7 +37,7 @@ controlnet = ControlNetModel.from_pretrained(
|
|
| 37 |
"monster-labs/control_v1p_sd15_qrcode_monster",
|
| 38 |
#"DionTimmer/controlnet_qrcode-control_v1p_sd15",
|
| 39 |
torch_dtype=torch.float16
|
| 40 |
-
).to("
|
| 41 |
|
| 42 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 43 |
"digiplay/GhostMixV1.2VAE",
|
|
@@ -45,7 +45,7 @@ pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
|
| 45 |
controlnet = controlnet,
|
| 46 |
torch_dtype = torch.float16,
|
| 47 |
safety_checker = None,
|
| 48 |
-
).to("
|
| 49 |
#pipe.enable_xformers_memory_efficient_attention()
|
| 50 |
|
| 51 |
|
|
@@ -113,7 +113,20 @@ def scan_qr_code(image):
|
|
| 113 |
def invert_image(image):
|
| 114 |
if image is None:
|
| 115 |
return None
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
@spaces.GPU()
|
| 119 |
def inference(
|
|
|
|
| 37 |
"monster-labs/control_v1p_sd15_qrcode_monster",
|
| 38 |
#"DionTimmer/controlnet_qrcode-control_v1p_sd15",
|
| 39 |
torch_dtype=torch.float16
|
| 40 |
+
).to("mps")
|
| 41 |
|
| 42 |
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
|
| 43 |
"digiplay/GhostMixV1.2VAE",
|
|
|
|
| 45 |
controlnet = controlnet,
|
| 46 |
torch_dtype = torch.float16,
|
| 47 |
safety_checker = None,
|
| 48 |
+
).to("mps")
|
| 49 |
#pipe.enable_xformers_memory_efficient_attention()
|
| 50 |
|
| 51 |
|
|
|
|
| 113 |
def invert_image(image):
|
| 114 |
if image is None:
|
| 115 |
return None
|
| 116 |
+
if isinstance(image, np.ndarray):
|
| 117 |
+
return 255 - image
|
| 118 |
+
elif isinstance(image, Image.Image):
|
| 119 |
+
return ImageOps.invert(image.convert('RGB'))
|
| 120 |
+
else:
|
| 121 |
+
raise ValueError("Unsupported image type")
|
| 122 |
+
|
| 123 |
+
def invert_displayed_image(image):
|
| 124 |
+
if image is None:
|
| 125 |
+
return None
|
| 126 |
+
inverted = invert_image(image)
|
| 127 |
+
if isinstance(inverted, np.ndarray):
|
| 128 |
+
return Image.fromarray(inverted)
|
| 129 |
+
return inverted
|
| 130 |
|
| 131 |
@spaces.GPU()
|
| 132 |
def inference(
|