Skip to content

Commit

Permalink
Merge pull request #121 from Haidra-Org/SC
Browse files Browse the repository at this point in the history
Support for Stable Cascade
  • Loading branch information
db0 authored Mar 10, 2024
2 parents cc479e0 + ef3f944 commit a47fc68
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 10 deletions.
15 changes: 12 additions & 3 deletions LucidCreations.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,14 @@ margin_right = 320.0
margin_bottom = 193.0
text = "Larger Values"

[node name="AllowDowngrade" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"]
unique_name_in_owner = true
margin_top = 165.0
margin_right = 320.0
margin_bottom = 193.0
pressed = true
text = "Allow Downgrade"

[node name="LoadSeedFromDisk" type="CheckButton" parent="Margin/Panel/Display/Panels/Controls/Options/VBC/VBCLeft"]
unique_name_in_owner = true
margin_top = 201.0
Expand Down Expand Up @@ -1769,21 +1777,22 @@ scroll_active = false

[node name="VBC" type="VBoxContainer" parent="Margin/Panel/Footer/Progress/Margin/Labels"]
margin_left = 100.0
margin_top = 10.0
margin_top = 8.0
margin_right = 1290.0
margin_bottom = 28.0
margin_bottom = 29.0
size_flags_horizontal = 3
size_flags_vertical = 4
custom_constants/separation = 0

[node name="StatusText" type="RichTextLabel" parent="Margin/Panel/Footer/Progress/Margin/Labels/VBC"]
unique_name_in_owner = true
margin_right = 1190.0
margin_bottom = 18.0
margin_bottom = 21.0
rect_min_size = Vector2( 0, 18 )
size_flags_horizontal = 3
size_flags_vertical = 4
bbcode_enabled = true
fit_content_height = true
scroll_active = false

[node name="ProgressText" type="Label" parent="Margin/Panel/Footer/Progress/Margin/Labels/VBC"]
Expand Down
6 changes: 6 additions & 0 deletions Options.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ onready var login_button = $"%LoginButton"
onready var stable_horde_login = $"%StableHordeLogin"
onready var load_seed_from_disk = $"%LoadSeedFromDisk"
onready var wipe_cache = $"%WipeCache"
onready var allow_downgrade = $"%AllowDowngrade"

func _ready():
remember_prompt.pressed = globals.config.get_value("Options", "remember_prompt", false)
remember_prompt.connect("toggled",self,"_on_remember_prompt_pressed")
larger_values.pressed = globals.config.get_value("Options", "larger_values", false)
larger_values.connect("toggled",self,"_on_larger_values_pressed")
allow_downgrade.pressed = globals.config.get_value("Options", "allow_downgrade", true)
allow_downgrade.connect("toggled",self,"_on_allow_downgrade_pressed")
load_seed_from_disk.pressed = globals.config.get_value("Options", "load_seed_from_disk", false)
load_seed_from_disk.connect("toggled",self,"_on_load_seed_from_disk_pressed")
shared.pressed = globals.config.get_value("Options", "shared", true)
Expand Down Expand Up @@ -54,6 +57,9 @@ func _on_remember_prompt_pressed(pressed: bool) -> void:
func _on_larger_values_pressed(pressed: bool) -> void:
globals.set_setting("larger_values", pressed, "Options")

func _on_allow_downgrade_pressed(pressed: bool) -> void:
globals.set_setting("allow_downgrade", pressed, "Options")

func _on_load_seed_from_disk_pressed(pressed: bool) -> void:
globals.set_setting("load_seed_from_disk", pressed, "Options")

Expand Down
1 change: 1 addition & 0 deletions PopupInfoPanel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const DESCRIPTIONS = {
"BlockList": "When enabled, the workers specified will NOT be used for generations (This option requires upfront kudos). When disabled only the workers specified will be used for the generation.",
"WorkerAutoComplete": "Specify workers to use for this generation. Use the toggle below to specify using them as an allowlist or a blocklist. When models are selected, only workers which can generate any of those models will be shown.",
"ShowAllWorkers": "Press this button to display and select available workers for your selected model.",
"AllowDowngrade": "When enabled and your account doesn't have enough kudos to generate the image, it will be downgraded in resolution and steps, so that it does not need upfront kudos, instead of failing.",
}

const META_DESCRIPTIONS = {
Expand Down
3 changes: 3 additions & 0 deletions StableHordeClient.gd
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ func _connect_hover_signals() -> void:
$"%BlockList",
$"%WorkerAutoComplete",
$"%ShowAllWorkers",
$"%AllowDowngrade",
]:
node.connect("mouse_entered", EventBus, "_on_node_hovered", [node])
node.connect("mouse_exited", EventBus, "_on_node_unhovered", [node])
Expand Down Expand Up @@ -681,10 +682,12 @@ func _accept_settings() -> void:
stable_horde_client.set("trusted_workers", trusted_workers.pressed)
globals.set_setting("trusted_workers", trusted_workers.pressed)
stable_horde_client.set("shared", globals.config.get_value("Options", "share", true))
stable_horde_client.set("allow_downgrade", globals.config.get_value("Options", "allow_downgrade", true))
stable_horde_client.set("gen_seed", seed_edit.text)
stable_horde_client.set("post_processing", globals.config.get_value("Parameters", "post_processing", stable_horde_client.post_processing))
stable_horde_client.set("lora", globals.config.get_value("Parameters", "loras", stable_horde_client.lora))
stable_horde_client.set("tis", globals.config.get_value("Parameters", "tis", stable_horde_client.tis))

if prompt_line_edit.text == '':
prompt_line_edit.text = _get_random_placeholder_prompt()
stable_horde_client.prompt = prompt_line_edit.text
Expand Down
18 changes: 13 additions & 5 deletions addons/stable_horde_client/civitai_showcase.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@ func _ready():

func get_model_showcase(
_model_reference: Dictionary,
version_id: String,
version_id: String = '',
force_index = null
) -> void:
if force_index:
used_image_index = force_index
else:
used_image_index = showcase_index
model_reference = _model_reference
if model_reference["versions"][version_id]["images"].size() <= used_image_index:
emit_signal("showcase_failed")
return
var showcase_url = model_reference["versions"][version_id]["images"][used_image_index]
var showcase_url: String
if version_id != '':
if model_reference["versions"][version_id]["images"].size() <= used_image_index:
emit_signal("showcase_failed")
return
showcase_url = model_reference["versions"][version_id]["images"][used_image_index]
else: # TODO: Convert TIs to the same format as LoRas
if model_reference["images"].size() <= used_image_index:
emit_signal("showcase_failed")
return
showcase_url = model_reference["images"][used_image_index]
print_debug(showcase_url)
var error = request(showcase_url, [], false, HTTPClient.METHOD_GET)
if error != OK:
var error_msg := "Something went wrong when initiating the request"
Expand Down
5 changes: 5 additions & 0 deletions addons/stable_horde_client/stable_horde_client.gd
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export(String, "none", "canny", "hed", "depth", "normal", "openpose", "seg", "sc
export(bool) var dry_run := false
export(Array) var workers := []
export(bool) var worker_blacklist := false
export(bool) var allow_downgrade := false

var all_image_textures := []
var latest_image_textures := []
Expand Down Expand Up @@ -155,7 +156,9 @@ func generate(replacement_prompt := '', replacement_params := {}) -> void:
"shared": shared,
"dry_run": dry_run,
"workers": workers,
"replacement_filter": false,
"worker_blacklist": worker_blacklist,
"allow_downgrade": allow_downgrade,
# "workers": [
# "dc0704ab-5b42-4c65-8471-561be16ad696", #portal
# ], # debug
Expand All @@ -173,6 +176,8 @@ func generate(replacement_prompt := '', replacement_params := {}) -> void:
"apikey: " + api_key,
"Client-Agent: " + client_agent,
]
# print_debug(body)
# print_debug(headers)
var error = request(aihorde_url + "/api/v2/generate/async", headers, false, HTTPClient.METHOD_POST, body)
if error != OK:
var error_msg := "Something went wrong when initiating the stable horde request"
Expand Down
4 changes: 2 additions & 2 deletions addons/stable_horde_client/stable_horde_httpclient.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func _on_request_completed(_result, response_code, _headers, body):
return
var json_ret = parse_json(body.get_string_from_utf8())
var json_error = json_ret
if typeof(json_ret) == TYPE_DICTIONARY and json_ret.has('message'):
json_error = str(json_ret['message'])
if typeof(json_ret) == TYPE_DICTIONARY and json_ret.has('rc'):
json_error = '(rc:' + json_ret['rc'] + ') ' + str(json_ret['message'])
if json_ret.has('errors'):
json_error += ': ' + str(json_ret['errors'])
if typeof(json_ret) == TYPE_NIL:
Expand Down
1 change: 1 addition & 0 deletions src/Lora/Lora.gd
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ func check_baseline_compatibility(version_id: String) -> int:
if baselines.size() == 0:
return LoraCompatible.MAYBE
var lora_to_model_baseline_map = {
"Stable Cascade": "stable_cascade",
"SDXL 1.0": "stable_diffusion_xl",
"SD 1.5": "stable diffusion 1",
"SD 2.1 768": "stable diffusion 2",
Expand Down
2 changes: 2 additions & 0 deletions src/Lora/TextualInversion.gd
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ func check_baseline_compatibility(ti_name) -> int:
if baselines.size() == 0:
return TICompatible.MAYBE
var ti_to_model_baseline_map = {
"Stable Cascade": "stable_cascade",
"SDXL 1.0": "stable_diffusion_xl",
"SD 1.5": "stable diffusion 1",
"SD 2.1 768": "stable diffusion 2",
"SD 2.1 512": "stable diffusion 2",
Expand Down

0 comments on commit a47fc68

Please sign in to comment.