Beispiel #1
0
def save_valid(tag, img, gt_lbl, res_lbl):
    if not os.path.exists(dumpdir + os.sep + "valid_pre"):
        os.mkdir(dumpdir + os.sep + "valid_pre")
    fpath = dumpdir + os.sep + "valid_pre" + os.sep + tag + ".png"
    gt_img = convertLabelToQImage(gt_lbl)
    res_img = convertLabelToQImage(res_lbl)
    imgpad = QtGui.QImage(img.width() * 3 + 10, img.height(),
                          QtGui.QImage.Format_RGB888)
    imgpad.fill(Qt.white)
    painter = QtGui.QPainter()
    painter.begin(imgpad)
    painter.drawImage(0, 0, img)
    painter.drawImage(img.width() + 5, 0, gt_img)
    painter.drawImage(2 * img.width() + 10, 0, res_img)
    painter.end()
    imgpad.save(fpath)
Beispiel #2
0
 def setGT(self, lmat):
     self.work.setGT(lmat)
     lblimg = (convertLabelToQImage(self.work.gt_lbl)).convertToFormat(
         QtGui.QImage.Format_RGB888)
     painter = QtGui.QPainter()
     painter.begin(self.imgpad)
     painter.drawImage(0, 0, lblimg)
     painter.end()
Beispiel #3
0
 def updateimg(self):
     print('updating')
     lbl = self.work.getLabel()
     lblimg = (convertLabelToQImage(lbl)).convertToFormat(
         QtGui.QImage.Format_RGB888)
     painter = QtGui.QPainter()
     painter.begin(self.imgpad)
     painter.drawImage(256, 0, lblimg)
     painter.end()
     debugimg = self.work.getDebug()
     for idx, img in enumerate(debugimg):
         painter.begin(self.imgpad)
         i = idx + 2
         ix = i % 5
         iy = i // 5
         painter.drawImage(256 * ix, 256 * iy, img)
         painter.end()
     self.setPixmap(QtGui.QPixmap.fromImage(self.imgpad))
     self.update()
Beispiel #4
0
 def getDebug(self):
     out_xy = self.sess.run(self.ppl.out_xy)
     inside = self.ppl.get_inside(out_xy)
     edge_pts = self.sess.run(self.ppl.edge_pts)
     nnidx = self.ppl.get_nn_idx(edge_pts)
     feed = {
         self.ppl.gt_lbl: self.gt,
         self.ppl.inside: inside,
         self.ppl.nnidx: nnidx
     }
     debug = self.sess.run(self.ppl.debug_prob, feed_dict=feed)
     debug -= debug.min()
     debug /= debug.max()
     debug *= 255.0
     array = debug.astype(np.uint8)
     imgs = []
     imgs.append(
         QtGui.QImage(array, array.shape[1], array.shape[0], array.shape[1],
                      QtGui.QImage.Format_Grayscale8))
     imgs.append(
         convertLabelToQImage(
             np.argmax(inside, axis=-1).astype(np.uint8) + 1))
     dist = self.sess.run(self.ppl.dist, feed_dict=feed)
     for i in range(5):
         debug = dist[:, :, i]
         debug -= debug.min()
         debug /= debug.max()
         debug *= 255.0
         array = debug.astype(np.uint8)
         imgs.append(
             QtGui.QImage(array, array.shape[1], array.shape[0],
                          array.shape[1], QtGui.QImage.Format_Grayscale8))
     #print("out_xy:",out_xy);
     #print("edge_end:",edge_end[:,:,:,self.ppl.fedge_idx_v[1,:]]);
     #print("edge_pts:",edge_pts.shape,edge_pts)
     return imgs
Beispiel #5
0
if __name__ == "__main__":
    path = "E:\\WorkSpace\\PPL\\data\\LSUN"
    try:
        train_data = loadmat(path + os.sep + 'training.mat')
    except:
        path = '/data4T1/samhu/LSUN'
        train_data = loadmat(path + os.sep + 'training.mat')
    res = []
    score = []
    for i in range(train_data['training'].shape[1]):
        #for i in range(5):
        name = train_data['training'][0, i][0][0]
        lmat = loadmat(path + os.sep + 'layout' + os.sep + 'layout_seg' +
                       os.sep + name + '.mat')
        lgt = lmat['layout'].copy()
        img = convertLabelToQImage(lgt)
        imgs = img.scaled(256, 256, Qt.KeepAspectRatio)
        if os.path.exists(path + os.sep + 'packed' + os.sep + name + '.h5'):
            markf = h5py.File(path + os.sep + 'packed' + os.sep + name + '.h5',
                              'r')
            xyz = np.zeros([3, 8], dtype=np.float32)
            xyz[0:2, :] = markf['layout']
            lgen = layout2ResultV3(xyz, 256, lgt.shape[1], lgt.shape[0],
                                   imgs.width(), imgs.height())
            markf.close()
            acc = max(pixAcc(lgt, lgen), pixAcc(lgen, lgt))
            score.append(acc)
            res.append(name)
            print(i, res[-1], score[-1])
            sys.stdout.flush()
    scorearray = np.array(score)