def wait():
    # raw_input("Press Enter to continue...")
    pass

# Open a corpus that is specified via a "properties" file;
# note that the path is relative to CVAC.DataDir, as always.
# This doesn't do much yet, it just reads the properties file.
corpus1 = easy.openCorpus( "corpus/CvacCorpusTest.properties" )

# Now let's obtain the labels contained in this corpus.  With
# this particular corpus, the labels are only available if the
# image files are local to the CorpusServer, which in this case is
# the default, local server.  More on that in a moment.
# Images will be downloaded automatically if the createMirror flag
# is set, however, a network connection is required.
categories1, lablist1 = easy.getDataSet( corpus1, createMirror=True )
print("=== Corpus 1: ===");
print('Obtained {0} labeled artifact{1} from corpus1 "{2}":'.format(
    len(lablist1), ("s","")[len(lablist1)==1], corpus1.name ));
easy.printCategoryInfo( categories1 )

# Create a list of labelable files under a directory.
lablist2 = easy.getLabelableList( "trainImg" )
categories2 = easy.getCategories(lablist2)
print("\n=== Corpus 2: ===");
print('Obtained {0} labeled artifact{1} from trainImg directory:'.format(
    len(lablist2), ("s","")[len(lablist2)==1]));
easy.printCategoryInfo( categories2 )

# Note how both corpora contain flag images, but they have different
# labels.  To use them for evaluation, let's assign the same purpose
Exemple #2
0
'''
Easy!  mini tutorial
Obtain labeled data from a LabelMe server.
See http://new-labelme.csail.mit.edu/Release3.0
matz 6/19/2013
'''

import easy

# The properties file for a LabelMe Corpus contains all pertinent information.
# Take a look at corpus/LabelMeCarsTest.properties and pay particular
# attention to the following properties:
# LMFolders and LMObjectNames
corpus = easy.openCorpus( "corpus/LabelMeCarsTest.properties" )
categories, lablist = easy.getDataSet( corpus, createMirror=True )
print('Obtained {0} labeled artifact{1} from corpus "{2}":'.format(
    len(lablist), ("s","")[len(lablist)==1], corpus.name ));
easy.printCategoryInfo( categories )

# draw the images and their annotations, one image at a time,
# at a given maximum size (width, height)
easy.drawLabelables( lablist, (512, 512) )
print("-----------")

# pick a subset: all license plates
license_plates = categories['license plate']
print("There are {0} license plate labels.".format( len(license_plates) ))

# another subset: all labels starting with "car"
cars = []
for key in categories.keys():
Exemple #3
0
'''
Easy!  test for corpus_service.py
Obtain labeled data from a LabelMe server.
See http://new-labelme.csail.mit.edu/Release3.0
matz 6/19/2013
'''

import easy

# The properties file for a LabelMe Corpus contains all pertinent information.
# Take a look at corpus/LabelMeCarsTest.properties and pay particular
# attention to the following properties:
# LMFolders and LMObjectNames
cs = easy.getCorpusServer( "PythonCorpusService:default -p 10021")
corpus = easy.openCorpus( "corpus/LabelMeCircuit.properties", corpusServer=cs )
categories, lablist = easy.getDataSet( corpus, corpusServer=cs, 
                                       createMirror=True )
print('Obtained {0} labeled artifact{1} from corpus "{2}":'.format(
    len(lablist), ("s","")[len(lablist)==1], corpus.name ));
easy.printCategoryInfo( categories )

# draw the images and their annotations, one image at a time,
# at a given maximum size (width, height)
easy.drawLabelables( lablist, (512, 512) )
print("-----------")

# Replace the objname with your object's label.  Note that the
# corpus_fname file name is relative to the CVAC_DataDir which
# is set in config.icebox, config.client, and config.service, and
# which defaults to your installation directory /data.
objname = 'windshield'
#objname = 'bookshelfFrontal'
corpus_fname = 'corpus/labelme_'+objname+'.properties'


