Skip to content

Commit

Permalink
Merge pull request #93 from Haidra-Org/main
Browse files Browse the repository at this point in the history
feat: use latest comfyui (as of Nov 10, 2023)
  • Loading branch information
tazlin authored Nov 10, 2023
2 parents c0f275e + 9f3c92c commit 4efaf87
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion hordelib/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from hordelib.config_path import get_hordelib_path

COMFYUI_VERSION = "dd116abfc48e8023bb425c2dd5bd954ee99d7a9c"
COMFYUI_VERSION = "3e0033ef30a111076af54a7a4e6b470cdc570886"
"""The exact version of ComfyUI version to load."""

REMOTE_PROXY = ""
Expand Down
6 changes: 4 additions & 2 deletions hordelib/model_manager/lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ def _download_thread(self, thread_number):
response = requests.get(lora["url"], timeout=self.REQUEST_DOWNLOAD_TIMEOUT)
response.raise_for_status()
if "reason=download-auth" in response.url:
logger.error(f"Error downloading {lora['filename']}. CivitAI appears to be redirecting us to a login page. Aborting")
logger.error(
f"Error downloading {lora['filename']}. CivitAI appears to be redirecting us to a login page. Aborting"
)
break
# Check the data hash
hash_object = hashlib.sha256()
Expand Down Expand Up @@ -567,7 +569,7 @@ def find_lora_trigger(self, model_name: str, trigger_search: str):

def save_cached_reference_to_disk(self):
with open(self.models_db_path, "w", encoding="utf-8", errors="ignore") as outfile:
outfile.write(json.dumps(self.model_reference, indent=4))
outfile.write(json.dumps(self.model_reference.copy(), indent=4))

def calculate_downloaded_loras(self, mode=DOWNLOAD_SIZE_CHECK.everything):
total_size = 0
Expand Down
Binary file added images_expected/lora_blue_low_clip_strength.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images_expected/lora_blue_low_model_strength.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images_expected/lora_character_hires_fix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images_expected/lora_negative_strength.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images_expected/sampler_30_steps_k_dpm_fast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images_expected/sampler_30_steps_k_dpmpp_sde.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions tests/test_horde_lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ def test_text_to_image_lora_blue_low_strength(

img_filename = "lora_blue_low_model_strength.png"
pil_image.save(f"images/{img_filename}", quality=100)
assert check_single_lora_image_similarity(
f"images_expected/{img_filename}",
pil_image,
)

data["loras"] = [{"name": lora_name, "model": 1.0, "clip": 0.1}]
pil_image = hordelib_instance.basic_inference_single_image(data)
Expand All @@ -250,6 +254,10 @@ def test_text_to_image_lora_blue_low_strength(

img_filename = "lora_blue_low_clip_strength.png"
pil_image.save(f"images/{img_filename}", quality=100)
assert check_single_lora_image_similarity(
f"images_expected/{img_filename}",
pil_image,
)

data["loras"] = [{"name": lora_name, "model": 0.1, "clip": 0.1}]
pil_image = hordelib_instance.basic_inference_single_image(data)
Expand All @@ -258,6 +266,10 @@ def test_text_to_image_lora_blue_low_strength(

img_filename = "lora_blue_low_model_and_clip_strength.png"
pil_image.save(f"images/{img_filename}", quality=100)
assert check_single_lora_image_similarity(
f"images_expected/{img_filename}",
pil_image,
)

def test_text_to_image_lora_blue_negative_strength(
self,
Expand Down Expand Up @@ -295,22 +307,37 @@ def test_text_to_image_lora_blue_negative_strength(
pil_image = hordelib_instance.basic_inference_single_image(data)
assert pil_image is not None
assert isinstance(pil_image, Image.Image)

img_filename = "lora_blue_negative_model_strength.png"
pil_image.save(f"images/{img_filename}", quality=100)
assert check_single_lora_image_similarity(
f"images_expected/{img_filename}",
pil_image,
)

data["loras"] = [{"name": lora_name, "model": 1.0, "clip": -1.0}]
pil_image = hordelib_instance.basic_inference_single_image(data)
assert pil_image is not None
assert isinstance(pil_image, Image.Image)

img_filename = "lora_blue_negative_clip_strength.png"
pil_image.save(f"images/{img_filename}", quality=100)
assert check_single_lora_image_similarity(
f"images_expected/{img_filename}",
pil_image,
)

data["loras"] = [{"name": lora_name, "model": -1.0, "clip": -1.0}]
pil_image = hordelib_instance.basic_inference_single_image(data)
assert pil_image is not None
assert isinstance(pil_image, Image.Image)

img_filename = "lora_blue_negative_model_and_clip_strength.png"
pil_image.save(f"images/{img_filename}", quality=100)
assert check_single_lora_image_similarity(
f"images_expected/{img_filename}",
pil_image,
)

def test_text_to_image_lora_blue_hires_fix(
self,
Expand Down Expand Up @@ -815,6 +842,11 @@ def test_negative_model_power(
img_filename = "lora_negative_strength.png"
pil_image.save(f"images/{img_filename}", quality=100)

assert check_single_lora_image_similarity(
f"images_expected/{img_filename}",
pil_image,
)

data = {
"sampler_name": "k_euler",
"cfg_scale": 8.0,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_horde_samplers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# test_horde.py

from PIL import Image
from loguru import logger

from hordelib.horde import HordeLib

Expand Down Expand Up @@ -81,6 +82,7 @@ def test_samplers(
images_to_compare.append((f"images_expected/{img_filename}", pil_image))

for img_filename, pil_image in images_to_compare:
logger.debug(f"Checking image {img_filename}")
assert check_single_inference_image_similarity(
img_filename,
pil_image,
Expand Down

0 comments on commit 4efaf87

Please sign in to comment.