加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
downloadSnowmanData.py 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
穿着帆布鞋也能走猫步 提交于 2019-01-24 15:02 . 初始提交
from PIL import Image
import requests
import csv
import subprocess
def get_file(url, local_filename):
attempts = 0
while attempts < 3:
try:
r = requests.get(url)
with open(local_filename, 'wb') as f:
f.write(r.content)
f.close()
img = Image.open(local_filename)
break
except:
attempts += 1
print("Attempt#" + str(attempts) + " - Failed to read from "+url)
try:
img = Image.open(local_filename)
img.verify()
except Exception as e:
print(e)
print(local_filename + " corrupted..deleting it..")
subprocess.run(['rm', local_filename])
return
with open('/home/xuxuejie/software/YOLOv3-Training-Snowman-Detector/snowmanDataLinks.csv', 'r') as csvfile:
#with open('snowmantestLinks.csv', 'r') as csvfile:
urlreader = csv.reader(csvfile, delimiter=',')
for row in urlreader:
get_file(row[0], 'JPEGImages/' + row[1])
print(row[0] + '-->' + row[1])
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化