UAE-RS icon indicating copy to clipboard operation
UAE-RS copied to clipboard

Question about the Zurich Summer dataset

Open cuge1995 opened this issue 2 years ago • 4 comments

Thanks for this excellent work! The dataset I download is different from what you present in README

Yours
│   ├── Zurich/    
|   |   ├── img/
|   |   ├── gt/
|   |   ├── ...
Download in your link
│   ├── Zurich/    
|   |   ├── images_tif/
|   |   ├── groundtruth/
|   |   ├── ...

and the filename is also different, resulting that we cannot reading the data in your code, can you explain why?

cuge1995 avatar Jan 19 '23 03:01 cuge1995

Hi, thanks for your interest in our work. It seems that the data owners have replaced the original Zurich Summer dataset with a new version. You can refer to the data shared in this repo for the original version.

YonghaoXu avatar Jan 19 '23 18:01 YonghaoXu

Thanks, it works! However, another bug occurs. Since the gt/ does not include the .png file, I changed seg_dataset.py line 47 to label_file = osp.join(root_dir, "gt/%s" % name), and the bug is:

File "pretrain_seg.py", line 146, in main
    seg_loss_value = seg_loss(pre_output, labels)
  File "/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/lib/python3.8/site-packages/torch/nn/modules/loss.py", line 1150, in forward
    return F.cross_entropy(input, target, weight=self.weight,
  File "/lib/python3.8/site-packages/torch/nn/functional.py", line 2846, in cross_entropy
    return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)
RuntimeError: only batches of spatial targets supported (3D tensors) but got targets of size: : [32, 3, 256, 256]

and the shape of 'pre_output and labels' are torch.Size([32, 8, 256, 256]) torch.Size([32, 256, 256, 3])

cuge1995 avatar Jan 24 '23 09:01 cuge1995

Please manually convert the original mask files (in .tif) into the .png format, where the pixel values range from 0 to num_classes-1.

YonghaoXu avatar Jan 24 '23 20:01 YonghaoXu

share the code

from PIL import Image
import os

def tif_to_png(file_path, num_classes):
    # Open the TIF file
    img = Image.open(file_path)
    # Convert the image to grayscale
    img = img.convert("L")

    # Convert the pixel values to range from 0 to num_classes-1
    img = img.point(lambda x: x / 256 * (num_classes - 1))

    # Save the image as PNG
    new_file_path = file_path.replace('.tif', '.png')
    img.save(new_file_path)

cuge1995 avatar Feb 06 '23 10:02 cuge1995