CNN_face_detection icon indicating copy to clipboard operation
CNN_face_detection copied to clipboard

create negative_py

Open reza320 opened this issue 8 years ago • 9 comments

Hi! when I am trying to run create negative_py, I get the error: read_img_name = data_base_dir + '/' + file_list[current_image].strip() IndexError: list index out of range can u help me with this please? I have just created 340 scenery images in the directory btw, I am not a pro. just a beginner thanks a lot!

reza320 avatar Apr 07 '17 08:04 reza320

Hi, Sorry, the script is indeed kind of messy! I think you can try modifying line 51 to exit(0) instead of break

anson0910 avatar Apr 07 '17 16:04 anson0910

thanks for your quick reply I sent you the error in appendix if you cant read it changing the break to exit(0) didn't work

On Fri, Apr 7, 2017 at 9:06 PM, Anson Yu [email protected] wrote:

Hi, Sorry, the script is indeed kind of messy! I think you can try modifying line 51 to exit(0) instead of break

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/anson0910/CNN_face_detection/issues/35#issuecomment-292586486, or mute the thread https://github.com/notifications/unsubscribe-auth/AZbyMlAzItAWXsZZEuQgtIXhbi4pdelhks5rtmYHgaJpZM4M2nK2 .

reza320 avatar Apr 07 '17 17:04 reza320

Try adding print(number_of_pictures) on next line of line 14, what does it print?

anson0910 avatar Apr 07 '17 17:04 anson0910

sorry, I should have changed the line ends with jpeg to jpg. now another error occures

reza320 avatar Apr 07 '17 17:04 reza320

I have added some lines in the code, is it OK?

 for current_image in range((current_neg_dir - 1)*300, (current_neg_dir - 1)*300 + 300):    # take 300 images
        if current_image > (number_of_pictures - 1):
            break
        if current_image % 100 == 0:
            print "Processing image number " + str(current_image)
        read_img_name = data_base_dir + '/' + file_list[current_image].strip()
        img = cv2.imread(read_img_name)     # read image
        height, width, channels = img.shape

        crop_size = min(height, width) / 2  # start from half of shorter side

        while crop_size >= 12:
            for start_height in range(0, height, 100):
                if (start_height + crop_size) > height:
                    break
                for start_width in range(0, width, 100):
                    if (start_width + crop_size) > width:
                        break
                    cropped_img = img[start_height : start_height + int(crop_size), start_width : start_width + int(crop_size)]

microhua avatar Mar 19 '18 07:03 microhua

Yes, this should work!

anson0910 avatar Mar 19 '18 16:03 anson0910

Hello, i'm also a beginner. When i tried to modify the codes as you discuss. It still said:"IndexError: list index out of range".

2018-06-10 4 02 16 2018-06-10 4 05 17

plz help me, thank you.

hqq1990 avatar Jun 10 '18 07:06 hqq1990

Hi Hong,

I think the problem is wrong indentation compared to the code microhua pasted. The code with the line starting from read_img_name should be indented to the right.

for current_image in range((current_neg_dir - 1)*300, (current_neg_dir - 1)*300 + 300):    # take 300 images
        if current_image > (number_of_pictures - 1):
            break
        if current_image % 100 == 0:
            print "Processing image number " + str(current_image)
        read_img_name = data_base_dir + '/' + file_list[current_image].strip()
        img = cv2.imread(read_img_name)     # read image
        height, width, channels = img.shape

        crop_size = min(height, width) / 2  # start from half of shorter side

        while crop_size >= 12:
            for start_height in range(0, height, 100):
                if (start_height + crop_size) > height:
                    break
                for start_width in range(0, width, 100):
                    if (start_width + crop_size) > width:
                        break
                    cropped_img = img[start_height : start_height + int(crop_size), start_width : start_width + int(crop_size)]

anson0910 avatar Jun 10 '18 19:06 anson0910

Dear Anson:

Thank you so much for your reply.

haha, i also found that problem after i checked the entire code, and i have solved it.

If i still met some problem in the future, i hope i can sent email to you for your help.

Sincerely Yours. Hong

2018-06-11 4:48 GMT+09:00 Anson Yu [email protected]:

Hi Hong,

I think the problem is wrong indentation compared to the code microhua pasted. The code with the line starting from read_img_name should be indented to the right.

for current_image in range((current_neg_dir - 1)*300, (current_neg_dir - 1)*300 + 300): # take 300 images if current_image > (number_of_pictures - 1): break if current_image % 100 == 0: print "Processing image number " + str(current_image) read_img_name = data_base_dir + '/' + file_list[current_image].strip() img = cv2.imread(read_img_name) # read image height, width, channels = img.shape

    crop_size = min(height, width) / 2  # start from half of shorter side

    while crop_size >= 12:
        for start_height in range(0, height, 100):
            if (start_height + crop_size) > height:
                break
            for start_width in range(0, width, 100):
                if (start_width + crop_size) > width:
                    break
                cropped_img = img[start_height : start_height + int(crop_size), start_width : start_width + int(crop_size)]

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/anson0910/CNN_face_detection/issues/35#issuecomment-396076473, or mute the thread https://github.com/notifications/unsubscribe-auth/AZJ2TBbTfUJcJkU_Q26icwlBO1yF4qK-ks5t7Xf8gaJpZM4M2nK2 .

hqq1990 avatar Jun 11 '18 03:06 hqq1990