示例#1
0
#
host = "-h vision.nps.edu"

#
# create a simple RunSet with just one unlabeled image
#
rs1 = easy.createRunSet("testImg/italia.jpg")

#
# Make sure all files in the RunSet are available on the remote site;
# it is the client's responsibility to upload them if not.
# The putResult contains information about which files were actually transferred.
#
print("------- Remote detection, local result display: -------")
fileserver = easy.getFileServer("PythonFileService:default -p 10111 " + host)
putResult = easy.putAllFiles(fileserver, rs1)
modelfile = "detectors/haarcascade_frontalface_alt.xml"
if not fileserver.exists(easy.getCvacPath(modelfile)):
    easy.putFile(fileserver, easy.getCvacPath(modelfile))

#
# detect remotely: note the host specification
#
detector = easy.getDetector("OpenCVCascadeDetector:default -p 10102 " + host)
results = easy.detect(detector, modelfile, rs1)
easy.printResults(results)

#
# Example 2:
# Train on a remote machine, obtain the model file, and test locally.
# Assume the files are on the remote machine, or transfer with putAllFiles.
示例#2
0
# specify the host name of the service
#
host = "-h vision.nps.edu"

#
# create a simple RunSet with just one unlabeled image
#
rs1 = easy.createRunSet( "testImg/italia.jpg" )

#
# Make sure all files in the RunSet are available on the remote site;
# it is the client's responsibility to upload them if not.
# The putResult contains information about which files were actually transferred.
#
fileserver = easy.getFileServer( "FileService:default -p 10110 " + host )
putResult = easy.putAllFiles( fileserver, rs1 )
modelfile = "detectors/haarcascade_frontalface_alt.xml"
if not fileserver.exists( easy.getCvacPath(modelfile) ):
    easy.putFile( fileserver, easy.getCvacPath(modelfile) )

#
# detect remotely: note the host specification
#
print("------- Remote detection, local result display: -------")
detector = easy.getDetector( "OpenCVCascadeDetector:default -p 10102 "+host )
results = easy.detect( detector, modelfile, rs1 )
easy.printResults( results )

#
# Example 2:
# Train on a remote machine, obtain the model file, and test locally.
示例#3
0
文件: demo.py 项目: dexter1691/CVAC
#
# add all samples from corpus to a RunSet,
# also obtain a mapping from class ID to label name
#
res = easy.createRunSet( categories )
runset = res['runset']
classmap = res['classmap']

#
# Make sure all files in the RunSet are available on the remote site;
# it is the client's responsibility to upload them if not.
#
host = "-h localhost"
#host = "-h vision.nps.edu"
fileserver = easy.getFileServer( "FileService:default -p 10110 " + host )
putResult = easy.putAllFiles( fileserver, runset )

#
# Connect to a trainer service, train on the RunSet
#
trainer = easy.getTrainer( "bowTrain:default -p 10103 " + host )
trainedModel = easy.train( trainer, runset )
print("Training model stored in file: " + easy.getFSPath( trainedModel.file ))

#
# Connect to a detector service,
# test on the training RunSet for validation purposes;
# The detect call takes the detector, the trained model, the
# runset, and a mapping from purpose to label name
#
detector = easy.getDetector( "bowTest:default -p 10104 " + host )