加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
generate_csv.py 763 Bytes
一键复制 编辑 原始数据 按行查看 历史
import os
import csv
read_train = open("train.txt", "r").readlines()
with open("train.csv", mode="w", newline="") as train_file:
for line in read_train:
image_file = line.split("/")[-1].replace("\n", "")
text_file = image_file.replace(".jpg", ".txt")
data = [image_file, text_file]
writer = csv.writer(train_file)
writer.writerow(data)
read_train = open("test.txt", "r").readlines()
with open("test.csv", mode="w", newline="") as train_file:
for line in read_train:
image_file = line.split("/")[-1].replace("\n", "")
text_file = image_file.replace(".jpg", ".txt")
data = [image_file, text_file]
writer = csv.writer(train_file)
writer.writerow(data)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化