Exemple #1
0
    def next(self):
        contents = self.frmR.text.get('1.0', Tk.END)
        try:
            t = int(contents)
            if t > 9 or t < 0:
                messagebox.showerror('消息框', '请输入0-9之间的数字')
                return
        except ValueError as e:
            messagebox.showerror('消息框', '请输入0-9之间的数字')
            return

        # 加载单条数据到data
        if self.currentidx < self.photonum:
            self.todata()

        self.currentidx = self.currentidx+1
        self.picidx = self.picidx + 1
        while self.picidx in self.skiplist:
            self.picidx = self.picidx+1
        # 保存到磁盘
        if self.currentidx == self.photonum:
            if self.currentidx == self.photonum:
                self.save()
        # 显示下一条数据
        if self.currentidx < self.photonum:
            self.canvas.delete('deal')
            self.canvas.delete('org')
            # self.canvas.create_rectangle(0, 0, 30, 30, fill='#000000',tags='s')
            self.canvas.create_image((75,75),image=PhotoImages[self.picidx],tags='org')
            self.dealphoto = ImageTk.PhotoImage(
                Image.fromarray(255 - readimg.load_img_to_center1(imgs[self.picidx])).resize((150, 150), 5))
            self.canvas1.create_image((75,75),image=self.dealphoto,tags='deal')
            self.frmR.lable['text'] = "共" + str(self.photonum) + "张,第" + str(self.picidx) + "张"
            self.frmR.lable1['text'] = "已处理" + str(self.currentidx) + "张,跳过" + str(len(self.skiplist)) + "张"
Exemple #2
0
 def attrinit(self):
     self.currentidx = 0
     self.picidx = 0
     self.skiplist = []
     self.data = None
     self.tf = {'sess': None, 't_conv': None, 'module_file': None,
                'keep_prob': None, 'accuracy': None, 'x': None, 'y_': None,
                'train_step': None, 'correct_prediction': None, 'module_file': None}
     self.predict_data={'images': None, 'labs': None}
     self.predict_result = {'result': None, 'wronglist': [], 'currentidx': 0}
     self.isload = None
     self.dealphoto = ImageTk.PhotoImage(
         Image.fromarray(255 - readimg.load_img_to_center1(imgs[self.picidx])).resize((150, 150), 5))
     self.savepath = './tmp/data'
     self.savename = 'train.bin'
Exemple #3
0
    def todata(self):
        """ 从图片中加载数据并人工加标签"""

        # img 是 28*28 的数组
        img = readimg.load_img_to_center1(imgs[self.picidx])

        lable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        lable[int(self.frmR.text.get('1.0',Tk.END))] = 1
        img = img.reshape(1, 784)
        lable = np.resize(lable, (1, 10))
        t = np.append(img,lable)
        if self.data is None:
            self.data = t
        else:
            self.data = np.row_stack((self.data,t))
Exemple #4
0
    def skip(self):
        """跳过"""
        r = messagebox.askokcancel('消息框', '是否跳过该图,不可撤销')
        if not r:
            return
        self.skiplist.append(self.picidx)
        self.picidx = self.picidx + 1

        # 显示
        self.canvas.delete('deal')
        self.canvas.delete('org')
        # self.canvas.create_rectangle(0, 0, 30, 30, fill='#000000',tags='s')
        self.canvas.create_image((75, 75), image=PhotoImages[self.picidx], tags='org')
        self.dealphoto = ImageTk.PhotoImage(
            Image.fromarray(255 - readimg.load_img_to_center1(imgs[self.picidx])).resize((150, 150), 5))
        self.canvas1.create_image((75, 75), image=self.dealphoto, tags='deal')
        self.frmR.lable['text'] = "共" + str(self.photonum) + "张,第" + str(self.picidx) + "张"
        self.frmR.lable1['text'] = "已处理" + str(self.currentidx) + "张,跳过" + str(len(self.skiplist)) + "张"
Exemple #5
0
    def pre(self):
        if self.currentidx <= 0:
            messagebox.showerror('消息框', '已经是第一张了')
            return

        self.currentidx = self.currentidx - 1
        self.picidx = self.picidx - 1
        while self.picidx in self.skiplist:
            self.picidx = self.picidx - 1
        self.frmR.lable1['text'] = "已处理" + str(self.currentidx) + "张,跳过" + str(len(self.skiplist)) + "张"

        self.data = np.delete(self.data,self.currentidx,0)
        self.canvas.delete('deal')
        self.canvas.delete('org')
        # self.canvas.create_rectangle(0, 0, 30, 30, fill='#000000',tags='s')
        self.canvas.create_image((75, 75), image=PhotoImages[self.picidx], tags='org')
        self.dealphoto = ImageTk.PhotoImage(
            Image.fromarray(255 - readimg.load_img_to_center1(imgs[self.picidx])).resize((150, 150), 5))
        self.canvas1.create_image((75, 75), image=self.dealphoto, tags='deal')
        self.frmR.lable['text'] = "共" + str(self.photonum) + "张,第" + str(self.picidx) + "张"