34
34
35
35
36
36
def next_seed (args ):
37
- print (type (args .seed ))
38
- print (args .seed )
37
+ print ('type(args.seed)' , type (args .seed ))
38
+ print ('args.seed' , args .seed )
39
39
args .seed = int (args .seed )
40
40
if args .seed_behavior == 'iter' :
41
41
args .seed += 1
@@ -62,6 +62,24 @@ def save_settings(args, outfolder, prompt, index):
62
62
del output_data
63
63
64
64
65
+ def shorten_path (path ):
66
+ # Get the directory, filename, and extension
67
+ dir_name , filename = os .path .split (path )
68
+ name , ext = os .path .splitext (filename )
69
+
70
+ # Shorten the name if necessary
71
+ max_length = 250 - len (ext )
72
+ if len (name ) > max_length :
73
+ name = name [:max_length ]
74
+
75
+ # Join the shortened name and extension
76
+ shortened_filename = name + ext
77
+
78
+ # Join the shortened filename and directory to get the shortened path
79
+ shortened_path = os .path .join (dir_name , shortened_filename )
80
+
81
+ return shortened_path
82
+
65
83
def render_image_batch (args , prompts , root , image_callback = None , step_callback = None ):
66
84
args .prompts = {k : f"{ v :05d} " for v , k in enumerate (prompts )}
67
85
@@ -179,11 +197,16 @@ def render_image_batch(args, prompts, root, image_callback=None, step_callback=N
179
197
filename = f"{ args .timestring } _{ index :05} _{ args .seed } .png"
180
198
#added prompt to output folder name
181
199
if gs .diffusion .pathmode == "prompt-folders" :
182
- outfolder = os .path .join (args .outdir , f'{ args .timestring } _{ sanitize (prompt )[:120 ]} ' )
200
+ outfolder = os .path .join (args .outdir , f'{ args .timestring } _{ sanitize (prompt )[:80 ]} ' )
183
201
else :
184
202
outfolder = os .path .join (args .outdir , datetime .now ().strftime ("%Y%m%d" ))
185
203
os .makedirs (outfolder , exist_ok = True )
186
- gs .temppath = os .path .join (outfolder , filename )
204
+ abs_path = os .path .join (outfolder , filename )
205
+ if len (abs_path ) > 250 :
206
+ print ('path to long and gets shortened' )
207
+ abs_path = shorten_path (abs_path )
208
+
209
+ gs .temppath = abs_path
187
210
if args .save_samples :
188
211
paths .append (gs .temppath )
189
212
image .save (gs .temppath )
0 commit comments