🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

Save created image on the go during app is running

I have created an image while my app is running.
I want that created image to put in an html division , but i am unable to do that?
Can anyone help me with this?

Or what we can do is to save image while app is running and use html.Img() is display that image but I could not implement that too is gives error as

WARNING: QApplication was not created in the main() thread.
Traceback (most recent call last):
File “D:\Anaconda\lib\site-packages\flask\app.py”, line 2309, in call
return self.wsgi_app(environ, start_response)
File “D:\Anaconda\lib\site-packages\flask\app.py”, line 2295, in wsgi_app
response = self.handle_exception(e)
File “D:\Anaconda\lib\site-packages\flask\app.py”, line 1741, in handle_excepti
reraise(exc_type, exc_value, tb)
File “D:\Anaconda\lib\site-packages\flask_compat.py”, line 35, in reraise
raise value
File “D:\Anaconda\lib\site-packages\flask\app.py”, line 2292, in wsgi_app
response = self.full_dispatch_request()
File “D:\Anaconda\lib\site-packages\flask\app.py”, line 1815, in full_dispatch_
rv = self.handle_user_exception(e)
File “D:\Anaconda\lib\site-packages\flask\app.py”, line 1718, in handle_user_ex
reraise(exc_type, exc_value, tb)
File “D:\Anaconda\lib\site-packages\flask_compat.py”, line 35, in reraise
raise value
File “D:\Anaconda\lib\site-packages\flask\app.py”, line 1813, in full_dispatch_
rv = self.dispatch_request()
File “D:\Anaconda\lib\site-packages\flask\app.py”, line 1799, in dispatch_reque
return self.view_functionsrule.endpoint
File “D:\Anaconda\lib\site-packages\dash-1.0.0a1-py3.6.egg\dash\dash.py”, line
return self.callback_map[target_id]‘callback’
File “D:\Anaconda\lib\site-packages\dash-1.0.0a1-py3.6.egg\dash\dash.py”, line
output_value = func(*args, **kwargs)
File "C:\Users\c-prasado\Desktop\Prasad\Codes\GUI\modelInterpretation\shap_app.
diag = shap.summary_plot(shap_values, X, plot_type=“bar”)
File “D:\Anaconda\lib\site-packages\shap\plots\summary.py”, line 397, in summar
File “D:\Anaconda\lib\site-packages\matplotlib\pyplot.py”, line 254, in show
return _show(*args, **kw)
File “D:\Anaconda\lib\site-packages\matplotlib\backend_bases.py”, line 3266, in
File “D:\Anaconda\lib\site-packages\matplotlib\backends\backend_qt5.py”, line 1
signal.signal(signal.SIGINT, signal.SIG_DFL)
File “D:\Anaconda\lib\signal.py”, line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread

This looks like it might have something to do with your code trying to spin-up a Qt Application. I think the culprit might be the call to matplotlib.pyplot.show. Try and modify your code to just save the image through the relevant non-interactive matplotlib API method.

1 Like