Comments (6)
hello,everybody, I have solved this problem. It just caused by the version of pytorch. most of all use the pytorch>=0.4,but this version of torch is 0.3 or lower.
here is the solution of nms:
def nms(bboxes,scores,threshold=0.5):
'''
bboxes(tensor) [N,4]
scores(tensor) [N,]
'''
x1 = bboxes[:,0]
y1 = bboxes[:,1]
x2 = bboxes[:,2]
y2 = bboxes[:,3]
areas = (x2-x1) * (y2-y1)
_,order = scores.sort(0,descending=True)
# print("order1:",order)
keep = []
while order.numel() > 0:
if order.numel()>1:
i = order.tolist()[0]
keep.append(i)
else:
keep.append(order.item())
break
xx1 = x1[order[1:]].clamp(min=x1[i])
yy1 = y1[order[1:]].clamp(min=y1[i])
xx2 = x2[order[1:]].clamp(max=x2[i])
yy2 = y2[order[1:]].clamp(max=y2[i])
w = (xx2-xx1).clamp(min=0)
h = (yy2-yy1).clamp(min=0)
inter = w*h
ovr = inter / (areas[i] + areas[order[1:]] - inter)
ids = (ovr<=threshold).nonzero().squeeze()
if ids.numel() == 0:
break
order = order[ids+1]
return torch.LongTensor(keep)
```_
from pytorch-yolo-v1.
I used
i = order.item()
but it doesn't work
from pytorch-yolo-v1.
Move this line of code if order.numel() == 1: break
in front of i = order.item()
.
from pytorch-yolo-v1.
Move this line of code
if order.numel() == 1: break
in front ofi = order.item()
.
i do this according to your reply ,but it does not work. would you tell me more info about it ?
from pytorch-yolo-v1.
你好 请问你这个问题解决了吗 我也同样的问题
from pytorch-yolo-v1.
order sometimes is list, sometime only 1 element. (it's order!), so when only 1 element --> use .item(), when it's a list. use .list()[0]
from pytorch-yolo-v1.
Related Issues (20)
- about grid_num=14 HOT 2
- 您能提供一下预训练好的模型文件吗,谢谢! HOT 2
- 你的resnet50作为backbone时,输入(3,448,448)的图片,输出维度不是(7,7,30)! HOT 7
- yoloLoss的组成部分中contain_loss的可疑之处 HOT 1
- predict.py中的nms是对所有类别一起做nms吗?
- 执行eval_voc,Expected 4-dimensional input for 4-dimensional weight 64 3 7 7, but got 3-dimensional input of size [3, 448, 448] instead
- 这里操作是不是有问题? HOT 6
- predict.py error HOT 2
- Can't find the listfile.txt HOT 4
- About BatchNormalization HOT 1
- 损失函数的参数好像有点问题 HOT 4
- ImportError: cannot import name 'queue' from 'torch._six' (/home/liqi/.local/lib/python3.8/site-packages/torch/_six.py) HOT 5
- loss变化图片
- ValueError: Input must be >= 2-d. HOT 3
- 训练了 5 个epoch , pred bbox 的x2 竟然小于 x1 HOT 6
- best.pth
- IndexError: invalid index of a 0-dim tensor
- some pictures in annotation txt(voc2007.txt+ voc2012.txt) are not in the image folder(2007trainval + 2012trainval)
- 请问为什么要代码中加入了sigmoid? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch-yolo-v1.