Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/qr_with_reference_image' into qr…
Browse files Browse the repository at this point in the history
…_with_reference_image

# Conflicts:
#	recipes/QRCodeGenerator.py
  • Loading branch information
devxpy committed Dec 31, 2023
2 parents 4596e15 + 59dc9ea commit aa1a753
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions recipes/QRCodeGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ def render_form_v2(self):
key="text_prompt",
placeholder="Bright sunshine coming through the cracks of a wet, cave wall of big rocks",
)
st.file_uploader(
"""
### 🏞️ Reference Image [optional]
This image will be used as inspiration to blend with the QR Code.
""",
key="image_prompt",
accept=["image/*"],
)

qr_code_source_key = "__qr_code_source"
if qr_code_source_key not in st.session_state:
Expand Down Expand Up @@ -423,6 +431,79 @@ def render_settings(self):
color=255,
)

if st.session_state.get("image_prompt"):
st.write("---")
st.write(
"""
##### 🎨 Inspiration
Use this to control how the image prompt should influence the output.
""",
className="gui-input",
)
st.slider(
"Inspiration Strength",
min_value=0.0,
max_value=1.0,
step=0.05,
key="image_prompt_strength",
)
enum_multiselect(
ControlNetModels,
label="Control Net Models",
key="image_prompt_controlnet_models",
checkboxes=False,
allow_none=False,
)
st.write(
"""
##### ⌖ Positioning
Use this to control where the reference image is placed, and how big it should be.
""",
className="gui-input",
)
col1, _ = st.columns(2)
with col1:
image_prompt_scale = st.slider(
"Scale",
min_value=0.1,
max_value=1.0,
step=0.05,
key="image_prompt_scale",
)
col1, col2 = st.columns(2, responsive=False)
with col1:
image_prompt_pos_x = st.slider(
"Position X",
min_value=0.0,
max_value=1.0,
step=0.05,
key="image_prompt_pos_x",
)
with col2:
image_prompt_pos_y = st.slider(
"Position Y",
min_value=0.0,
max_value=1.0,
step=0.05,
key="image_prompt_pos_y",
)

img_cv2 = mask_cv2 = bytes_to_cv2_img(
requests.get(st.session_state["image_prompt"]).content,
)
repositioning_preview_widget(
img_cv2=img_cv2,
mask_cv2=mask_cv2,
obj_scale=image_prompt_scale,
pos_x=image_prompt_pos_x,
pos_y=image_prompt_pos_y,
out_size=(
st.session_state["output_width"],
st.session_state["output_height"],
),
color=255,
)

def render_output(self):
state = st.session_state
self._render_outputs(state)
Expand Down

0 comments on commit aa1a753

Please sign in to comment.