Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -127,9 +127,9 @@ def inference(model_name, prompt, guidance, steps, n_images=1, width=512, height
|
|
| 127 |
|
| 128 |
try:
|
| 129 |
if img is not None:
|
| 130 |
-
return img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance, steps, width, height, generator
|
| 131 |
else:
|
| 132 |
-
return txt_to_img(model_path, prompt, n_images, neg_prompt, guidance, steps, width, height, generator
|
| 133 |
except Exception as e:
|
| 134 |
return None, error_str(e)
|
| 135 |
|
|
@@ -181,7 +181,7 @@ def inference_image(model_path, prompt, mode, *args, **kwargs):
|
|
| 181 |
)
|
| 182 |
return replace_nsfw_images(result)
|
| 183 |
|
| 184 |
-
def txt_to_img(model_path, prompt, n_images, neg_prompt, guidance, steps, width, height, generator
|
| 185 |
return inference_image(model_path, prompt, "txt2img",
|
| 186 |
negative_prompt=neg_prompt,
|
| 187 |
num_images_per_prompt=n_images,
|
|
@@ -189,11 +189,10 @@ def txt_to_img(model_path, prompt, n_images, neg_prompt, guidance, steps, width,
|
|
| 189 |
guidance_scale=guidance,
|
| 190 |
width=width,
|
| 191 |
height=height,
|
| 192 |
-
generator=generator
|
| 193 |
-
seed=seed
|
| 194 |
)
|
| 195 |
|
| 196 |
-
def img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance, steps, width, height, generator
|
| 197 |
img = process_image(img, width, height)
|
| 198 |
return inference_image(model_path, prompt, "img2img",
|
| 199 |
negative_prompt=neg_prompt,
|
|
@@ -202,8 +201,7 @@ def img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance
|
|
| 202 |
num_inference_steps=int(steps),
|
| 203 |
strength=strength,
|
| 204 |
guidance_scale=guidance,
|
| 205 |
-
generator=generator
|
| 206 |
-
seed=seed
|
| 207 |
)
|
| 208 |
|
| 209 |
def replace_nsfw_images(results):
|
|
|
|
| 127 |
|
| 128 |
try:
|
| 129 |
if img is not None:
|
| 130 |
+
return img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance, steps, width, height, generator), f"Done. Seed: {seed}"
|
| 131 |
else:
|
| 132 |
+
return txt_to_img(model_path, prompt, n_images, neg_prompt, guidance, steps, width, height, generator), f"Done. Seed: {seed}"
|
| 133 |
except Exception as e:
|
| 134 |
return None, error_str(e)
|
| 135 |
|
|
|
|
| 181 |
)
|
| 182 |
return replace_nsfw_images(result)
|
| 183 |
|
| 184 |
+
def txt_to_img(model_path, prompt, n_images, neg_prompt, guidance, steps, width, height, generator):
|
| 185 |
return inference_image(model_path, prompt, "txt2img",
|
| 186 |
negative_prompt=neg_prompt,
|
| 187 |
num_images_per_prompt=n_images,
|
|
|
|
| 189 |
guidance_scale=guidance,
|
| 190 |
width=width,
|
| 191 |
height=height,
|
| 192 |
+
generator=generator
|
|
|
|
| 193 |
)
|
| 194 |
|
| 195 |
+
def img_to_img(model_path, prompt, n_images, neg_prompt, img, strength, guidance, steps, width, height, generator):
|
| 196 |
img = process_image(img, width, height)
|
| 197 |
return inference_image(model_path, prompt, "img2img",
|
| 198 |
negative_prompt=neg_prompt,
|
|
|
|
| 201 |
num_inference_steps=int(steps),
|
| 202 |
strength=strength,
|
| 203 |
guidance_scale=guidance,
|
| 204 |
+
generator=generator
|
|
|
|
| 205 |
)
|
| 206 |
|
| 207 |
def replace_nsfw_images(results):
|