Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为什么显示无标签的数据集仍要读取标签 #174

Open
HakuuZalem opened this issue Nov 8, 2024 · 3 comments
Open

为什么显示无标签的数据集仍要读取标签 #174

HakuuZalem opened this issue Nov 8, 2024 · 3 comments

Comments

@HakuuZalem
Copy link

HakuuZalem commented Nov 8, 2024

dset = city_dset(cfg["data_root"], cfg["data_list"], trs_form, seed, n_sup, split)
dset_unsup = city_dset(
cfg["data_root"], data_list_unsup, trs_form_unsup, seed, n_sup, split
)
这两个都是使用的city_dset获取数据信息,而city_dset下面的类中似乎没有对有标签的和无标签的进行区分。

class city_dset(BaseDataset):
def init(self, data_root, data_list, trs_form, seed, n_sup, split="val"):
super(city_dset, self).init(data_list)
self.data_root = data_root
self.transform = trs_form
random.seed(seed)
if len(self.list_sample) >= n_sup and split == "train":
self.list_sample_new = random.sample(self.list_sample, n_sup)
elif len(self.list_sample) < n_sup and split == "train":
num_repeat = math.ceil(n_sup / len(self.list_sample))
self.list_sample = self.list_sample * num_repeat

        self.list_sample_new = random.sample(self.list_sample, n_sup)
    else:
        self.list_sample_new = self.list_sample
def __getitem__(self, index):
    # load image and its label
    image_path = os.path.join(self.data_root, self.list_sample_new[index][0])
    label_path = os.path.join(self.data_root, self.list_sample_new[index][1])
    image = self.img_loader(image_path, "RGBA")
    label = self.img_loader(label_path, "L")
    image, label = self.transform(image, label)
    return image[0], label[0, 0].long()
def __len__(self):
    return len(self.list_sample_new)
@Ahrenat
Copy link

Ahrenat commented Nov 28, 2024

我也遇到了这个问题,看了一下代码,似乎是因为数据增强是统一对原图和标签进行的,为了方便,无标签数据也复用了这套流程。

@HakuuZalem
Copy link
Author

HakuuZalem commented Nov 30, 2024 via email

@Ahrenat
Copy link

Ahrenat commented Dec 3, 2024

因为标签这一部分最终并不会用到,所以我把原图copy了一份,放入原本应该存放标签的位置。这样做只是为了能够顺利通过代码,但从训练效率上来说,最好还是重写有标签和无标签的数据预处理部分~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants