cs230-stanford / cs230-code-examples

Code examples in pyTorch and Tensorflow for CS230
Other
3.79k stars 984 forks source link

Error when run build_dataset.py on windows #17

Open Amin-Tgz opened 5 years ago

Amin-Tgz commented 5 years ago

In Windows OS, folder names in a path join together with back slash [ \ ] instead of slash [ / ] like this:

C:\Program Files\NVIDIA GPU Computing Toolkit

so build_dataset.py throw an error. because it can't split filename from directory.

I solve it by replace the slash with double back slash '\'

image.save(os.path.join(output_dir, **filename.split('\\')[-1])**)

Thanks.

3a1b2c3 commented 8 months ago

def resize_and_save(filename, output_dir, size=SIZE): """Resize the image contained in filename and save it to the output_dir""" image = Image.open(filename)

Use bilinear interpolation instead of the default "nearest neighbor" method

image = image.resize((size, size), Image.BILINEAR)
image.save(os.path.join(output_dir, filename.split(os.sep)[-1]))