error:
eq() received an invalid combination of arguments - got (numpy.ndarray), but expected one of:
- (Tensor other)
didn’t match because some of the arguments have invalid types: (!numpy.ndarray!) - (Number other)
didn’t match because some of the arguments have invalid types: (!numpy.ndarray!)
remove = (g_pids[order] == q_pid) & (g_camids[order] == q_camid)
TypeError: eq() received an invalid combination of arguments - got (numpy.ndarray), but expected one of:
- (Tensor other)
didn’t match because some of the arguments have invalid types: (numpy.ndarray) - (Number other)
didn’t match because some of the arguments have invalid types: (numpy.ndarray)
solution:
You are trying to compare predicted and labels. However, your predicted is an np.array while labels is a torch.tensor therefore eq() (the == operator) cannot compare between them.
Replace the np.argmax with torch.argmax:
实际上的solution:
将 pids = pids.cuda() 去掉,因为这里cuda会将numpy转化为tensor,而实际上是用numpy 而不是tensor
文件名字修改:
srcpath = ‘/mnt/hgfs/share/DT2/testdata’
a = 81002
for root,dirs,files in os.walk(srcpath):
a += 1
b = 0
for imagefile in files[0::2]:
b += 1
jsonfile = files[files.index(imagefile)+1]
oldimage = root + ‘/’ + imagefile
newimage = root + ‘/’ + ‘20190704000’ + str(a) + ‘000’ + str(b) + ‘.jpg’
oldjson = root + ‘/’ + jsonfile
newjson = root + ‘/’ + ‘20190704000’ + str(a) + ‘000’ + str(b) + ‘.json’
os.rename(oldimage,newimage)
os.rename(oldjson,newjson)