比赛链接:零基础入门CV赛事- 街景字符编码识别
目的:识别真实街景图片中的数字。
数据集:Google街景图像中的门牌号数据集(The Street View House Numbers Dataset, SVHN)。训练集数据包括3W张照片,验证集数据包括1W张照片,每张照片包括颜色图像和对应的编码类别和具体位置;为了保证比赛的公平性,测试集A包括4W张照片,测试集B包括4W张照片。
所有的数据(训练集、验证集和测试集)的标注使用JSON格式,并使用文件名进行索引。如果一个文件中包括多个字符,则使用列表将字段进行组合。
最终判断方法优劣的标准:以编码整体识别准确率为评价指标,结果越大越好。
提交格式:提交文件后缀名.csv。
.csv结果文件内部样式:
预备工作:
1)环境配置
利用anaconda新建虚拟环境。
conda create -n py37_torch131 python=3.7
source activate py37_torch131
conda install pytorch=1.3.1 torchvision cudatoolkit=10.0
pip install jupyter tqdm opencv-python matplotlib pandas
2)下载数据到指定路径(这部分是队长大大提供的代码,非常6)
前提是要先从天池网站上把他们提供的.csv文件下载下来。
# import related packages
import pandas as pd
import os
import requests
import zipfile
# read .csv file
links = pd.read_csv("mchar_data_list_0515.csv")# the path of .csv should be where you store your .csv file, modify it adaptively.
dir_name = "Dataset"
mypath = "/home/zdst/Ryan/Street_view_number/" # the path should be modified according to your situation
if not os.path.exists(mypath + dir_name):
os.mkdir(mypath + dir_name)
# download files from links listed on the .csv file one by one
for i,link in enumerate(links["link"]):
file_name = links['file'][i]
print(file_name,'\t',link)
file_name = mypath + dir_name + '/' + file_name
if not os.path.exists(file_name):
response = requests.get(link,stream=True)
with open(file_name,"wb") as f:
for chunk in response.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
zip_list = ['mchar_train','mchar_test_a','mchar_val']
# unzip related files
for little_zip in zip_list:
if not os.path.exist(mypath + dir_name + '/' + little_zip):
zip_file = zipfile.ZipFile(mypath + dir_name + '/' + little_zip + '.zip','r')
zip_file.extractall(path = mypath + dir_name)
参考资料:
Datawhale 零基础入门CV赛事-Baseline讲解
Datawhale 零基础入门CV赛事-Task1 赛题理解