Skip to content

Commit aa777fd

Browse files
committed
Limit txt2img filename length to prevent crash
1 parent 662c647 commit aa777fd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scripts/stable_txt2img.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ def main():
272272
grid = rearrange(grid, 'n b c h w -> (n b) c h w')
273273

274274
for i in range(grid.size(0)):
275-
save_image(grid[i, :, :, :], os.path.join(outpath,opt.prompt+'_{}.png'.format(i)))
275+
save_image(grid[i, :, :, :], os.path.join(outpath,opt.prompt[:30]+'_{}.png'.format(i)))
276276
grid = make_grid(grid, nrow=n_rows)
277277

278278
# to image
279279
grid = 255. * rearrange(grid, 'c h w -> h w c').cpu().numpy()
280-
Image.fromarray(grid.astype(np.uint8)).save(os.path.join(outpath, f'{prompt.replace(" ", "-")}-{grid_count:04}.jpg'))
280+
Image.fromarray(grid.astype(np.uint8)).save(os.path.join(outpath, f'{prompt.replace(" ", "-")[:30]}-{grid_count:04}.jpg'))
281281
grid_count += 1
282282

283283

0 commit comments

Comments
 (0)