示例#1
0
import caffe
from caffe import surgery, score

import numpy as np
import os

import setproctitle
setproctitle.setproctitle(os.path.basename(os.getcwd()))

weights = '../fcn16s-heavy-72k.caffemodel'

# init
caffe.set_device(int(sys.argv[1]))
caffe.set_mode_gpu()

solver = caffe.SGDSolver('solver.prototxt')
solver.net.copy_from(weights)

# surgeries
interp_layers = [k for k in solver.net.params.keys() if 'up' in k]
surgery.interp(solver.net, interp_layers)

# scoring
val = np.loadtxt('../data/segvalid11.txt', dtype=str)

for _ in range(25):
    solver.step(4000)
    score.seg_tests(solver, False, val, layer='score')
示例#2
0
import sys
sys.path.append('../../python')

import caffe
from caffe import surgery, score

import numpy as np
import os

weights = '/home/shelhamer/dpb/exp/vgg16fc.caffemodel'

caffe.set_phase_train()
caffe.set_mode_gpu()
caffe.set_device(1)

solver = caffe.SGDSolver('solver.prototxt')
solver.net.copy_from(weights)

interp_layers = [k for k in solver.net.params.keys() if 'up' in k]
surgery.interp(solver.net, interp_layers)

for _ in range(30):
    print 'epoch {}'.format(_)
    solver.step(1087)
    score.boundary_eval(solver, ('bsds', 'val'), layer='prob')