libffcv / ffcv-imagenet

Train ImageNet *fast* in 500 lines of code with FFCV
Apache License 2.0
136 stars 34 forks source link

Question about the parameter of the `write_imagenet.py` #8

Closed mzhaoshuai closed 2 years ago

mzhaoshuai commented 2 years ago

@lengstrom Thanks for your wonderful work!

I have a question about the parameters of the write_imagenet.py.

From the repo of ffcv, we can see https://github.com/libffcv/ffcv/blob/bfd9b3d85e31360fada2ecf63bea5602e4774ba3/ffcv/fields/rgb_image.py#L337

        write_mode = self.write_mode
        as_jpg = None

        if write_mode == 'smart':
            as_jpg = encode_jpeg(image, self.jpeg_quality)
            write_mode = 'raw'
            if self.smart_threshold is not None:
                if image.nbytes > self.smart_threshold:
                    write_mode = 'jpg'
        elif write_mode == 'proportion':
            if np.random.rand() < self.proportion:
                write_mode = 'jpg'
            else:
                write_mode = 'raw'

The default write mode in https://github.com/libffcv/ffcv-imagenet/blob/main/write_imagenet.py is smart, and the smart_threshold is None. So the script is actually running in RAW write mode?

Related issues are https://github.com/libffcv/ffcv-imagenet/issues/1

lengstrom commented 2 years ago

The script should use proportion as is passed in the actual execution script here: https://github.com/libffcv/ffcv-imagenet/blob/main/write_imagenet.sh

mzhaoshuai commented 2 years ago

Thx for your reply. I make a mistake.