deeptraining_hands
deeptraining_hands copied to clipboard
print ("successfully converted {}-labels from mat to pascal-xml").format(directory) AttributeError: 'NoneType' object has no attribute 'format'
trafficstars
Hey when I ran mat_to_xml.py I got this error:
mona@Mona:~/code/handpose/deeptraining_hands$ python mat_to_xml.py
successfully converted {}-labels from mat to pascal-xml
Traceback (most recent call last):
File "mat_to_xml.py", line 213, in <module>
main()
File "mat_to_xml.py", line 209, in main
print ("successfully converted {}-labels from mat to pascal-xml").format(directory)
AttributeError: 'NoneType' object has no attribute 'format'
how should this be fixed?
There really should no issue on the call of format(directory) as this is the string the loop iterates over. as the code in main() is:
def main():
# Read a .mat file and convert it to a pascal format
for directory in ['train','eval']:
if not os.path.exists('data/{}/annotations/xml'.format(directory)):
os.makedirs('data/{}/annotations/xml'.format(directory))
MAT_FILES_PATH = os.path.join(os.getcwd(), 'data/{}/annotations/mat'.format(directory))
XML_FILES_PATH = os.path.join(os.getcwd(), 'data/{}/annotations/xml'.format(directory))
IMG_FILES_PATH = os.path.join(os.getcwd(), 'data/{}/images'.format(directory))
# List all files in the MAT_FILES_PATH and ignore hidden files (.DS_STORE for Macs)
mat_files = [[join(MAT_FILES_PATH, x), x] for x in os.listdir(MAT_FILES_PATH) if isfile(join(MAT_FILES_PATH, x)) and x[0] is not '.']
mat_files.sort()
# Iterate through all files and convert them to XML
for mat_file in mat_files:
#print(mat_file)
read_mat_file(mat_file[0], mat_file[1],IMG_FILES_PATH, XML_FILES_PATH)
#break
print ("successfully converted {}-labels from mat to pascal-xml").format(directory)
cv2.destroyAllWindows()
My questions:
- Did you change my code?
- Did you successfully run the dataset setup scripts?
- Which python version are you using?
@monajalal you are facing this issue because in the last print the syntax is wrong for python 3. It is written like this print ("successfully converted {}-labels from mat to pascal-xml").format(directory) but should actually be print ("successfully converted {}-labels from mat to pascal-xml".format(directory)) I hope this helps.