从固态硬盘预测的映像ID和盒子 [英] Predicted Image id and box from SSD
本文介绍了从固态硬盘预测的映像ID和盒子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从SSD中找到预测的图像ID和Box,我正在使用GitHub link这里是我想要保存图像ID和Box的测试函数
def test(loader, net, criterion, device):
net.eval()
running_loss = 0.0
running_regression_loss = 0.0
running_classification_loss = 0.0
num = 0
for _, data in enumerate(loader):
images, boxes, labels = data
images = images.to(device)
boxes = boxes.to(device)
labels = labels.to(device)
num += 1
with torch.no_grad():
confidence, locations = net(images)
regression_loss, classification_loss = criterion(confidence, locations, labels, boxes)
loss = regression_loss + classification_loss
running_loss += loss.item()
running_regression_loss += regression_loss.item()
running_classification_loss += classification_loss.item()
return running_loss / num, running_regression_loss / num, run
推荐答案
假设
y = net(x)
detections = y.data
您可以使用以下内容打印检测信息
# this will loop over predictions class by class
for i in range(detections.size(1)):
# this will loop over each detection in the class
for j in range(detections.size(2)):
score = detection[0,i,j,0]
coords = detections[0,i,j,1:]
print(f"Class id: {i} Score: {score} Coords: {coords}")
有关详细信息,请参阅demo。
这篇关于从固态硬盘预测的映像ID和盒子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文