Skip to content

Commit d34b882

Browse files
committed
predict fix
1 parent 3a0b007 commit d34b882

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

predict.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ def predict(
6767
description="Input prompt.",
6868
default="Add character to the scene",
6969
),
70+
negative_prompt: str = Input(
71+
description="Input negative prompt.",
72+
default="Bad, low quality, deformed, distorted, distorted, ugly",
73+
),
74+
should_optimise_reference: bool = Input(
75+
description="Should optimise reference?", default=None, choices=[True, False, None]
76+
),
7077
num_inference_steps: int = Input(
7178
description="Number of denoising steps", ge=1, le=150, default=20
7279
),
@@ -137,14 +144,13 @@ def predict(
137144
reference_image = reference_image.resize((width, height), Image.LANCZOS)
138145

139146
try:
140-
if has_reference:
141-
optimised_reference, new_reference_delta = optimise_image_condition(reference_image, delta)
147+
if should_optimise_reference is None:
148+
should_optimise_reference = delta[0] == 1
149+
if has_reference and should_optimise_reference:
150+
print("optimising reference")
151+
reference_image, delta = optimise_image_condition(reference_image, delta)
142152
try:
143-
print("optimised_reference: ", optimised_reference)
144-
print("new_reference_delta: ", new_reference_delta)
145-
o = "/tmp/optimised_reference.png"
146-
optimised_reference.save(o)
147-
print("saved optimised_reference to: ", Path(o))
153+
print("delta: ", delta)
148154
except Exception as e:
149155
print("Error saving optimised reference: ", e)
150156

@@ -159,6 +165,7 @@ def predict(
159165
print("guidance_scale: ", guidance_scale)
160166
result_img = self.pipe(
161167
prompt=prompt,
168+
negative_prompt=negative_prompt,
162169
image=image,
163170
reference=reference_image if has_reference else None,
164171
reference_delta=delta if has_reference else None,

0 commit comments

Comments
 (0)