Spaces:
Runtime error
Runtime error
patrickvonplaten
commited on
correct merg
Browse filesFormer-commit-id: f3f60fccc31acee192417e2e926260698201982f
- scripts/txt2img.py +7 -2
scripts/txt2img.py
CHANGED
@@ -239,9 +239,7 @@ def main():
|
|
239 |
if opt.fixed_code:
|
240 |
start_code = torch.randn([opt.n_samples, opt.C, opt.H // opt.f, opt.W // opt.f], device=device)
|
241 |
|
242 |
-
print("start code", start_code.abs().sum())
|
243 |
precision_scope = autocast if opt.precision=="autocast" else nullcontext
|
244 |
-
precision_scope = nullcontext
|
245 |
with torch.no_grad():
|
246 |
with precision_scope("cuda"):
|
247 |
with model.ema_scope():
|
@@ -297,6 +295,13 @@ def main():
|
|
297 |
Image.fromarray(grid.astype(np.uint8)).save(os.path.join(outpath, f'grid-{grid_count:04}.png'))
|
298 |
grid_count += 1
|
299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
print(f"Your samples are ready and waiting for you here: \n{outpath} \n"
|
301 |
f" \nEnjoy.")
|
302 |
|
|
|
239 |
if opt.fixed_code:
|
240 |
start_code = torch.randn([opt.n_samples, opt.C, opt.H // opt.f, opt.W // opt.f], device=device)
|
241 |
|
|
|
242 |
precision_scope = autocast if opt.precision=="autocast" else nullcontext
|
|
|
243 |
with torch.no_grad():
|
244 |
with precision_scope("cuda"):
|
245 |
with model.ema_scope():
|
|
|
295 |
Image.fromarray(grid.astype(np.uint8)).save(os.path.join(outpath, f'grid-{grid_count:04}.png'))
|
296 |
grid_count += 1
|
297 |
|
298 |
+
image = x_samples_ddim.cpu().permute(0, 2, 3, 1).numpy()
|
299 |
+
|
300 |
+
# run safety checker
|
301 |
+
safety_checker_input = pipe.feature_extractor(numpy_to_pil(image), return_tensors="pt")
|
302 |
+
image, has_nsfw_concept = pipe.safety_checker(images=image, clip_input=safety_checker_input.pixel_values)
|
303 |
+
toc = time.time()
|
304 |
+
|
305 |
print(f"Your samples are ready and waiting for you here: \n{outpath} \n"
|
306 |
f" \nEnjoy.")
|
307 |
|