Esempio n. 1
0
def log_line(image, model, t):
    imagen = ImageCategories(model)
    td = t
    if not type(t) == dict:
        td = { int(i): 1 for i in t }
    else:
        td = { int(i): v for (i, v) in t.iteritems() }
    nd = { imagen.name(i): v for (i, v) in td.iteritems() }
    nld = sorted(nd.items(), key=lambda x: -x[1])
    row = [ str(e) for l in nld for e in l ]
    row = [ image, model ] + row
    return ','.join(row) + "\n"
Esempio n. 2
0
#!/usr/bin/env python

from nltk.corpus import wordnet as wn


from neuralgae import ImageCategories

OUTFILE = "definitions_places.txt"

inet = ImageCategories("places")


def find_synsets(w):
    ss = wn.synsets(w)
    if ss:
        return ss
    ss = []
    ws = w.split("_")
    for w1 in ws:
        ss1 = wn.synsets(w1)
        if ss1:
            ss += ss1
    return ss


with open(OUTFILE, "w") as f:
    for i in range(0, 204):
        w = inet.name(i)
        w_ = w.replace(" ", "_")
        ss = find_synsets(w_)
        if not ss:
Esempio n. 3
0
def class_names(model, t):
    imagen = ImageCategories(model)
    return ', '.join([imagen.name(c) for c in t])
Esempio n. 4
0
#!/usr/bin/env python

from nltk.corpus import wordnet as wn

from neuralgae import ImageCategories

OUTFILE = 'definitions_places.txt'

inet = ImageCategories('places')


def find_synsets(w):
    ss = wn.synsets(w)
    if ss:
        return ss
    ss = []
    ws = w.split('_')
    for w1 in ws:
        ss1 = wn.synsets(w1)
        if ss1:
            ss += ss1
    return ss


with open(OUTFILE, 'w') as f:
    for i in range(0, 204):
        w = inet.name(i)
        w_ = w.replace(' ', '_')
        ss = find_synsets(w_)
        if not ss:
            print "ERR: %d %s not found" % (i, w)