Upload folder using huggingface_hub
Browse files- inference.py +2 -1
- internals/pipelines/sdxl_tile_upscale.py +16 -6
inference.py
CHANGED
|
@@ -159,6 +159,7 @@ def tile_upscale(task: Task):
|
|
| 159 |
negative_prompt=task.get_negative_prompt(),
|
| 160 |
width=task.get_width(),
|
| 161 |
height=task.get_height(),
|
|
|
|
| 162 |
)
|
| 163 |
|
| 164 |
lora_patcher.cleanup()
|
|
@@ -600,7 +601,7 @@ def load_model_by_task(task: Task):
|
|
| 600 |
else:
|
| 601 |
if task.get_type() == TaskType.TILE_UPSCALE:
|
| 602 |
if get_is_sdxl():
|
| 603 |
-
sdxl_tileupscaler.create(text2img_pipe)
|
| 604 |
else:
|
| 605 |
controlnet.load_model("tile_upscaler")
|
| 606 |
elif task.get_type() == TaskType.CANNY:
|
|
|
|
| 159 |
negative_prompt=task.get_negative_prompt(),
|
| 160 |
width=task.get_width(),
|
| 161 |
height=task.get_height(),
|
| 162 |
+
model_id=task.get_model_id(),
|
| 163 |
)
|
| 164 |
|
| 165 |
lora_patcher.cleanup()
|
|
|
|
| 601 |
else:
|
| 602 |
if task.get_type() == TaskType.TILE_UPSCALE:
|
| 603 |
if get_is_sdxl():
|
| 604 |
+
sdxl_tileupscaler.create(text2img_pipe, task.get_model_id())
|
| 605 |
else:
|
| 606 |
controlnet.load_model("tile_upscaler")
|
| 607 |
elif task.get_type() == TaskType.CANNY:
|
internals/pipelines/sdxl_tile_upscale.py
CHANGED
|
@@ -15,10 +15,15 @@ controlnet = ControlNet()
|
|
| 15 |
|
| 16 |
|
| 17 |
class SDXLTileUpscaler(AbstractPipeline):
|
| 18 |
-
def create(self, pipeline: Text2Img):
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
)
|
|
|
|
|
|
|
| 22 |
pipe = DemoFusionSDXLControlNetPipeline(
|
| 23 |
**pipeline.pipe.components, controlnet=controlnet
|
| 24 |
)
|
|
@@ -37,12 +42,17 @@ class SDXLTileUpscaler(AbstractPipeline):
|
|
| 37 |
negative_prompt: str,
|
| 38 |
width: int,
|
| 39 |
height: int,
|
|
|
|
| 40 |
):
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
img = download_image(imageUrl).resize((width, height))
|
| 43 |
|
| 44 |
img = ImageUtils.resize_image(img, get_base_dimension())
|
| 45 |
-
|
| 46 |
|
| 47 |
img2 = self.__resize_for_condition_image(img, resize_dimension)
|
| 48 |
|
|
@@ -51,7 +61,7 @@ class SDXLTileUpscaler(AbstractPipeline):
|
|
| 51 |
images = self.pipe.__call__(
|
| 52 |
image_lr=image_lr,
|
| 53 |
prompt=prompt,
|
| 54 |
-
condition_image=
|
| 55 |
negative_prompt="blurry, ugly, duplicate, poorly drawn, deformed, mosaic",
|
| 56 |
guidance_scale=11,
|
| 57 |
sigma=0.8,
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
class SDXLTileUpscaler(AbstractPipeline):
|
| 18 |
+
def create(self, pipeline: Text2Img, model_id: int):
|
| 19 |
+
# temporal hack for upscale model till multicontrolnet support is added
|
| 20 |
+
model = (
|
| 21 |
+
"thibaud/controlnet-openpose-sdxl-1.0"
|
| 22 |
+
if int(model_id) == 2000293
|
| 23 |
+
else "diffusers/controlnet-canny-sdxl-1.0"
|
| 24 |
)
|
| 25 |
+
|
| 26 |
+
controlnet = ControlNetModel.from_pretrained(model, torch_dtype=torch.float16)
|
| 27 |
pipe = DemoFusionSDXLControlNetPipeline(
|
| 28 |
**pipeline.pipe.components, controlnet=controlnet
|
| 29 |
)
|
|
|
|
| 42 |
negative_prompt: str,
|
| 43 |
width: int,
|
| 44 |
height: int,
|
| 45 |
+
model_id: int,
|
| 46 |
):
|
| 47 |
+
if int(model_id) == 2000293:
|
| 48 |
+
condition_image = controlnet.detect_pose(imageUrl)
|
| 49 |
+
else:
|
| 50 |
+
condition_image = download_image(imageUrl)
|
| 51 |
+
condition_image = ControlNet.canny_detect_edge(condition_image)
|
| 52 |
img = download_image(imageUrl).resize((width, height))
|
| 53 |
|
| 54 |
img = ImageUtils.resize_image(img, get_base_dimension())
|
| 55 |
+
condition_image = condition_image.resize(img.size)
|
| 56 |
|
| 57 |
img2 = self.__resize_for_condition_image(img, resize_dimension)
|
| 58 |
|
|
|
|
| 61 |
images = self.pipe.__call__(
|
| 62 |
image_lr=image_lr,
|
| 63 |
prompt=prompt,
|
| 64 |
+
condition_image=condition_image,
|
| 65 |
negative_prompt="blurry, ugly, duplicate, poorly drawn, deformed, mosaic",
|
| 66 |
guidance_scale=11,
|
| 67 |
sigma=0.8,
|