Пример #1
0
def get_imgfile(img_id):
    s = Search(index='idx1').query('match', image_id=img_id)
    s = s.using(client)
    s.execute()
    for hit in s.scan():
        imgfile = hit.imagefile
        return imgfile
Пример #2
0
def query_imagesi(classnum_list, classval_list, upfilename):

    #print("In query_imagesi")
    hit1 = set()
    image_set = set()
    #print("11. classnum_list =", classnum_list)
    #print("12. classval_list =", classval_list)
    if (len(classnum_list) > 7):
        lenclassnum = 7

    QI = Q('match_all')
    s1 = Search(index='adknum')
    #s1 = Search(index='vgnum')
    classn = 1
    for class_num in classnum_list:
        if classn > 7:  #can make this 5--
            break
        classn = classn + 1
        QI = QI & Q('bool', must=[Q("match", classnum=class_num)])

    s1 = s1.query(QI).using(client)
    response = s1.execute()
    hit_num = 0
    simDict = {}
    similarityClass = np.zeros(15)
    for hit in s1.scan():
        print("123. hit.classnum: ", hit.classnum)
        print("124. hit.classval: ", hit.classval)
        lenimgclassnum = len(hit.classnum)
        simDict[hit.imgfile] = 1.0
        #similarityClass[lenimgclassnum]
        # Compute similarity and choose top 4 rather than random 4
        ii = 0
        similarityImg = 0.0
        for classi in classnum_list:
            jj = 0
            for classj in hit.classnum:
                if classi == int(classj):
                    similarityClass[ii] = classval_list[ii] / (abs(
                        (classval_list[ii] - int(hit.classval[jj]))) + 10)
                    #print("144. similarityClass[ii] = ", similarityClass[ii])
                    similarityImg = similarityImg + similarityClass[ii]
                    break
                jj = jj + 1
            simDict[hit.imgfile] = similarityImg
            #print("130. simDict[hit.imgfile] = ", simDict[hit.imgfile], similarityImg)
            ii = ii + 1

    #for key in sorted(simDict.keys(), reverse=True) :
    kk = 0
    for img in sorted(simDict, key=simDict.get, reverse=True):
        print("140. ", img, simDict[img])
        image_set.add(img)
        #image_set.add(hit.imgfile)
        #pick top 4 images (hit_nums)
        kk = kk + 1
        if kk > 3:
            break

    return display_image_set(image_set, upfilename, '')
Пример #3
0
def query_images(object_list):
    #print("In query_images")
    hit1 = set()
    image_set = set()
    print("11. object_list =", object_list)

    QI = Q('match_all')
    #s1 = Search(index='bvgobjs_index')
    s1 = Search(index='idxo20')
    for objectk in object_list:
        print("objectk= ", objectk)
        QI = QI & Q("match", names=objectk)

    s1 = s1.query(QI).using(client)
    response = s1.execute()
    for hit in s1.scan():
        print("33 ", hit.imgfile)
        image_set.add(hit.imgfile)

    print("image_set = {0}".format(image_set))
    im = 0
    #app.layout = serve_layout
    images_div = []
    for image in image_set:
        if im > 3:
            break
        file, ext = os.path.splitext(image)
        image = file + '.png'
        print("66 image =", image)
        images_div.append(display_image(image))
        im = im + 1
    print("Please hit refresh...")
    # Here call callback -
    #serve_layout =
    app.layout = serve_layout(images_div)
Пример #4
0
def get_imgfile(img_id):
    s = Search(index='idxi20').query('match', image_id=img_id)
    s = s.using(client)
    s.execute()
    for hit in s.scan():
        imgfile = hit.imagefile
        #imagefile = hit.url
        #print("22 imgfile = ", imgfile)
        return imgfile
Пример #5
0
def query_imageso(object_list):
    print("In query_imageso")
    hit1 = set()
    image_set = set()
    print("11. object_list =", object_list)

    QI = Q('match_all')
    s1 = Search(index='idx0')
    for name in object_list:
        print("name= ", name)
        QI = QI & Q("match", names=name)

    s1 = s1.query(QI).using(client)
    response = s1.execute()
    for hit in s1.scan():
        image_set.add(hit.imgfile)

    return display_image_set(image_set, None, object_list)
Пример #6
0
def query_imagesi(classnum_list, upfilename):  #Disabled --
    #print("In query_imagesi")
    hit1 = set()
    image_set = set()
    #print("11. classnum_list =", classnum_list)

    QI = Q('match_all')
    s1 = Search(index='vgnum')
    classn = 1
    for class_num in classnum_list:
        if classn > 7:  #can make this 7--
            break
        classn = classn + 1
        print("class_num= ", class_num)
        QI = QI & Q('bool', must=[Q("match", classnum=class_num)])

    s1 = s1.query(QI).using(client)
    response = s1.execute()
    for hit in s1.scan():
        image_set.add(hit.imgfile)
    return display_image_set(image_set, upfilename, '')