下⾯的代码更适合本⽂,貌似是少了⼀个for
import cv2
from skimage import measure, color
asure import regionprops
import numpy as np
配置windows update失败>8月再见9月你好的句子import os
import copy
def skimageFilter(gray):
binary_warped = py(gray)
binary_warped[binary_warped > 0.1] = 255
厉致诚表白林浅
gray = (np.dstack((gray, gray, gray))*255).astype('uint8')
labels = measure.label(gray[:, :, 0], connectivity=1)
dst = color.label2rgb(labels,bg_label=0, bg_color=(0,0,0))
gray = cv2.cvtColor(np.uint8(dst*255), cv2.COLOR_RGB2GRAY)
return binary_warped, gray
def moveImageTodir(path,targetPath,name):美菱冰箱温度调节
if os.path.isdir(path):
image_name = "gt_image/"+str(name)+".png"
binary_name = "gt_binary_image/"+str(name)+".png"
instance_name = "gt_instance_image/"+str(name)+".png"
train_rows = image_name + " " + binary_name + " " + instance_name + "\n"
origin_img = cv2.imread(path+"/img.png")
茶花origin_img = size(origin_img, (1280,720))
cv2.imwrite(targetPath+"/"+image_name, origin_img)
img = cv2.imread(path+'/label.png')
杨梅怎么洗img = size(img, (1280,720))
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
binary_warped, instance = skimageFilter(gray)
cv2.imwrite(targetPath+"/"+binary_name, binary_warped)
cv2.imwrite(targetPath+"/"+instance_name, instance)
print("success create data name is : ", train_rows)
return train_rows
return None
if __name__ == "__main__":
count = 1
with open("THE PATH TO YOUR /", 'w+') as file:
#for images_dir in os.listdir("./images"):
dir_name = os.path.join("THE PATH TO YOUR/annotations")
for annotations_dir in os.listdir(dir_name):
json_dir = os.path.join(dir_name, annotations_dir)
if os.path.isdir(json_dir):
train_rows = moveImageTodir(json_dir, "THE PATH TO YOUR SAVE DIR", str(count).zfill(4))
file.write(train_rows)
count += 1
Final,将上述三个⽂件夹与⼀个TXT⽂件拷贝⼊lanenet-lane-detection-master\data\training_data_example⽂件夹下
(4)数据集处理:TuSimple数据集---->Tfrecords
这块⼉是我⽐较迷惑的,整理⼀下既有的类似博客的主流做法,⼤致有以下⼏种做法
做法⼀:来源⽂章::
步骤:python data_provider/lanenet_data_feed_pipline.py --dataset_dir ./data/training_data_example/training/ --tfrecords_dir ./data/training_data_example/tfrecords
发布评论