Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions download_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def download_file(url, folder_path, filename):
"models/Stable-diffusion",
"epicrealism_naturalSinRC1VAE.safetensors"
)
download_file(
"https://civitai.com/api/download/models/429454?type=Model&format=SafeTensor&size=pruned&fp=fp16",
"models/Stable-diffusion",
"epicphotogasm_ultimateFidelity.safetensors"
)

# Upscaler Model
download_file(
Expand Down Expand Up @@ -74,6 +79,17 @@ def download_file(url, folder_path, filename):
"models/Lora",
"more_details.safetensors"
)
download_file(
"https://civitai.com/api/download/models/174461?type=Model&format=SafeTensor",
"models/Lora",
"filmgrain_slider_v1.safetensors"
)

download_file(
"https://civitai.com/api/download/models/76092?type=Model&format=SafeTensor",
"models/Lora",
"add_sharpness.safetensors"
)

# Controlnet models
download_file(
Expand Down
2 changes: 2 additions & 0 deletions modules/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,8 @@ def init(self, all_prompts, all_seeds, all_subseeds):

if image_mask is not None:
image_masked = Image.new('RGBa', (image.width, image.height))
if self.mask_for_overlay.size != image.size:
self.mask_for_overlay = self.mask_for_overlay.resize(image.size).convert('L')
image_masked.paste(image.convert("RGBA").convert("RGBa"), mask=ImageOps.invert(self.mask_for_overlay.convert('L')))

self.overlay_images.append(image_masked.convert('RGBA'))
Expand Down
39 changes: 22 additions & 17 deletions predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def predict(
),
sd_model: str = Input(
description="Stable Diffusion model checkpoint",
choices=['epicrealism_naturalSinRC1VAE.safetensors [84d76a0328]', 'juggernaut_reborn.safetensors [338b85bc4f]', 'flat2DAnimerge_v45Sharp.safetensors'],
choices=['epicrealism_naturalSinRC1VAE.safetensors [84d76a0328]', 'juggernaut_reborn.safetensors [338b85bc4f]', 'flat2DAnimerge_v45Sharp.safetensors', 'epicphotogasm_ultimateFidelity.safetensors'],
default="juggernaut_reborn.safetensors [338b85bc4f]",
),
scheduler: str = Input(
Expand All @@ -227,7 +227,7 @@ def predict(
description="Number of denoising steps", ge=1, le=100, default=18
),
seed: int = Input(
description="Random seed. Leave blank to randomize the seed", default=1337
description="Random seed. Leave blank to randomize the seed", default=None
),
downscaling: bool = Input(
description="Downscale the image before upscaling. Can improve quality and speed for images with high resolution but lower quality", default=False
Expand Down Expand Up @@ -296,23 +296,28 @@ def predict(

if downscaling:
image_np_array = np.frombuffer(binary_image_data, dtype=np.uint8)

image = cv2.imdecode(image_np_array, cv2.IMREAD_UNCHANGED)

height, width = image.shape[:2]

if height > width:
scaling_factor = downscaling_resolution / float(height)
else:
scaling_factor = downscaling_resolution / float(width)

new_width = int(width * scaling_factor)
new_height = int(height * scaling_factor)

resized_image = cv2.resize(image, (new_width, new_height))

_, binary_resized_image = cv2.imencode('.jpg', resized_image)
binary_image_data = binary_resized_image.tobytes()

# Determine the larger side of the image
largest_side = max(height, width)

# Only perform downscaling if the downscaling resolution is smaller than the largest side
if downscaling_resolution < largest_side:
if height > width:
scaling_factor = downscaling_resolution / float(height)
else:
scaling_factor = downscaling_resolution / float(width)

new_width = int(width * scaling_factor)
new_height = int(height * scaling_factor)

resized_image = cv2.resize(image, (new_width, new_height))

_, binary_resized_image = cv2.imencode('.jpg', resized_image)
binary_image_data = binary_resized_image.tobytes()

if handfix == "hands_only":
print("Trying to fix hands")
Expand Down