Visitar URL original
fix path concatenation in `make_labeled_images_from_dataframe` · DeepLabCut/DeepLabCut@c8ca7e0 · GitHub
Skip to content

Commit c8ca7e0

Browse files
committed
fix path concatenation in make_labeled_images_from_dataframe
1 parent 2140b4a commit c8ca7e0

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

‎deeplabcut/utils/visualization.py‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def prepare_figure_axes(width, height, scale=1.0, dpi=100):
299299
def make_labeled_images_from_dataframe(
300300
df,
301301
cfg,
302-
destfolder="",
302+
destfolder=None,
303303
scale=1.0,
304304
dpi=100,
305305
keypoint="+",
@@ -315,7 +315,7 @@ def make_labeled_images_from_dataframe(
315315
through pandas.read_csv() or pandas.read_hdf().
316316
cfg : dict
317317
Project configuration.
318-
destfolder : string, optional
318+
destfolder : str or Path, optional
319319
Destination folder into which images will be stored. By default, same location as the labeled data.
320320
Note that the folder will be created if it does not exist.
321321
scale : float, optional
@@ -370,9 +370,11 @@ def make_labeled_images_from_dataframe(
370370
ind_bones = tuple(zip(*bones, strict=False))
371371

372372
images_list = [str(Path(cfg["project_path"]).joinpath(*tuple_)) for tuple_ in df.index.tolist()]
373-
if not destfolder:
374-
destfolder = str(Path(images_list[0]).parent)
375-
tmpfolder = str(destfolder) + "_labeled"
373+
if destfolder is None:
374+
destfolder = Path(images_list[0]).parent
375+
else:
376+
destfolder = Path(destfolder)
377+
tmpfolder = destfolder.parent / (destfolder.name + "_labeled")
376378
auxiliaryfunctions.attempt_to_make_folder(tmpfolder)
377379
ic = io.imread_collection(images_list)
378380

@@ -409,7 +411,7 @@ def make_labeled_images_from_dataframe(
409411
imagename = Path(filename).name
410412
fig.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)
411413
fig.savefig(
412-
Path(tmpfolder) / imagename.replace(".png", f"_{color_by}.png"),
414+
tmpfolder / imagename.replace(".png", f"_{color_by}.png"),
413415
dpi=dpi,
414416
)
415417
plt.close(fig)
@@ -431,7 +433,7 @@ def make_labeled_images_from_dataframe(
431433
imagename = Path(filename).name
432434
fig.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)
433435
fig.savefig(
434-
Path(tmpfolder) / imagename.replace(".png", f"_{color_by}.png"),
436+
tmpfolder / imagename.replace(".png", f"_{color_by}.png"),
435437
dpi=dpi,
436438
)
437439
plt.close(fig)

0 commit comments

Comments
 (0)