コード例 #1
0
class fsrgan_process(Process):
    def __init__(self, fsrq, recoq, lock):
        Process.__init__(self)
        self.fsrgan = LHFSRGAN()
        self.fsrq = fsrq
        self.recoq = recoq
        self.lock = lock
        self.state = True

    def run(self):
        while (self.state):
            if self.fsrq.qsize() > 0:
                img = self.fsrq.get()
                out_img, _ = self.fsrgan.LR_to_HR(img)
                self.lock.acquire()
                self.recoq.put([out_img, 1])
                self.lock.release()
                self.fsrq.task_done()

    def stop(self):
        self.state = False
コード例 #2
0
                                    printable=False))
        imgs = tl.vis.read_images(img_list, path=facedir, n_threads=4)
        id = time.strftime('%Y%m%d%H%M%S', time.localtime(
            time.time())) + '_' + str(np.random.randint(0, 9999)).zfill(4)
        # print(id)
        dict_face = {}

        for i in range(len(imgs)):
            imgface = imgs[i]
            h = imgface.shape[0]
            w = imgface.shape[1]
            x1 = random.randint(0, 1080)
            y1 = random.randint(0, 1080)
            flag = 0
            if (h < 80 and w < 80):
                imgface, _ = srgan.LR_to_HR(imgface)
                flag = 1
            if imgface.ndim < 2:
                print('Unable to align ')
            faces = face_recognition.identify(imgface)
            if (len(faces) > 0):
                if (faces[0].confidence < thed):
                    faces[0].name = 'unknown'
                faceinfo = [[x1, y1, w, h],
                            str(faces[0].embedding), faces[0].name, flag]
            else:
                faceinfo = [[x1, y1, w, h],
                            str(np.zeros((128, ))), 'unable', flag]
            if i == 0:
                dict_face[id] = [faceinfo]
            else:
コード例 #3
0
                    w = int(person[D_HEAD_AXIS][D_W])
                    h = int(person[D_HEAD_AXIS][D_H])
                    #print(pid,"@@@@@@@@@@w:%d h:%d"%(w, h))
                    data = person[D_HEAD]
                    arr = np.array(data)
                    arr = arr.reshape(-1)
                    img = arr.reshape(h, w, 3)
                    img = np.uint8(img)
                    faceimg = cv2.cvtColor(np.asarray(img), cv2.COLOR_BGR2RGB)
                    #face rgb
                    #########################################
                    flag = 0
                    #print(faceimg.shape[0], faceimg.shape[1])
                    #start_time = time.time()
                    if (faceimg.shape[0] < 80 and faceimg.shape[1] < 80):
                        faceimg, _ = srgan.LR_to_HR(faceimg)
                        flag = 1
                    if faceimg.ndim < 2:
                        print('Unable to align ')
                    faces = face_recognition.identify(faceimg)
                    if (len(faces) > 0):
                        if (faces[0].confidence < thed):
                            faces[0].name = 'unknown'
                        faceinfo = [pid, faces[0].name, flag]
                    else:
                        faceinfo = [pid, 'unable', flag]
                    dict_face[id].append(faceinfo)
                    #print('111111111111111one face img cost time:%f' % (time.time() - start_time))
            publish.insertListFace(dict_face)
            #print('222222222222one face img cost time:%f' % (time.time() - start_time))