update ieemoo-ai-isempty.py.

This commit is contained in:
Brainway
2023-03-14 08:36:39 +00:00
committed by Gitee
parent 207bc1603c
commit fd366d76b0

View File

@ -80,8 +80,11 @@ class Predictor(object):
probs = torch.nn.Softmax(dim=-1)(part_logits) probs = torch.nn.Softmax(dim=-1)(part_logits)
topN = torch.argsort(probs, dim=-1, descending=True).tolist() topN = torch.argsort(probs, dim=-1, descending=True).tolist()
clas_ids = topN[0][0] clas_ids = topN[0][0]
clas_ids = 0 if 0==int(clas_ids) or 2 == int(clas_ids) or 3 == int(clas_ids) else 1
print("cur_img result: class id: %d, score: %0.3f" % (clas_ids, probs[0, clas_ids].item())) print("cur_img result: class id: %d, score: %0.3f" % (clas_ids, probs[0, clas_ids].item()))
if(int(clas_ids)==6 or int(clas_ids)==7):
clas_ids = 0
else:
clas_ids = 1
result["success"] = "true" result["success"] = "true"
result["rst_cls"] = str(clas_ids) result["rst_cls"] = str(clas_ids)
return result return result