Skip to content
Open
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
12 changes: 11 additions & 1 deletion scripts/txt2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ def main():
choices=["full", "autocast"],
default="autocast"
)

parser.add_argument(
"--nsfw_filter",
action="store_true",
help="Boolean Flag to enable the built-in safety check and NSFW filter"
)

opt = parser.parse_args()

if opt.laion400m:
Expand Down Expand Up @@ -306,7 +313,10 @@ def main():
x_samples_ddim = torch.clamp((x_samples_ddim + 1.0) / 2.0, min=0.0, max=1.0)
x_samples_ddim = x_samples_ddim.cpu().permute(0, 2, 3, 1).numpy()

x_checked_image, has_nsfw_concept = check_safety(x_samples_ddim)
if opt.nsfw_filter:
x_checked_image, has_nsfw_concept = check_safety(x_samples_ddim)
else:
x_checked_image = x_samples_ddim

x_checked_image_torch = torch.from_numpy(x_checked_image).permute(0, 3, 1, 2)

Expand Down