資源簡介
csv數(shù)據(jù)標(biāo)注格式轉(zhuǎn)xml文件格式,便于SSD和YOLO訓(xùn)練
詳見:https://blog.csdn.net/Mynameisyournamewuyu/article/details/81124692
代碼片段和文件信息
#?encoding:?utf-8
import?csv
import?cv2
newRows=[]
with?open(“./train_labels.csv“?“r“)?as?fr:
????rows?=?csv.reader(fr)
????aRow=[]
????lastJpg=‘‘
????newJpg=‘‘
????count=0
????for?row?in?rows:
????????newJpg=row[0]
????????if?newJpg!=lastJpg:
????????????if?aRow:
????????????????newRows.append(aRow)
????????????aRow=row
????????else:
????????????aRow.append(row[1])???
????????lastJpg=row[0]
????????count+=1
????newRows.append(aRow)????????????
def?getxml(jpgDetail):
????context=“\n“
????context+=“\tJPGImage \n“
????context+=“\t“+jpgDetail[0]+“ \n“
????context+=“\t/MYPATH/JPGImage/“+jpgDetail[0]+“ \n“
????context+=“\t\n“
????context+=“\t\tse>Unknown se>\n“
????context+=“\t \n“
????context+=“\t\n“
????img?=?cv2.imread(“./jpg/“+jpgDetail[0])#返回一個Image對象
????sp=img.shape
????context+=“\t\t“+str(sp[1])+“ \n“
????context+=“\t\t“+str(sp[0])+“ \n“
????context+=“\t\t
評論
共有 條評論