Skip to content

Commit

Permalink
Merge branch 'develop' into frame-correction
Browse files Browse the repository at this point in the history
Signed-off-by: vahid khroasani <[email protected]>
  • Loading branch information
v8hid authored May 1, 2023
2 parents bf41a30 + 7591a96 commit 119f53a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 48 deletions.
4 changes: 2 additions & 2 deletions iz_helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def putPrompts(files):

data = readJsonPrompt(file_contents,False)
return [
gr.Textbox.update(data["commonPromptPrefix"]),
gr.Textbox.update(data["prePrompt"]),
gr.DataFrame.update(data["prompts"]),
gr.Textbox.update(data["commonPromptSuffix"]),
gr.Textbox.update(data["postPromt"]),
gr.Textbox.update(data["negPrompt"])
]

Expand Down
46 changes: 14 additions & 32 deletions iz_helpers/prompt_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,21 @@
jsonprompt_schemafile
)

"""
json is valid, but not our current schema.
lets try something.
does it look like something usable?
def fixJson(j):
fixedJ = empty_prompt
try:
if isinstance(j, dict):
if "prompts" in j:
if "data" in j["prompts"]:
if isinstance (j["prompts"]["data"],list):
fixedJ["prompts"]["data"] = j["prompts"]["data"]
if not isinstance (fixedJ["prompts"]["data"][0].
if "headers" not in j["prompts"]:
fixedJ["prompts"]["headers"] = ["outpaint steps","prompt"]
else:
fixedJ["prompts"]["headers"] = j["prompts"]["headers"]
if "negPrompt" in j:
fixedJ["prompts"]["headers"]
if "commonPrompt" in j:
return j
except Exception:
raise "JsonFix: Failed on recovering json prompt"
return j
"""

def fixHeaders(j):
def completeOptionals(j):
if isinstance(j, dict):
if "prompts" in j:
if "headers" not in j["prompts"]:
j["prompts"]["headers"] = ["outpaint steps","prompt"]

if "negPrompt" not in j:
j["negPrompt"]=""

if "prePrompt" not in j:
j["prePrompt"]=""

if "postPrompt" not in j:
j["postPrompt"]=""

return j


Expand All @@ -49,11 +30,12 @@ def validatePromptJson_throws(data):
schema = json.load(s)
try:
validate(instance=data, schema=schema)

except Exception:
raise "Your prompts are not schema valid."
#fixJson(data)

return fixHeaders(data)
return completeOptionals(data)


def readJsonPrompt(txt, returnFailPrompt=False):
Expand All @@ -74,4 +56,4 @@ def readJsonPrompt(txt, returnFailPrompt=False):
if returnFailPrompt:
return invalid_prompt
pass


9 changes: 3 additions & 6 deletions iz_helpers/promptschema.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,14 @@
"negPrompt": {
"type": "string"
},
"commonPromptPrefix": {
"prePrompt": {
"type": "string"
},
"commonPromptSuffix": {
"postPrompt": {
"type": "string"
}
},
"required": [
"prompts",
"negPrompt",
"commonPromptPrefix",
"commonPromptSuffix"
"prompts"
]
}
4 changes: 2 additions & 2 deletions iz_helpers/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def on_ui_settings():
None,
"Name of your desired model to render keyframes (txt2img)",
gr.Dropdown,
lambda: {"choices": shared.list_checkpoint_tiles()},
lambda: {"choices": [x for x in list(shared.list_checkpoint_tiles()) if "inpainting" not in x]},
section=section,
),
)
Expand All @@ -78,7 +78,7 @@ def on_ui_settings():
None,
"Name of your desired inpaint model (img2img-inpaint). Default is vanilla sd-v1-5-inpainting.ckpt ",
gr.Dropdown,
lambda: {"choices": shared.list_checkpoint_tiles()},
lambda: {"choices": [x for x in list(shared.list_checkpoint_tiles()) if "inpainting" in x]},
section=section,
),
)
Expand Down
4 changes: 2 additions & 2 deletions iz_helpers/static_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"headers": ["outpaint steps", "prompt"],
},
"negPrompt": "Invalid prompt-json",
"commonPromptPrefix": "Invalid prompt",
"commonPromptSuffix": "Invalid prompt",
"prePromp": "Invalid prompt",
"postPrompt": "Invalid prompt"
}

available_samplers = [
Expand Down
4 changes: 2 additions & 2 deletions iz_helpers/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def on_ui_tabs():
jpr = readJsonPrompt(pr, True)

main_common_prompt_pre = gr.Textbox(
value=jpr["commonPromptPrefix"], label="Common Prompt Prefix"
value=jpr["prePrompt"], label="Common Prompt Prefix"
)

main_prompts = gr.Dataframe(
Expand All @@ -64,7 +64,7 @@ def on_ui_tabs():
)

main_common_prompt_suf = gr.Textbox(
value=jpr["commonPromptSuffix"], label="Common Prompt Suffix"
value=jpr["postPrompt"], label="Common Prompt Suffix"
)

main_negative_prompt = gr.Textbox(
Expand Down
2 changes: 0 additions & 2 deletions scripts/infinite-zoom.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from modules import script_callbacks
from iz_helpers.ui import on_ui_tabs
from iz_helpers.settings import on_ui_settings


script_callbacks.on_ui_tabs(on_ui_tabs)
script_callbacks.on_ui_settings(on_ui_settings)

0 comments on commit 119f53a

Please sign in to comment.