Task2-数据读取与数据扩增。

数据读取:


import json

import  numpyas np

import matplotlib.pyplotas plt

import cv2

train_json = json.load(open(r'D:\data2\mchar_train.json'))

# 数据标注处理

def pl(n):

plt.ion()

plt.pause(n)

plt.close()

def parse_json(d):

arr = np.array([

d['top'], d['height'], d['left'],  d['width'], d['label']

])

arr = arr.astype(int)

return arr

i=str(500).rjust(6,'0')

img = cv2.imread('D:\\data2\\mchar_train\\'+i+'.png')

arr = parse_json(train_json[i+'.png'])

print('json',arr)

plt.figure(figsize=(10,10))

plt.subplot(1, arr.shape[1]+1,1)

plt.imshow(img)

plt.xticks([]); plt.yticks([])

for idxin range(arr.shape[1]):

plt.subplot(1, arr.shape[1]+1, idx+2)

plt.imshow(img[arr[0, idx]:arr[0, idx]+arr[1, idx],arr[2, idx]:arr[2, idx]+arr[3, idx]])

plt.title(arr[4, idx])

plt.xticks([]); plt.yticks([])

pl(1)


数据和方法都比较清楚了.现在选择实现方法.需提取出json中的位置和识别数据.

每张图片json数据如下,分别对应top,height,left,width.label

json [[ 7 8]

[ 56  56]

[ 84 100]

[ 18  22]

[  5  8]]

分别对应top,height,left,width,label。for循环把top,height,left,width.放到一组,作为位置数据集。label放一组。

label作为模型正确率验证组。使用检测再识别方法,使用位置数据集,检测SSD模型效果。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容