Flask function return invalidated on the Main Thread Error
I think the problem is your visualization/plotting code in the vis_segmentation()
method. If you comment out the line run_visualization(url='/Users/abdul/PycharmProjects/ImgSeg/uploads/photo.jpg')
, the error should go away but obviously you won't have any plots showing.
There are various SO answers already that address how to display a matplotlib plot via flask. Here is one: Python: How to show matplotlib in flask