# The properties file for a LabelMe Corpus contains all pertinent information.
# Take a look at corpus/LabelMeCarsTest.properties and pay particular
# attention to the following properties:
# LMFolders and LMObjectNames
cs = easy.getCorpusServer( "PythonCorpusService:default -p 10021")
corpus = easy.openCorpus( corpus_fname, corpusServer=cs )
categories, lablist = easy.getDataSet( corpus, corpusServer=cs )
print('Obtained {0} labeled artifact{1} from corpus "{2}":'.format(
    len(lablist), ("s","")[len(lablist)==1], corpus.name ));
easy.printCategoryInfo( categories )

# if desired, you can draw the images and their annotations,
# one image at a time, at a given maximum size (width, height)
#easy.drawLabelables( lablist, (512, 512) )

print("==== Training runset: ====")
posPurpose = easy.getPurpose('pos')
negPurpose = easy.getPurpose('neg')
trainset = cvac.RunSet()
easy.addToRunSet(trainset, categories[objname], posPurpose);
#trainset = easy.createRunSet( categories, purpose=posPurpose );
correct = easy.isProperRunSet(trainset, deleteInvalid=True)
    # raw_input("Press Enter to continue...")
    pass


# Open a corpus that is specified via a "properties" file;
# note that the path is relative to CVAC.DataDir, as always.
# This doesn't do much yet, it just reads the properties file.
corpus1 = easy.openCorpus("corpus/CvacCorpusTest.properties")

# Now let's obtain the labels contained in this corpus.  With
# this particular corpus, the labels are only available if the
# image files are local to the CorpusServer, which in this case is
# the default, local server.  More on that in a moment.
# Images will be downloaded automatically if the createMirror flag
# is set, however, a network connection is required.
categories1, lablist1 = easy.getDataSet(corpus1, createMirror=True)
print("=== Corpus 1: ===")
print('Obtained {0} labeled artifact{1} from corpus1 "{2}":'.format(
    len(lablist1), ("s", "")[len(lablist1) == 1], corpus1.name))
easy.printCategoryInfo(categories1)

# Create a list of labelable files under a directory.
lablist2 = easy.getLabelableList("trainImg")
categories2 = easy.getCategories(lablist2)
print("\n=== Corpus 2: ===")
print('Obtained {0} labeled artifact{1} from trainImg directory:'.format(
    len(lablist2), ("s", "")[len(lablist2) == 1]))
easy.printCategoryInfo(categories2)

# Note how both corpora contain flag images, but they have different
# labels.  To use them for evaluation, let's assign the same purpose
# Replace the objname with your object's label.  Note that the
# corpus_fname file name is relative to the CVAC_DataDir which
# is set in config.icebox, config.client, and config.service, and
# which defaults to your installation directory /data.
objname = 'windshield'
#objname = 'bookshelfFrontal'
corpus_fname = 'corpus/labelme_' + objname + '.properties'

# The properties file for a LabelMe Corpus contains all pertinent information.
# Take a look at corpus/LabelMeCarsTest.properties and pay particular
# attention to the following properties:
# LMFolders and LMObjectNames
cs = easy.getCorpusServer("PythonCorpusService:default -p 10021")
corpus = easy.openCorpus(corpus_fname, corpusServer=cs)
categories, lablist = easy.getDataSet(corpus, corpusServer=cs)
print('Obtained {0} labeled artifact{1} from corpus "{2}":'.format(
    len(lablist), ("s", "")[len(lablist) == 1], corpus.name))
easy.printCategoryInfo(categories)

# if desired, you can draw the images and their annotations,
# one image at a time, at a given maximum size (width, height)
#easy.drawLabelables( lablist, (512, 512) )

print("==== Training runset: ====")
posPurpose = easy.getPurpose('pos')
negPurpose = easy.getPurpose('neg')
trainset = cvac.RunSet()
easy.addToRunSet(trainset, categories[objname], posPurpose)
#trainset = easy.createRunSet( categories, purpose=posPurpose );
correct = easy.isProperRunSet(trainset, deleteInvalid=True)