我试图创建pandas dataframe并根据保存在csv文件中的图像ID从目录中读取图像。csv文件包括稍后用于回归任务的图像ID和标签。加载脚本时,图像不会存储在image变量中。有人能帮我更正这个脚本吗
labelPath = "E:/Notebooks/labels.csv" #path for the csv file
cols = ["id","label"] #defining the columns name in the csv file
all_df = pd.read_csv(labelPath, sep=",", header=None, names=cols)
def read_img(self,id, folder='image_files'):
images=[]
"""
Read image by it's id
"""
file='E:/Notebooks/' + folder + '/' + str(id) + '.tif'
for filepath in os.listdir(file):
images.append(cv2.imread(file+'/{0}'.format(filepath),flags=(cv2.IMREAD_ANYCOLOR | cv2.IMREAD_ANYDEPTH)))
return images
更新:csv文件中数据的示例
目前没有回答
相关问题 更多 >
编程相关推荐