Skip to content

Commit

Permalink
Test strudel with commented out lines
Browse files Browse the repository at this point in the history
  • Loading branch information
benrugg committed Dec 5, 2024
1 parent 87e6355 commit 75c63f2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 43 deletions.
21 changes: 12 additions & 9 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "AI Render - Stable Diffusion in Blender",
"description": "Create amazing images using Stable Diffusion AI",
"author": "Ben Rugg",
"version": (1, 1, 2),
"blender": (3, 0, 0),
"location": "Render Properties > AI Render",
"warning": "",
"doc_url": "https://github.com/benrugg/AI-Render#readme",
"tracker_url": "https://github.com/benrugg/AI-Render/issues",
"category": "Render",
# "version": (1, 1, 0),
# "blender": (3, 0, 0),
# "location": "Render Properties > AI Render",
# "warning": "",
# "doc_url": "https://github.com/benrugg/AI-Render#readme",
# "tracker_url": "https://github.com/benrugg/AI-Render/issues",
# "category": "Render",
}


Expand All @@ -30,7 +30,6 @@
imp.reload(automatic1111_api)
imp.reload(stability_api)
imp.reload(stablehorde_api)
imp.reload(test_api)
else:
from . import (
addon_updater_ops,
Expand All @@ -48,7 +47,11 @@
ui_panels,
ui_preset_styles,
)
from .sd_backends import automatic1111_api, stability_api, stablehorde_api, test_api
from .sd_backends import (
automatic1111_api,
stability_api,
stablehorde_api,
)

import bpy

Expand Down
34 changes: 18 additions & 16 deletions sd_backends/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def generate(params, img_file, filename_prefix, props):
img_file.close()
except requests.exceptions.ReadTimeout:
img_file.close()
return operators.handle_error(
f"The server timed out. Try again in a moment, or get help. [Get help with timeouts]({config.HELP_WITH_TIMEOUTS_URL})",
"timeout",
)
# return operators.handle_error(
# f"The server timed out. Try again in a moment, or get help. [Get help with timeouts]({config.HELP_WITH_TIMEOUTS_URL})",
# "timeout",
# )

# print log info for debugging
# debug_log(response)
Expand Down Expand Up @@ -80,10 +80,10 @@ def upscale(img_file, filename_prefix, props):
img_file.close()
except requests.exceptions.ReadTimeout:
img_file.close()
return operators.handle_error(
f"The server timed out during upscaling. Try again in a moment, or turn off upscaling.",
"timeout",
)
# return operators.handle_error(
# f"The server timed out during upscaling. Try again in a moment, or turn off upscaling.",
# "timeout",
# )

# print log info for debugging
# debug_log(response)
Expand Down Expand Up @@ -187,10 +187,11 @@ def validate_params(params, props):
if props.sd_model.startswith(
"stable-diffusion-xl-1024"
) and not utils.are_sdxl_1024_dimensions_valid(params["width"], params["height"]):
return operators.handle_error(
f"The SDXL model only supports these image sizes: {', '.join(utils.sdxl_1024_valid_dimensions)}. Please change your image size and try again.",
"invalid_dimensions",
)
pass
# return operators.handle_error(
# f"The SDXL model only supports these image sizes: {', '.join(utils.sdxl_1024_valid_dimensions)}. Please change your image size and try again.",
# "invalid_dimensions",
# )
elif params["steps"] < 10:
return operators.handle_error(
"Steps must be set to at least 10.", "steps_too_small"
Expand All @@ -207,10 +208,11 @@ def parse_message_for_error(message):
or "Unauthenticated" in message
or "Unable to find corresponding account" in message
):
return (
f"Your DreamStudio API key is incorrect. Please find it on the DreamStudio website, and re-enter it above. [DreamStudio website]({config.DREAM_STUDIO_URL})",
"api_key",
)
pass
# return (
# f"Your DreamStudio API key is incorrect. Please find it on the DreamStudio website, and re-enter it above. [DreamStudio website]({config.DREAM_STUDIO_URL})",
# "api_key",
# )
elif "not have enough balance" in message:
return (
f"You don't have enough DreamStudio credits. Please purchase credits on the DreamStudio website or switch to a different backend in the AI Render add-on preferences. [DreamStudio website]({config.DREAM_STUDIO_URL})",
Expand Down
35 changes: 17 additions & 18 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
stability_api,
stablehorde_api,
shark_api,
test_api,
)

min_dimension_size = 128
Expand Down Expand Up @@ -443,24 +442,23 @@ def has_url(text, strict_match_protocol=False):
for ch in replacechars:
text.replace(ch, "")

# if none found, look for url without markup
else:
if strict_match_protocol:
bare_url_regex = (
r"(https{0,1}:\/\/[A-Za-z0-9\-\._~:\/\?#\[\]@!\$&'\(\)\*\+\,;%=]+)"
)
else:
bare_url_regex = r"(?:[a-z]{3,9}:\/\/?[\-;:&=\+\$,\w]+?[a-z0-9\.\-]+|[\/a-z0-9]+\.|[\-;:&=\+\$,\w]+@)[a-z0-9\.\-]+(?:(?:\/[\+~%\/\.\w\-_]*)?\??[\-\+=&;%@\.\w_]*#?[\.\!\/\\\w]*)?"

urls = re.findall(bare_url_regex, text, re.IGNORECASE)

for i, url in enumerate(urls):
urls[i] = [url, url]

# return what was found (could be just text)
# # if none found, look for url without markup
# else:
# if strict_match_protocol:
# bare_url_regex = r"(https{0,1}:\/\/[A-Za-z0-9\-\._~:\/\?#\[\]@!\$&'\(\)\*\+\,;%=]+)"
# else:
# bare_url_regex = r"(?:[a-z]{3,9}:\/\/?[\-;:&=\+\$,\w]+?[a-z0-9\.\-]+|[\/a-z0-9]+\.|[\-;:&=\+\$,\w]+@)[a-z0-9\.\-]+(?:(?:\/[\+~%\/\.\w\-_]*)?\??[\-\+=&;%@\.\w_]*#?[\.\!\/\\\w]*)?"
#
# urls = re.findall(bare_url_regex, text, re.IGNORECASE)
#
# for i, url in enumerate(urls):
# urls[i] = [url, url]

# # return what was found (could be just text)
return urls, text


#
def label_multiline(
layout,
text="",
Expand Down Expand Up @@ -565,8 +563,6 @@ def get_active_backend():
return automatic1111_api
elif backend == "shark":
return shark_api
elif backend == "test":
return test_api


def is_installation_valid():
Expand All @@ -584,3 +580,6 @@ def show_invalid_installation_message(layout, width):
alert=True,
width=width,
)


#

0 comments on commit 75c63f2

Please sign in to comment.