def store_neg_images():
neg_images_link = 'image-net url for negative images'
neg_image_urls = urllib.request.urlopen(neg_images_link).read().decode()
#pic_num stands for picture index on the repo
pic_num = 1
if not os.path.exists('neg'):
os.makedirs('neg')
for i in neg_image_urls.split('\n'):
try:
print(i)
urllib.request.urlretrieve(i, "neg/"+str(pic_num)+".jpg")
neg_img = cv2.imread("neg/"+str(pic_num)+".jpg",cv2.IMREAD_GRAYSCALE)
# should be larger than samples / pos pic (so we can place our image on it)
neg_resize = cv2.resize(img, (100, 100))
cv2.imwrite("neg/"+str(pic_num)+".jpg",neg_resize)
pic_num += 1
except Exception as e:
print(str(e))
评论列表
文章目录