Hi,
I designed a Python OOT sink block. The purpose of this block is to get the 
input characters and store it in a variable. I can run a tensorflow model 
through this variable to restore it to the original image. My work function is 
as follows:
 def work(self, input_items, output_items):
        in0 = input_items[0]
        n = len(in0)
        i = 0
&nbsp; &nbsp; &nbsp; &nbsp; while(i<n):
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.rxsymbols.append(in0[i])
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i = i+1
&nbsp; &nbsp; &nbsp; &nbsp; rxsymbols_len = len(self.rxsymbols)
&nbsp; &nbsp; &nbsp; &nbsp; if rxsymbols_len == 
self.width*self.high//2+self.fillnum:
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.rxsymbols = 
np.array(self.rxsymbols)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
self.rxsymbols.tofile("/home/liumaolin-2/PycharmProjects/test/model/sink_test")
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rx = 
self.rxsymbols[0:self.width*self.high//2]
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rv_img = 
np.concatenate([np.reshape(np.real(rx), [1, -1]), np.reshape(np.imag(rx), [1, 
-1])], axis=0)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rv_img = np.reshape(rv_img, 
self.inter_shape)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; re_img = self.de_model.predict(rv_img)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mse = 
np.mean(np.square(re_img-self.img_array))
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(mse)


&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; plt.subplot(111)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; plt.imshow(re_img[0]/255)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; plt.show()


&nbsp; &nbsp; &nbsp; &nbsp; return len(input_items[0])



But when I clicked to run the flow graph, the following error occurred:
Exception ignored in: <function Image.__del__ at 0x7fd68942b4c0&gt;
Traceback (most recent call last):
&nbsp; &nbsp;File "/usr/lib/python3.8/tkinter/__init__.py", line 4017, in 
__del__
&nbsp; &nbsp; &nbsp;self.tk.call('image','delete', self.name)
RuntimeError: main thread is not in main loop
Tcl_AsyncDelete: async handler deleted by the wrong thread



This seems to be a problem with matplotlib drawing. In fact, the final result 
is that I can restore the picture I want. In other words, the basic functions 
can be realized now, but the error prompted by the terminal does not look good. 
, I want to make it perfect, if anyone has some good suggestions I would not be 
very grateful, thank you!
Sincerely,
linge93

Reply via email to