代码拉取完成,页面将自动刷新
同步操作将从 EricMing/deeptesla 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python
from __future__ import division
import random
import os
import sys
from collections import OrderedDict
import cv2
import params
import preprocess
import local_common as cm
################ parameters ###############
data_dir = params.data_dir
epochs = params.epochs
img_height = params.img_height
img_width = params.img_width
img_channels = params.img_channels
purposes = ['train', 'val']
imgs = OrderedDict()
wheels = OrderedDict()
for purpose in purposes:
imgs[purpose] = []
wheels[purpose] = []
# load all preprocessed training images into memory
def load_imgs():
global imgs
global wheels
for p in purposes:
for epoch_id in epochs[p]:
print 'processing and loading "{}" epoch {} into memory, current num of imgs is {}...'.format(
p, epoch_id, len(imgs[p]))
vid_path = cm.jn(data_dir, 'epoch{:0>2}_front.mkv'.format(epoch_id))
assert os.path.isfile(vid_path)
frame_count = cm.frame_count(vid_path)
cap = cv2.VideoCapture(vid_path)
csv_path = cm.jn(data_dir, 'epoch{:0>2}_steering.csv'.format(epoch_id))
assert os.path.isfile(csv_path)
rows = cm.fetch_csv_data(csv_path)
assert frame_count == len(rows)
yy = [[float(row['wheel'])] for row in rows]
while True:
ret, img = cap.read()
if not ret:
break
img = preprocess.preprocess(img)
imgs[p].append(img)
wheels[p].extend(yy)
assert len(imgs[p]) == len(wheels[p])
cap.release()
def load_batch(purpose):
p = purpose
assert len(imgs[p]) == len(wheels[p])
n = len(imgs[p])
assert n > 0
ii = random.sample(xrange(0, n), params.batch_size)
assert len(ii) == params.batch_size
xx, yy = [], []
for i in ii:
xx.append(imgs[p][i])
yy.append(wheels[p][i])
return xx, yy
if __name__ == '__main__':
load_imgs()
load_batch()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。