提交 19b3be8f 编写于 作者: C CrossLee1 提交者: qingqing01

fix vc bug (#1297)

上级 a6c45e92
...@@ -111,7 +111,6 @@ According to the congfiguration of evaluation, the output log is like: ...@@ -111,7 +111,6 @@ According to the congfiguration of evaluation, the output log is like:
Inference is used to get prediction score or video features based on trained models. Inference is used to get prediction score or video features based on trained models.
``` ```
python infer.py \ python infer.py \
--batch_size=128 \
--class_dim=101 \ --class_dim=101 \
--image_shape=3,224,224 \ --image_shape=3,224,224 \
--with_mem_opt=True \ --with_mem_opt=True \
......
...@@ -9,27 +9,33 @@ for line in f.readlines(): ...@@ -9,27 +9,33 @@ for line in f.readlines():
dd[name.lower()] = int(label) - 1 dd[name.lower()] = int(label) - 1
f.close() f.close()
# generate pkl
path = 'train/' def generate_pkl(mode):
savepath = 'train_pkl/' # generate pkl
if not os.path.exists(savepath): path = '%s/' % mode
os.makedirs(savepath) savepath = '%s_pkl/' % mode
if not os.path.exists(savepath):
fw = open('train.list', 'w') os.makedirs(savepath)
for folder in os.listdir(path):
vidid = folder.split('_', 1)[1] fw = open('%s.list' % mode, 'w')
this_label = dd[folder.split('_')[1].lower()] for folder in os.listdir(path):
this_feat = [] vidid = folder.split('_', 1)[1]
for img in sorted(os.listdir(path + folder)): this_label = dd[folder.split('_')[1].lower()]
fout = open(path + folder + '/' + img, 'rb') this_feat = []
this_feat.append(fout.read()) for img in sorted(os.listdir(path + folder)):
fout.close() fout = open(path + folder + '/' + img, 'rb')
this_feat.append(fout.read())
res = [vidid, this_label, this_feat] fout.close()
outp = open(savepath + vidid + '.pkl', 'wb') res = [vidid, this_label, this_feat]
cPickle.dump(res, outp, protocol=cPickle.HIGHEST_PROTOCOL)
outp.close() outp = open(savepath + vidid + '.pkl', 'wb')
cPickle.dump(res, outp, protocol=cPickle.HIGHEST_PROTOCOL)
fw.write('data/train_pkl/%s.pkl\n' % vidid) outp.close()
fw.close()
fw.write('data/%s/%s.pkl\n' % (savepath, vidid))
fw.close()
generate_pkl('train')
generate_pkl('test')
...@@ -16,8 +16,8 @@ THREAD = 8 ...@@ -16,8 +16,8 @@ THREAD = 8
BUF_SIZE = 1024 BUF_SIZE = 1024
TRAIN_LIST = 'data/train.list' TRAIN_LIST = 'data/train.list'
TEST_LIST = 'data/val.list' TEST_LIST = 'data/test.list'
INFER_LIST = 'data/val.list' INFER_LIST = 'data/test.list'
img_mean = np.array([0.485, 0.456, 0.406]).reshape((3, 1, 1)) img_mean = np.array([0.485, 0.456, 0.406]).reshape((3, 1, 1))
img_std = np.array([0.229, 0.224, 0.225]).reshape((3, 1, 1)) img_std = np.array([0.229, 0.224, 0.225]).reshape((3, 1, 1))
......
...@@ -2,6 +2,7 @@ import os ...@@ -2,6 +2,7 @@ import os
import numpy as np import numpy as np
import time import time
import sys import sys
import paddle.v2 as paddle
import paddle.fluid as fluid import paddle.fluid as fluid
from resnet import TSN_ResNet from resnet import TSN_ResNet
import reader import reader
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册