Coder Social home page Coder Social logo

Comments (8)

ZiQiangXie avatar ZiQiangXie commented on June 18, 2024

labels使用前未定义,原因是这句上面的if判断没进去,labels是if里面定义的。应该是你的样本里面有负样本,没有labels,你可以去掉这些负样本,或者给if加一个
else:
labels = np.zeros((0,5), dtype=np.float32)
生成一个0标签,这个工程用的原版的yolov3是有这一句的。
不知道有负样本对稀疏训练会不会有影响。

from yolov3-channel-and-layer-pruning.

wangkangchn avatar wangkangchn commented on June 18, 2024

from yolov3-channel-and-layer-pruning.

JieShare avatar JieShare commented on June 18, 2024

labels使用前未定义,原因是这句上面的if判断没进去,labels是if里面定义的。应该是你的样本里面有负样本,没有labels,你可以去掉这些负样本,或者给if加一个
else:
labels = np.zeros((0,5), dtype=np.float32)
生成一个0标签,这个工程用的原版的yolov3是有这一句的。
不知道有负样本对稀疏训练会不会有影响。

原版没找到这句哎

from yolov3-channel-and-layer-pruning.

ZiQiangXie avatar ZiQiangXie commented on June 18, 2024

@FishEatApple
以前的版本是有的,可能后来又删了。

from yolov3-channel-and-layer-pruning.

JieShare avatar JieShare commented on June 18, 2024

@FishEatApple
以前的版本是有的,可能后来又删了。

还有一个问题,是不是应该是

labels = np.zeros((1,5), dtype=np.float32)

而不是

labels = np.zeros((0,5), dtype=np.float32)

也就是说将未标注的负样本图片的类别与坐标全部置零,这样才能参与训练和计算损失函数嘛,我说的对吗?

from yolov3-channel-and-layer-pruning.

ZiQiangXie avatar ZiQiangXie commented on June 18, 2024

@FishEatApple
就是(0,5),这个其实就是起一个占位的作用,只定义了一个shape和labels一样的空值而已。没有标注的负样本就是没有label,如果都写成0,那就是认为负样本含有有效的目标了,只不过坐标都是零,我没试过不知道会不会报错,但是这样处理是不对的。目标检测的loss计算中的正负样本,不是指图片是正负样本,而是指目标框,这个建议看一下各个检测框架对正负样本的选取。

from yolov3-channel-and-layer-pruning.

JieShare avatar JieShare commented on June 18, 2024

@FishEatApple
就是(0,5),这个其实就是起一个占位的作用,只定义了一个shape和labels一样的空值而已。没有标注的负样本就是没有label,如果都写成0,那就是认为负样本含有有效的目标了,只不过坐标都是零,我没试过不知道会不会报错,但是这样处理是不对的。目标检测的loss计算中的正负样本,不是指图片是正负样本,而是指目标框,这个建议看一下各个检测框架对正负样本的选取。

但是如果写成(0,5)的话,是会报错的,因为这样target的class和xywh是空值,pred的值无法与之计算loss了。我改成(1,5)后就能正常训练(但是不能使用focal loss了),而且模型实测是有效果的,但是我觉得(1,5)在理论上确实有点说不通,(1,5)的意思是没有目标的样本的class是0,xywh也是0。

from yolov3-channel-and-layer-pruning.

ZiQiangXie avatar ZiQiangXie commented on June 18, 2024

@FishEatApple
我写成0是正常的。不太清楚你的报错问题,不过写成1就真的是给图片添加了一个全0的label。你可以在原版里面找,2019年12月27号左右,我下载的有这一天的版本。也可能是作者改动的比较大了,比如现在的版本没有else这一句,而loss那一块对应的处理也和当时不一样了,所以加了会报错。或者你也可以不添加了,直接把labels4.append(labels)增加一个缩进。之前的报错就是因为负样本进不了上面的 if 导致 labels 没有定义,增加缩进就保证append一定能添加。

from yolov3-channel-and-layer-pruning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.