代码拉取完成,页面将自动刷新
import os
import pandas as pd
import numpy as np
import shutil
dir = "/ext/Data/distracted_driver_detection/"
driver_imgs_list_csv = os.path.join(dir, "driver_imgs_list.csv")
valid_subjects = ['p081','p075']
if not os.path.exists(dir + "valid"):
os.mkdir(dir + "valid")
for i in range(10):
os.mkdir(dir + "valid/c%d"%i)
df = pd.read_csv(driver_imgs_list_csv)
for valid_subject in valid_subjects:
df_valid = df[(df["subject"]==valid_subject)]
for index, row in df_valid.iterrows():
subpath = row["classname"] + "/" + row["img"]
if os.path.exists(os.path.join(dir,"train",subpath)):
shutil.move(os.path.join(dir,"train",subpath), os.path.join(dir,"valid",subpath),)
else:
print("cannot move {} : {}".format(row["subject"],subpath))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。