7d9db23a389499c2764fb850cd19f853cc3e8565,ludwig/features/image_feature.py,ImageBaseFeature,add_feature_data,#Any#Any#Any#Any#Any#,192

Before Change


                    (num_images, height, width, num_channels),
                    dtype=np.uint8
                )
                for i in range(len(dataset_df)):
                    filepath = get_abs_path(
                        csv_path,
                        dataset_df[feature["name"]][i]
                    )

                    img = ImageBaseFeature._read_image_and_resize(
                        filepath,
                        width,
                        height,
                        should_resize,
                        num_channels,
                        preprocessing_parameters["resize_method"],
                        user_specified_num_channels
                    )

                    image_dataset[i, :height, :width, :] = img

            data[feature["name"]] = np.arange(num_images)


class ImageInputFeature(ImageBaseFeature, InputFeature):

After Change


            resize_method=preprocessing_parameters["resize_method"],
            user_specified_num_channels=user_specified_num_channels
        )
        all_file_paths = [get_abs_path(csv_path, file_path)
                          for file_path in dataset_df[feature["name"]]]

        if feature["preprocessing"]["in_memory"]:
            data[feature["name"]] = np.empty(
                (num_images, height, width, num_channels),
                dtype=np.uint8
            )
            with Pool(5) as pool:
                logger.info("Using 5 processes for preprocessing images")
                data[feature["name"]] = np.array(
                    pool.map(read_image_and_resize, all_file_paths)
                )
        else:
            data_fp = os.path.splitext(dataset_df.csv)[0] + ".hdf5"
            mode = "w"
            if os.path.isfile(data_fp):
                mode = "r+"

            with h5py.File(data_fp, mode) as h5_file:
                image_dataset = h5_file.create_dataset(
                    feature["name"] + "_data",
                    (num_images, height, width, num_channels),
                    dtype=np.uint8
                )
                for i, filepath in enumerate(all_file_paths):
                    image_dataset[i, :height, :width, :] = \
                        read_image_and_resize(filepath)

            data[feature["name"]] = np.arange(num_images)


class ImageInputFeature(ImageBaseFeature, InputFeature):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 8

Instances


Project Name: uber/ludwig
Commit Name: 7d9db23a389499c2764fb850cd19f853cc3e8565
Time: 2019-08-08
Author: smiryala@uber.com
File Name: ludwig/features/image_feature.py
Class Name: ImageBaseFeature
Method Name: add_feature_data


Project Name: ray-project/ray
Commit Name: dcb9e03fde3116f7c43787947ea6f0b37ddb3210
Time: 2020-09-08
Author: rkooo567@gmail.com
File Name: python/ray/tests/test_placement_group.py
Class Name:
Method Name: test_atomic_creation


Project Name: keras-team/keras
Commit Name: b95fcf7f52aca8ad0b1afb3cfc64c8eed534fafe
Time: 2017-07-29
Author: me@taehoonlee.com
File Name: tests/keras/backend/backend_test.py
Class Name: TestBackend
Method Name: test_function


Project Name: uber/ludwig
Commit Name: 5667af96dade79ef77194d519182d4989494b3a4
Time: 2019-08-25
Author: smiryala@uber.com
File Name: ludwig/features/image_feature.py
Class Name: ImageBaseFeature
Method Name: add_feature_data