tkinter回调回溯中出现异常

8ulbf1ek  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(312)

tkinter回调异常
回溯(最近一次呼叫)
保存模型验证字符错误率:8.654728%python:3.6.8
我指的是这个代码手写行文字识别使用深入学习。
它基本上是对手写行文本图像进行识别,而不需要预先分割成单词或字符
这是python应用程序gui代码:

  1. from tkinter import *
  2. from tkinter import ttk
  3. from tkinter import filedialog
  4. from PIL import Image, ImageTk
  5. from main import infer_by_app
  6. class Root(Tk):
  7. def _init_(self):
  8. super(Root, self)._init_()
  9. self.title("Hand Written Character Recognition")
  10. self.minsize(1000, 400)
  11. self.labelFrame = ttk.LabelFrame(self, text="Choose an Image for Text Prediction:")
  12. self.labelFrame.grid(column=0, row=1, padx=20, pady=20)
  13. self.labelFrame2 = ttk.LabelFrame(self, text="Predicted Text:")
  14. self.labelFrame2.grid(column=0, row=7)
  15. self.label4 = ttk.Label(self.labelFrame2, text="Prediction Without AutoCorrect : ")
  16. self.label4.grid(column=0, row=8)
  17. self.label5 = ttk.Label(self.labelFrame2, text="Prediction With AutoCorrect :")
  18. self.label5.grid(column=0, row=9)
  19. self.button()
  20. def button(self):
  21. self.button_browse = ttk.Button(self.labelFrame, text="Browse", command=self.fileDialog)
  22. self.button_browse.grid(column=1, row=1)
  23. self.button_pred = ttk.Button(self.labelFrame2, text="Predict", command=self.upload)
  24. self.button_pred.grid(column=0, row=5)
  25. def fileDialog(self):
  26. self.filename = None
  27. self.filename = filedialog.askopenfilename(initialdir="D:\MSc-IT\MScFinalProject\Handwritten-Line-Text-Recognition-using-Deep-Learning-with-Tensorflow-master\data", title="Select A File", filetype=
  28. (("PNG file", ".png"), ("all files", ".*")))
  29. self.label = ttk.Label(self.labelFrame, text="Image location:")
  30. self.label.grid(column=1, row=2)
  31. self.label1 = ttk.Label(self.labelFrame, text = "")
  32. self.label1.grid(column = 2, row = 2)
  33. self.label1.configure(text = self.filename)
  34. img = Image.open(self.filename)
  35. img = img.resize((800, 40))
  36. photo = ImageTk.PhotoImage(img)
  37. self.label2 = Label(image=photo)
  38. self.label2.image = photo
  39. self.label2.grid(column=0, row=4)
  40. def upload(self):
  41. self.option = "bestPath"
  42. self.destination = self.filename
  43. self.result = self.predText(self.destination, self.option)
  44. self.withoutCorrection, self.withCorrection = self.result
  45. #print("Prediction: ", self.withCorrection)
  46. self.label4.configure(text="Prediction Without AutoCorrect : " + "'" + str(self.withoutCorrection) + "'")
  47. self.label5.configure(text="Prediction With AutoCorrect : " + "'" + str(self.withCorrection) + "'")
  48. def predText(self,path,option):
  49. return infer_by_app(path, option)
  50. root=Root()
  51. root.mainloop()

这是第一个输出

我在第二次输出中出错

upload self.result=self.predtext(self.destination,self.option)中的第56行“使用tensorflow master/src/app gui.py深度学习进行项目/手写行文本识别”

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题