Skip to content

Commit

Permalink
Fix upscaler for Stability API
Browse files Browse the repository at this point in the history
  • Loading branch information
benrugg committed Oct 27, 2024
1 parent 7387975 commit adb2aa5
Show file tree
Hide file tree
Showing 8 changed files with 686 additions and 255 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "AI Render - Stable Diffusion in Blender",
"description": "Create amazing images using Stable Diffusion AI",
"author": "Ben Rugg",
"version": (1, 0, 1),
"version": (1, 1, 0),
"blender": (3, 0, 0),
"location": "Render Properties > AI Render",
"warning": "",
Expand Down
55 changes: 41 additions & 14 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
package_name = 'AI-Render'
default_prompt_text = 'Describe anything you can imagine'
package_name = "AI-Render"
default_prompt_text = "Describe anything you can imagine"
default_image_filename_template = "ai-render-{timestamp}-{prompt}"
filename_template_allowed_vars = ['timestamp', 'prompt', 'width', 'height', 'seed', 'steps', 'image_similarity', 'sampler', 'negative_prompt']
tmp_path_subfolder = 'ai-render-temp'
animated_prompts_text_name = 'AI Render Animated Prompts'
filename_template_allowed_vars = [
"timestamp",
"prompt",
"width",
"height",
"seed",
"steps",
"image_similarity",
"sampler",
"negative_prompt",
]
tmp_path_subfolder = "ai-render-temp"
animated_prompts_text_name = "AI Render Animated Prompts"

ADDON_DOWNLOAD_URL = "https://blendermarket.com/products/ai-render"
STABILITY_API_URL = "https://api.stability.ai/v1/generation/"
STABILITY_API_V1_URL = "https://api.stability.ai/v1/generation/"
STABILITY_API_V2_URL = "https://api.stability.ai/v2beta/stable-image/"
DREAM_STUDIO_URL = "https://dreamstudio.ai/account"
STABLE_HORDE_API_URL_BASE = "https://stablehorde.net/api/v2"
STABLE_HORDE_URL = "https://stablehorde.net/"
VIDEO_TUTORIAL_URL = "https://www.youtube.com/watch?v=tmyln5bwnO8"
HELP_WITH_TIMEOUTS_URL = "https://github.com/benrugg/AI-Render/wiki/FAQ#%EF%B8%8F-ai-render-keeps-timing-out"
HELP_WITH_LOCAL_INSTALLATION_URL = "https://github.com/benrugg/AI-Render/wiki/Local-Installation"
HELP_WITH_AUTOMATIC1111_NOT_IN_API_MODE_URL = "https://github.com/benrugg/AI-Render/wiki/Local-Installation#troubleshooting"
HELP_WITH_AUTOMATIC1111_UPSCALING_URL = "https://github.com/benrugg/AI-Render/wiki/Upscaling#upscaling-with-automatic1111"
HELP_WITH_ANIMATED_PROMPTS_URL = "https://github.com/benrugg/AI-Render/wiki/Animation#animated-prompts"
HELP_WITH_NEGATIVE_PROMPTS_URL = "https://github.com/benrugg/AI-Render/wiki/Animation#negative-prompts"
HELP_WITH_TIMEOUTS_URL = (
"https://github.com/benrugg/AI-Render/wiki/FAQ#%EF%B8%8F-ai-render-keeps-timing-out"
)
HELP_WITH_LOCAL_INSTALLATION_URL = (
"https://github.com/benrugg/AI-Render/wiki/Local-Installation"
)
HELP_WITH_AUTOMATIC1111_NOT_IN_API_MODE_URL = (
"https://github.com/benrugg/AI-Render/wiki/Local-Installation#troubleshooting"
)
HELP_WITH_AUTOMATIC1111_UPSCALING_URL = (
"https://github.com/benrugg/AI-Render/wiki/Upscaling#upscaling-with-automatic1111"
)
HELP_WITH_ANIMATED_PROMPTS_URL = (
"https://github.com/benrugg/AI-Render/wiki/Animation#animated-prompts"
)
HELP_WITH_NEGATIVE_PROMPTS_URL = (
"https://github.com/benrugg/AI-Render/wiki/Animation#negative-prompts"
)
HELP_WITH_CONTROLNET_URL = "https://github.com/benrugg/AI-Render/wiki/ControlNet"
ANIMATION_TIPS_URL = "https://github.com/benrugg/AI-Render/wiki/Animation#animation-tips"
ANIMATION_TIPS_URL = (
"https://github.com/benrugg/AI-Render/wiki/Animation#animation-tips"
)
CONTRIBUTING_URL = "https://github.com/benrugg/AI-Render/blob/main/CONTRIBUTING.md"
HELP_WITH_SHARK_INSTALLATION_URL = "https://github.com/AyaanShah2204/AI-Render/wiki/SHARK-by-nod.ai#running-shark-locally"
HELP_WITH_SHARK_TROUBLESHOOTING_URL = "https://github.com/AyaanShah2204/AI-Render/wiki/SHARK-by-nod.ai#troubleshooting"
HELP_WITH_SHARK_TROUBLESHOOTING_URL = (
"https://github.com/AyaanShah2204/AI-Render/wiki/SHARK-by-nod.ai#troubleshooting"
)
12 changes: 11 additions & 1 deletion properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,20 @@ def ensure_upscaler_model(context):
scene.air_props.upscaler_model = get_default_upscaler_model()


def ensure_upscaler_factor(context):
# """Ensure that the upscale factor is set to a valid value"""
scene = context.scene
if not utils.get_active_backend().supports_choosing_upscale_factor():
scene.air_props.upscale_factor = (
utils.get_active_backend().fixed_upscale_factor()
)


def ensure_properties(self, context):
# """Ensure that any properties which could change with a change in preferences are set to valid values"""
ensure_sampler(context)
ensure_upscaler_model(context)
ensure_upscaler_factor(context)


class AIRProperties(bpy.types.PropertyGroup):
Expand Down Expand Up @@ -203,7 +213,7 @@ class AIRProperties(bpy.types.PropertyGroup):
)
do_upscale_automatically: bpy.props.BoolProperty(
name="Upscale Automatically",
default=True,
default=False,
description="When true, will automatically upscale the image after each render",
)
upscaler_model: bpy.props.EnumProperty(
Expand Down
Loading

0 comments on commit adb2aa5

Please sign in to comment.