ImageResizer.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:main 作者: templerobotics 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号