Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
db0 committed Mar 24, 2024
1 parent 055778d commit 2551574
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
3 changes: 2 additions & 1 deletion horde/classes/base/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class News:
"date_published": "2024-03-24",
"newspiece": (
"The AI Horde now supports [Stable Cascade](https://stability.ai/news/introducing-stable-cascade) along with its"
"[image variations / remix](https://comfyanonymous.github.io/ComfyUI_examples/stable_cascade/#image-variations) capabilities!"
"[image variations / remix](https://comfyanonymous.github.io/ComfyUI_examples/stable_cascade/#image-variations)"
" capabilities!"
),
"tags": ["Stable Cascade", "db0", "nlnet"],
"importance": "Information",
Expand Down
4 changes: 2 additions & 2 deletions horde/classes/base/waiting_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

from horde import horde_redis as hr
from horde import vars as hv
from horde.bridge_reference import check_bridge_capability
from horde.classes.base.processing_generation import ProcessingGeneration
from horde.classes.kobold.processing_generation import TextProcessingGeneration
from horde.classes.stable.processing_generation import ImageProcessingGeneration
from horde.flask import SQLITE_MODE, db
from horde.logger import logger
from horde.utils import get_db_uuid, get_expiry_date
from horde.bridge_reference import check_bridge_capability

procgen_classes = {
"template": ProcessingGeneration,
Expand Down Expand Up @@ -277,7 +277,7 @@ def get_pop_payload(self, procgen_list, payload):
"ids": [g.id for g in procgen_list],
}
if self.extra_source_images and check_bridge_capability("extra_source_images", procgen_list[0].worker.bridge_agent):
prompt_payload["extra_source_images"] = self.extra_source_images['esi']
prompt_payload["extra_source_images"] = self.extra_source_images["esi"]

return prompt_payload

Expand Down
2 changes: 1 addition & 1 deletion horde/classes/stable/waiting_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def get_pop_payload(self, procgen_list, payload):
if src_msk:
prompt_payload["source_mask"] = convert_pil_to_b64(src_msk, 50)
if self.extra_source_images and check_bridge_capability("extra_source_images", procgen.worker.bridge_agent):
prompt_payload["extra_source_images"] = self.extra_source_images['esi']
prompt_payload["extra_source_images"] = self.extra_source_images["esi"]
# We always ask the workers to upload the generation to R2 instead of sending it back as b64
# If they send it back as b64 anyway, we upload it outselves
prompt_payload["r2_upload"] = generate_procgen_upload_url(str(procgen.id), self.shared)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_simple_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
try:
assert pop_req.ok, pop_req.text
except AssertionError as err:
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
print("Request cancelled")
raise err
pop_results = pop_req.json()
Expand All @@ -58,7 +58,7 @@ def test_simple_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
try:
assert job_id is not None, pop_results
except AssertionError as err:
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
print("Request cancelled")
raise err
submit_dict = {
Expand Down
18 changes: 10 additions & 8 deletions tests/test_image_extra_sources.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import base64
from io import BytesIO

import requests
import json
from PIL import Image
from io import BytesIO
import base64


def load_image_as_b64(image_path):
final_src_img = Image.open(image_path)
buffer = BytesIO()
final_src_img.save(buffer, format="Webp", quality=50, exact=True)
return base64.b64encode(buffer.getvalue()).decode("utf8")


TEST_MODELS = ["Stable Cascade 1.0"]


Expand All @@ -30,15 +32,15 @@ def test_simple_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
"sampler_name": "k_euler_a",
},
"models": TEST_MODELS,
"source_image": load_image_as_b64('img_stable/0.jpg'),
"source_image": load_image_as_b64("img_stable/0.jpg"),
"source_processing": "remix",
"extra_source_images": [
{
"image": load_image_as_b64('img_stable/1.jpg'),
"image": load_image_as_b64("img_stable/1.jpg"),
"strength": 0.5,
},
{
"image": load_image_as_b64('img_stable/2.jpg'),
"image": load_image_as_b64("img_stable/2.jpg"),
},
],
}
Expand Down Expand Up @@ -67,7 +69,7 @@ def test_simple_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
try:
assert pop_req.ok, pop_req.text
except AssertionError as err:
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
print("Request cancelled")
raise err

Expand All @@ -78,7 +80,7 @@ def test_simple_image_gen(api_key: str, HORDE_URL: str, CIVERSION: str) -> None:
try:
assert job_id is not None, pop_results
except AssertionError as err:
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
requests.delete(f"{protocol}://{HORDE_URL}/api/v2/generate/status/{req_id}", headers=headers)
print("Request cancelled")
raise err
submit_dict = {
Expand Down

0 comments on commit 2551574

Please sign in to comment.