Closed memmam closed 2 years ago
Running this in Google Colab gave me a warning that cv2.imshow is known to crash Jupyter Notebook, and suggested I use a patch Google supplies for Colab called 'cv2_imshow' instead. Since this issue involved a crash when opening the image window, I think this is the issue.
The plot thickens... When I switch to cv2_imshow, I get this:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
[<ipython-input-7-7d1e3a69f925>](https://localhost:8080/#) in <module>()
6
7 image = cv2.imread(img_paths[1000])
----> 8 cv2_imshow(image)
9 cv2.namedWindow('image')
10 cv2.setMouseCallback('image', onMouse)
[/usr/local/lib/python3.7/dist-packages/google/colab/patches/__init__.py](https://localhost:8080/#) in cv2_imshow(a)
20 image.
21 """
---> 22 a = a.clip(0, 255).astype('uint8')
23 # cv2 stores colors as BGR; convert to RGB
24 if a.ndim == 3:
AttributeError: 'NoneType' object has no attribute 'clip'
I'm trying to figure it out right now.
ALL ISSUES FIXED, one line change
Replace the following line in the fourth code block:
img_paths.append(os.path.join(f"{image_dir}/{folder}/", filename))
with
img_paths.append(os.path.join(f"{folder}/", filename))
See pull request #7
Also, I'm not sure the colab cv2_imshow behaviour is going to work like you expect! If I remember correctly it will display the images one after the other in the notebook, and not as a "video" per say. Unfortunately this is a limitation of colab, and show
should be set to false.
@lloydowen8 It actually worked fine once I applied the fix in #7, up until the heatmap notebook tried to open and it halted the notebook because of a request to open an X Server window, which Colab doesn't support. I was trying Colab in the off-chance that the problem was with my Python install and not with your code.
I get this error when running the code. Using Python 3.9, installed the
requirements.txt
file, zip file is extracted properly (all folders in zip are together in a folder namedfinal_v1
)Edit: A reason for this bug seems to have been identified, see comment below.Edit 2: More issues have cropped up; diagnosing them now.Edit 3: one-line fix identified, pull request incoming.