1 | # Install Jupyterextension package |
install
1 | pip install jupyter_contrib_nbextensions |
热爱平淡,向往未知
1 | # Install Jupyterextension package |
1 | pip install jupyter_contrib_nbextensions |
1 | http://mirrors.nju.edu.cn/tensorflow/linux/gpu |
1 | pip install opencv-python |
c++, java 有统一的入口main函数
python 也就是从脚本第一行开始运行,没有统一的入口
1 | >>> from easydict import EasyDict as edict |
https://github.com/makinacorpus/easydict
1 | def parse_args(): |
获得当前路径
1 | import os.path as osp |
大小写敏感
缩进时不允许使用Tab键,只允许使用空格。
1 | for k, v in zip(cfg_list[0::2], cfg_list[1::2]): |
1 | if not os.path.isfile(caffemodel): |
用 {} .format 代替 %s %
1 | print '\n\nLoaded network {:s}'.format(caffemodel) |
1 | cv2.imread(im_file) |
1 | cls_scores |
1 | order = scores.argsort() |
1 | im = im[:, :, (2, 1, 0)] |
1 | im_orig = im.astype(np.float32, copy=True) |
1 | im = cv2.resize(im_orig, None, None, fx=im_scale, fy=im_scale,interpolation=cv2.INTER_LINEAR) |
1 | max_shape = np.array([im.shape for im in ims]).max(axis=0) # 每一位取最大的 |
solvers = [[net_name, n, ‘stage1_rpn_solver60k80k.pt’],
[net_name, n, ‘stage1_fast_rcnn_solver30k40k.pt’]]
solvers = [os.path.join(cfg.MODELS_DIR, *s) for s in solvers]
1 | # fix the random seeds (numpy and caffe) for reproducibility |
1 | for year in ['2007', '2012']: |
1 | self._class_to_ind = dict(zip(self.classes, xrange(self.num_classes))) |
1 | assert os.path.exists(image_set_file), \ |
1 | with open(image_set_file) as f: |
1 | net = caffe.Net(prototxt, caffemodel, caffe.TEST) |
Blob是Caffe的基本数据结构,具有CPU和GPU之间同步的能力,它是4维的数组(Num, Channels, Height, Width)
访问data或diff有两种方法:
1 | const Dtype* cpu_data() const; //不修改值 |
1 | with open(cache_file, 'wb') as fid: |
1 | self.solver = caffe.SGDSolver(solver_prototxt) |
1 | set -x 输出执行的命令 |
1 | set -x set -o xtrace 执行命令之前打印命令。 |
1 | git clone --recursive https://github.com/rbgirshick/py-faster-rcnn.git |
可以直接把caffe-faster-rcnn替换成caffe最新版
1 | cd $FRCN_ROOT/lib |
解决:
1 | lib/fast_rcnn/train.py |
1 | # set path of lastest caffe and caffe in py-faster-rcnn |
1 | open -a "QuickTime Player" ~/Desktop/filename.mp4 |