MSDA icon indicating copy to clipboard operation
MSDA copied to clipboard

office-31database's label

Open cheer00 opened this issue 6 years ago • 4 comments

I have download the office-31 database, but there is no "label.txt "file which is needed in the code. So I want to know where to get the label.txt. Thank you very much!

cheer00 avatar Oct 29 '18 06:10 cheer00

I have download the office-31 database, but there is no "label.txt "file which is needed in the code. So I want to know where to get the label.txt. Thank you very much!

hello. have u got the "label.txt"? I met the same problem

jjn037 avatar Oct 18 '19 06:10 jjn037


import os
import shutil
import codecs

def build_path(path):
    if os.path.exists(path):
        shutil.rmtree(path)
    os.makedirs(path)

input_data_path ='/home/xxx/'
output_data_path = '/home/xxx/'

f = codecs.open(os.path.join(output_data_path, 'label.txt'), 'a+', 'utf-8')

label_temp = 0

file_list1=[v for v in os.listdir(input_data_path)]
file_list1.sort()

for file in file_list1:
    file_path = os.path.join(input_data_path, file)
        
    for pic in os.listdir(file_path):
        pic_path = os.path.join(file_path, pic)
        context = str(input_data_path) + str(file) + '/' + str(pic) + ' ' + str(label_temp) + '\n'
        f.write(str(context))
   label_temp +=1      

f.close()

run with this code, and you can get a label.txt like this: image

cheer00 avatar Oct 18 '19 06:10 cheer00

在 2019年10月18日,下午2:32,cheer00 [email protected] 写道:

import os import shutil import codecs

def build_path(path): if os.path.exists(path): shutil.rmtree(path) os.makedirs(path)

input_data_path ='/home/xxx/' output_data_path = '/home/xxx/'

f = codecs.open(os.path.join(output_data_path, 'label.txt'), 'a+', 'utf-8')

label_temp = 0

file_list1=[v for v in os.listdir(input_data_path)] file_list1.sort()

for file in file_list1: file_path = os.path.join(input_data_path, file)

for pic in os.listdir(file_path):
    pic_path = os.path.join(file_path, pic)
    context = str(input_data_path) + str(file) + '/' + str(pic) + ' ' + str(label_temp) + '\n'
    f.write(str(context))

label_temp +=1

f.close() run with this code, and you can get a label.txt like this: https://user-images.githubusercontent.com/16377064/67070955-eed6b800-f1b3-11e9-9337-459abf348823.png — You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/HCPLab-SYSU/MSDA/issues/1?email_source=notifications&email_token=AEGMCENJFCCZXTIMWINWEP3QPFKBVA5CNFSM4F72GAWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBS4R5I#issuecomment-543541493, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEGMCEMMTVKZS5B6TQWAJIDQPFKBVANCNFSM4F72GAWA.

哇 好给力 谢谢啦

jjn037 avatar Oct 18 '19 07:10 jjn037

When I run this code, I found that the line of code "f = codecs.open(os.path.join(output_data_path, 'label.txt'), 'a+', 'utf-8')" should be placed after reading "file_list1", so as not to read an extra label.txt file

wudaliu avatar Mar 20 '23 01:03 wudaliu