cs230-stanford / website-2018-winter

90 stars 59 forks source link

got some problem while running build_database.py using Windows #5

Open 12ycli opened 6 years ago

12ycli commented 6 years ago

As tutorial says,for getting down-sized pics we should run build_database.py.However,a small problem occurred because Linux and Windows use different file directory separation mark.Function below should change filename.split('/')[-1])) into filename.split('\\')[-1])) while using Windows.

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('/')[-1]))
omoindrot commented 6 years ago

A better way would be to use os.path.basename instead of filename.split('/')[-1].