Open cheer00 opened 6 years ago
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
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:
在 2019年10月18日,下午2:32,cheer00 notifications@github.com 写道:
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.
哇 好给力 谢谢啦
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
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!