修改下面代码使其忽略标签并依次选择索引,读取对应的图像序列路径(imgs_path),函数通过调用 self.loader() 函数来加载图像并一起返回 def getitem(self, index): current_index = np.random.choice(range(0, self.num_samples)) imgs_path = self.imgseqs[current_index].split() current_imgs = [] current_imgs_path = imgs_path[:len(imgs_path) - 1] current_label_path = imgs_path[len(imgs_path) - 1] current_label = self.loader(current_label_path)
时间: 2023-06-08 19:07:21 浏览: 88
def getitem(self, index):
current_index = index % self.num_samples
imgs_path = self.imgseqs[current_index].split()
current_imgs = []
current_imgs_path = [path for path in imgs_path[:-1] if not path.startswith("<")]
for img_path in current_imgs_path:
current_img = self.loader(img_path)
current_imgs.append(current_img)
current_label_path = [path for path in imgs_path if path.startswith("<")][0][1:-1]
current_label = self.loader(current_label_path)
return current_imgs, current_label
相关问题
修改下面代码使其去掉标签并顺序选择索引,读取对应的图像序列路径(imgs_path),函数通过调用 self.loader() 函数来加载标签图像并一起返回 def getitem(self, index): current_index = np.random.choice(range(0, self.num_samples)) imgs_path = self.imgseqs[current_index].split() current_imgs = [] current_imgs_path = imgs_path[:len(imgs_path) - 1] current_label_path = imgs_path[len(imgs_path) - 1] current_label = self.loader(current_label_path)
def getitem(self, index):
current_imgs_path = self.imgseqs[index].split()[:-1]
current_label_path = self.imgseqs[index].split()[-1]
current_label = self.loader(current_label_path)
current_imgs = [self.loader(img_path) for img_path in current_imgs_path]
return current_imgs, current_label
修改下面代码使其顺序选择索引,读取对应的图像序列路径(imgs_path),函数通过调用 self.loader() 函数来加载标签图像并一起返回 def getitem(self, index): current_index = np.random.choice(range(0, self.num_samples)) imgs_path = self.imgseqs[current_index].split() current_imgs = [] current_imgs_path = imgs_path[:len(imgs_path) - 1] current_label_path = imgs_path[len(imgs_path) - 1] current_label = self.loader(current_label_path)
def getitem(self, index):
current_index = index % self.num_samples
imgs_path = self.imgseqs[current_index].split()
current_imgs = []
current_imgs_path = imgs_path[:len(imgs_path) - 1]
current_label_path = imgs_path[len(imgs_path) - 1]
current_label = self.loader(current_label_path)
return current_imgs, current_label, current_imgs_path
阅读全文