Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add input to specify PNG, JPEG, or WebP output formats #80

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion predict.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
from typing import List

import torch
Expand Down Expand Up @@ -63,6 +64,11 @@ def predict(
description="Prompt strength when using init image. 1.0 corresponds to full destruction of information in init image",
default=0.8,
),
format: str = Input(
description="Format of the output images",
choices=["png", "jpg", "webp"],
default="png",
),
num_outputs: int = Input(
description="Number of images to output.",
ge=1,
Expand Down Expand Up @@ -121,7 +127,8 @@ def predict(
if output.nsfw_content_detected and output.nsfw_content_detected[i]:
continue

output_path = f"/tmp/out-{i}.png"
ext = re.sub(r'\W+', '', format)
output_path = os.path.join("/tmp", f"out-{i}.{ext}")
sample.save(output_path)
output_paths.append(Path(output_path))

Expand Down