|
| 1 | +import random |
1 | 2 | from pathlib import Path
|
2 | 3 |
|
3 | 4 | import PIL.Image
|
@@ -273,8 +274,7 @@ def core_generation_funnel(outpath, inputimages, inputdepthmaps, inputnames, inp
|
273 | 274 | if inp[go.GEN_SIMPLE_MESH]:
|
274 | 275 | print(f"\nGenerating (occluded) mesh ..")
|
275 | 276 | basename = 'depthmap'
|
276 |
| - meshsimple_fi = get_uniquefn(outpath, basename, 'obj') |
277 |
| - meshsimple_fi = os.path.join(outpath, meshsimple_fi + '_simple.obj') |
| 277 | + meshsimple_fi = get_uniquefn(outpath, basename, 'obj', 'simple') |
278 | 278 |
|
279 | 279 | depthi = raw_prediction if raw_prediction is not None else out
|
280 | 280 | depthi_min, depthi_max = depthi.min(), depthi.max()
|
@@ -346,18 +346,17 @@ def core_generation_funnel(outpath, inputimages, inputdepthmaps, inputnames, inp
|
346 | 346 | print("All done.\n")
|
347 | 347 |
|
348 | 348 |
|
349 |
| -def get_uniquefn(outpath, basename, ext): |
| 349 | +def get_uniquefn(outpath, basename, ext, suffix=''): |
350 | 350 | basecount = backbone.get_next_sequence_number(outpath, basename)
|
351 |
| - if basecount > 0: basecount = basecount - 1 |
352 |
| - fullfn = None |
| 351 | + if basecount > 0: |
| 352 | + basecount -= 1 |
| 353 | + if suffix != '': |
| 354 | + suffix = f'-{suffix}' # Dash is important for selecting unique filenames (see get_next_sequence_number) |
353 | 355 | for i in range(500):
|
354 |
| - fn = f"{basecount + i:05}" if basename == '' else f"{basename}-{basecount + i:04}" |
355 |
| - fullfn = os.path.join(outpath, f"{fn}.{ext}") |
| 356 | + fullfn = os.path.join(outpath, f"{basename}-{basecount + i:04}{suffix}.{ext}") |
356 | 357 | if not os.path.exists(fullfn):
|
357 |
| - break |
358 |
| - basename = Path(fullfn).stem |
359 |
| - |
360 |
| - return basename |
| 358 | + return fullfn |
| 359 | + return f"{basename}-99999{suffix}.{ext}" # Failback, should never be executed |
361 | 360 |
|
362 | 361 |
|
363 | 362 | def run_3dphoto(device, img_rgb, img_depth, inputnames, outpath, gen_inpainted_mesh_demos, vid_ssaa, vid_format):
|
@@ -428,8 +427,7 @@ def run_3dphoto(device, img_rgb, img_depth, inputnames, outpath, gen_inpainted_m
|
428 | 427 | p = Path(inputnames[count])
|
429 | 428 | basename = p.stem
|
430 | 429 |
|
431 |
| - basename = get_uniquefn(outpath, basename, 'obj') |
432 |
| - mesh_fi = os.path.join(outpath, basename + '.obj') |
| 430 | + mesh_fi = get_uniquefn(outpath, basename, 'obj') |
433 | 431 |
|
434 | 432 | print(f"\nGenerating inpainted mesh .. (go make some coffee) ..")
|
435 | 433 |
|
|
0 commit comments