最近参加了“华为云杯”2019人工智能创新应用大赛,是一个图像分类的比赛,最终准确率0.972,大概排50多/732。但决赛取前20名,遗憾败北(第20名的准确率是0.982)。
第一次参加类似比赛,总结记录一下。
比赛的代码:xyxy875/huawei_xian_image_classification
赛题
对西安的热门景点、美食、特产、民俗、工艺品等图片进行分类,共有54类。
官方给出了3000余张数据集,官方判分的不公开测试集有1000张图片。
要求:不允许使用“测试时增强”策略和“模型融合”策略,可以使用其他来源的图片数据。
数据
数据分析
绘制了混淆矩阵,对难分的类别进行有针对性的增广。
计算混淆矩阵的代码如下:
from sklearn.metrics import confusion_matrix
def validate(val_loader, model, criterion, args, epoch):
……
# confusion_matrix init
cm = np.zeros((54, 54))
# switch to evaluate mode
model.eval()
with torch.no_grad():
end = time.time()
for i, (images, target) in enumerate(val_loader):
if args.gpu is not None:
images = images.cuda(args.gpu, non_blocking=True)
target = target.cuda(args.gpu, non_blocking=True)
# compute output
output = model(images)
loss = criterion(output, target)
# compute_confusion _ added by YJ on 20191209
cm += compute_confusion(output, target)
……
confusion_file_name = os.path.join(args.train_local, 'epoch_{}.npy'.format</