Exemplo n.º 1
0
# 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
# to syntactically different but semantically identical labels.
# Because we don't specify it, this guesses the specific Purpose that
# is assigned to the labels.
# Also obtain this mapping from Purpose to label name, called "classmap."
Exemplo n.º 2
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("-----------")

Exemplo n.º 3
0
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():
    if key.startswith("car"):
        cars.append( categories[key] )
Exemplo n.º 4
0
# 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
# to syntactically different but semantically identical labels.
# Because we don't specify it, this guesses the specific Purpose that
# is assigned to the labels.
# Also obtain this mapping from Purpose to label name, called "classmap."