4cb6414084163db7fb5bf5f0e29a4c19009dcad0,rastervision_pytorch_backend/rastervision/pytorch_backend/pytorch_semantic_segmentation.py,PyTorchSemanticSegmentationSampleWriter,write_sample,#PyTorchSemanticSegmentationSampleWriter#Any#,15

Before Change



        img_path = join(img_dir, "{}-{}.png".format(sample.scene_id,
                                                    self.sample_ind))
        labels_path = join(
            labels_dir, "{}-{}.png".format(sample.scene_id, self.sample_ind))
        save_img(sample.chip, img_path)
        save_img(label_arr, labels_path)

        self.sample_ind += 1

After Change


        
        split_name = "train" if sample.is_train else "valid"

        sample_dir = Path(self.sample_dir)
        img_dir = sample_dir / split_name / "img"
        label_dir = sample_dir / split_name / "labels"

        make_dir(img_dir)
        make_dir(label_dir)

        img = sample.chip
        label_arr = sample.labels.get_label_arr(sample.window).astype(np.uint8)

        img_fmt, label_fmt = self.img_format, self.label_format
        sample_name = f"{sample.scene_id}-{self.sample_ind}"

        // write image
        img_filename = f"{sample_name}.{img_fmt}"
        img_path = img_dir / img_filename
        if img_fmt == "npy":
            np.save(img_path, img)
        else:
            save_img(img, img_path)

        // write labels
        label_filename = f"{sample_name}.{label_fmt}"
        label_path = label_dir / label_filename
        if label_fmt == "npy":
            np.save(label_path, label_arr)
        else:
            save_img(label_arr, label_path)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: azavea/raster-vision
Commit Name: 4cb6414084163db7fb5bf5f0e29a4c19009dcad0
Time: 2020-08-19
Author: AdeelH@users.noreply.github.com
File Name: rastervision_pytorch_backend/rastervision/pytorch_backend/pytorch_semantic_segmentation.py
Class Name: PyTorchSemanticSegmentationSampleWriter
Method Name: write_sample


Project Name: pantsbuild/pants
Commit Name: 79ba58636288f95be1a156f02623d46b0eb242ea
Time: 2019-09-07
Author: ericarellano@me.com
File Name: tests/python/pants_test/build_graph/test_target.py
Class Name: TargetTest
Method Name: test_target_id_long


Project Name: pantsbuild/pants
Commit Name: 79ba58636288f95be1a156f02623d46b0eb242ea
Time: 2019-09-07
Author: ericarellano@me.com
File Name: tests/python/pants_test/build_graph/test_target.py
Class Name: TargetTest
Method Name: test_target_id_short