今天看yolov3的代码,读取img和label的时候,感觉写的很简洁,记录下来,以后有类似场景可以优雅一下。
with open(list_path, "r") as file:
self.img_files = file.readlines()
label_files = [
path.replace("images", "labels").replace(".png", ".txt").replace(".jpg", ".txt")
for path in self.img_files
]