PaddleCV-SIG / PaddleLabel

飞桨智能标注,让标注快人一步
https://paddlecv-sig.github.io/PaddleLabel/
Apache License 2.0
236 stars 38 forks source link

多标签分类导出的数据不对 #180

Closed andyz168 closed 1 year ago

andyz168 commented 1 year ago

image 生成的是下面的格式

image\230209_075442_0000000009_CAM2_NG.jpg 4 0
image\230209_080039_0000000092_CAM2_NG.jpg 0

其中第一列为图像文件名,其后的列分别为你自己定义的标签用空格分开,为1则是,0否。 需要的格式的/t 空格 空格...

andyz168 commented 1 year ago
import os

current_dir = os.getcwd()
print(current_dir) 

current_dir = os.path.dirname(__file__)
print(current_dir)
data = ['0', '1', '2', '3','4','5']

with open(current_dir+'/train_list.txt', 'r') as f_in, open(current_dir+'/train_list1.txt', 'w') as f_out:

    for line in f_in:

        parts = line.strip().split() 

        parts[0] = parts[0].replace(' ', '\t') 

        if len(parts) > 1:
            parts[1:] = [p.replace(' ', ',') for p in parts[1:]]

        myh=','.join(parts[1:]) 
        print(myh)
        tempp=[];
        for item in data:
            if item in myh:
                tempp.append('1')
            else:
                tempp.append('0')

        print(','.join(tempp))

        myline=parts[0] + '\t' + ','.join(tempp) 

        f_out.write(myline + '\n')

小菜鸡,写了个脚本转换了下 image\230209_075442_0000000009_CAM2_NG.jpg 4 0 image\230209_080039_0000000092_CAM2_NG.jpg 0 image\230209_080438_0000000970_CAM1_NG.jpg 2 image\230209_075442_0000000009_CAM2_NG.jpg 1,0,0,0,1,0 image\230209_080039_0000000092_CAM2_NG.jpg 1,0,0,0,0,0 image\230209_080438_0000000970_CAM1_NG.jpg 0,0,1,0,0,0

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.