[英]TypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U21'), dtype('<U21')) -> dtype('<U21')
I run my code and it throw a error in line 79:我运行我的代码,它在第 79 行抛出一个错误:
numpy.core._exceptions.UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U21'), dtype('<U21')) -> dtype('<U21').
Everybody know how to fix please help me.大家知道怎么解决请帮帮我。 Thank you so much.
非常感谢。 My code:
我的代码:
68 multi_df = pd.read_csv(FLAGS.VoTT_csv)
69 labels = multi_df["label"].unique()
70 labeldict = dict(zip(labels, range(len(labels))))
71 multi_df.drop_duplicates(subset=None, keep="first", inplace=True)
72 train_path = FLAGS.VoTT_Folder
73 convert_vott_csv_to_yolo(
74 multi_df, labeldict, path=train_path, target_name=FLAGS.YOLO_filename
75 )
76 file = open(classes_filename, "w")
77 SortedLabelDict = sorted(labeldict.items(), key=lambda x: x[1])
78 for elem in SortedLabelDict:
79 file.write(elem[0] + "\n")
80 file.close()
The likely situation is that elem[0]
in line 79 isn't a string, but rather is a numeric type from deep in numpy.可能的情况是第 79 行中的
elem[0]
不是字符串,而是来自 numpy 深处的数字类型。
Try changing lines 78 and 79 to this instead:尝试将第 78 行和第 79 行改为:
for elem in SortedLabelDict:
file.write(str(elem[0]) + "\n")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.