create negative_py
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!
Hi,
Sorry, the script is indeed kind of messy!
I think you can try modifying line 51 to exit(0) instead of break
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 .
Try adding print(number_of_pictures) on next line of line 14,
what does it print?
sorry, I should have changed the line ends with jpeg to jpg. now another error occures
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)]
Yes, this should work!
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".
plz help me, thank you.
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)]
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 .