umyelab / LabGym

Quantify user-defined behaviors.
GNU General Public License v3.0
64 stars 5 forks source link

failed to resize behavior examples when training categorizers #202

Closed XiaotongChel closed 1 month ago

XiaotongChel commented 1 month ago

Hello: Thanks for the software! I'm trying to label the moving pattern-related behavior of Drosophila larvae. When preparing my sorted behavior examples for the categorizers, I failed to resize the examples. (I used the default size of 32, and pressed the "Start to prepare the training examples" button but nothing happened) image

The cmd window shows a cv2.error, but I don't know how to fix that.

Traceback (most recent call last):
  File "C:\Users\Ida\AppData\Local\Programs\Python\Python310\lib\site-packages\LabGym\gui_categorizer.py", line 1077, in rename_files
    CA.rename_label(self.file_path,self.new_path,resize=self.resize)
  File "C:\Users\Ida\AppData\Local\Programs\Python\Python310\lib\site-packages\LabGym\categorizer.py", line 94, in rename_label
    image=cv2.resize(image,(resize,resize),interpolation=cv2.INTER_AREA)
cv2.error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\resize.cpp:4152: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'

Thank you for the help!

yujiahu415 commented 1 month ago

Hi, The error indicated that images for resizing are 'broken', either because the image files were corrupted or because the images were not read properly. I guess the cause would be more likely the latter. First, can you double check whether the 'sorted behavior' folder contains the images, and all images are in pair with the animations. Second, what are the file names of the behavior examples like? Are there any special characters in the file names or in the path to the images?

XiaotongChel commented 1 month ago

Thank you for the double-check advice. I found the problem when checking the folder. It is because my "sorted behavior" folder contains one empty folder, the program runs properly right after I delete the empty folder.