A peaknet API with pytorch backbone
conda activate ana-1.4.22
To build/test the python, cd to the directory containing setup.py and execute the following commands:
mkdir -p install/lib/python2.7/site-packagesexport PYTHONPATH=`pwd`/install/lib/python2.7/site-packagespython setup.py develop --prefix=`pwd`/install
from peaknet.Peaknet import Peaknet
peaknet = Peaknet(use_cuda=True) # Init a Peaknet instance
peaknet.loadDefaultCFG() # Load newpeaksv10 network and pretrained weights
Default model file lives at /reg/common/package/peaknet/model.pt
peaknet.predict( imgs )
imgs is a numpy array with dimensions (n,m,h,w). imgs will be treated as a stack of nxm tiles.
peaknet.train( imgs, labels, box_size = 7 )
imgs is a numpy array with dimensions (n,m,h,w). imgs will be treated as a stack of nxm tiles.
labels is a list of tutple of length n. Each item in the list is a tutple of three numpy arrays s, r, c, where s is an array of integers 0~(m-1).
peaknet.model
returns the current model
peaknet.updateModel( newModel )
replaces the current model with newModel, including the network and the weights
peaknet.updateGrad( newModel )
replaces gradients in the current model with that from newModel. newModel must have same network as current model.
peaknet.optimize()
performs one step of SGD optimization.