机缘
-
由于不是计算机专业,刚开始出来工作都是从csdn博客学习,配置环境,安装教程都是参考各位大佬们的博客
-
后面自己学习了一些心得,也想着分享给后来人。
收获
-
发布了12篇原创文章,收获了14871访问量,总排名6w+,周排名8k+,粉丝37
-
通过博客提升了自己的语言组织能力,熟悉了markdown编辑,排版。也收获了许多赞美与鼓励
日常
-
在工作中,想到好的trick,都会记录下来,在空闲时间写成博客分享
-
博客也可以记录自己学习的过程。一段时间后回顾之前的博客和学习历程,也是挺有意思。
成就
-
从第一篇博客到如今,成就颇丰。
举一个例子。优化目标检测后处理(yolov3)耗时从20ms优化到1ms,且结果99%一致
// 得到所有的候选框
std::vector<std::shared_ptr<ObjectInfo>> YoloLayer::getCandidateBoxes(const std::vector<void*>& outputPointers)
{
std::vector<std::shared_ptr<ObjectInfo>> result;
std::vector<ObjectType> types = mYoloLayerParam->getObjectType();
// For yolov3 there are three output bindings. The outputs returned (flat array) have data in the following shape and order
// mentioned in OUTPUT_SHAPE
std::vector<std::vector<std::vector<int>>> anchorDims = mYoloLayerParam->getAnchorDims();
std::vector<std::vector<int>> outputShapes = mYoloLayerParam->getOutputShape();
for(int i = 0; i < outputPointers.size(); ++i)
{
auto gridWidth = outputShapes[i][3];
auto gridHeight = outputShapes[i][2];
auto numAnchors = mYoloLayerParam->getAnchorCount();
float* pOutput = (float* )outputPointers[i];
for (uint32_t a = 0; a < numAnchors; ++a)
{
uint32_t obStart = getIndex(a, 4, gridWidth, gridHeight, gridWidth, gridHeight); // 循环开始的值
// uint32_t obEnd = getIndex(a, 5, gridWidth, gridHeight, gridWidth, gridHeight); // 循环结束的值
for (uint32_t ob = obStart; ob < obStart+gridWidth*gridHeight; ++ob)
{
float to = pOutput[ob];
float bo = sigmoid(to);
uint32_t indexBo = ob - obStart;
uint32_t y = indexBo / gridHeight;
uint32_t x = indexBo % gridHeight;
float maxProb = 0.0f;
uint32_t maxIndex = 0;
for (uint32_t c = 0; c < mYoloLayerParam->getClassesCount() ; ++c)
{
uint32_t index = getIndex(a, 5 + c, y, x, gridWidth, gridHeight);
float prob = sigmoid(pOutput[index]);
if (prob > maxProb)
{
maxProb = prob;
maxIndex = c;
}
}
maxProb *= bo;
if (maxProb >= mYoloLayerParam->getConfidenceThreshold())
{
auto currAnchorDim = anchorDims[i][a];
float tx, ty, tw, th, bx, by, bw, bh;
tx = pOutput[getIndex(a, 0, y, x, gridWidth, gridHeight)];
ty = pOutput[getIndex(a, 1, y, x, gridWidth, gridHeight)];
tw = pOutput[getIndex(a, 2, y, x, gridWidth, gridHeight)];
th = pOutput[getIndex(a, 3, y, x, gridWidth, gridHeight)];
bw = (currAnchorDim[0] * exp(tw)); // box width
bh = (currAnchorDim[1] * exp(th)); // box height
// Coordinates are relative to the grid. Scale to detector dimension.
// Later scale up by input resolution.
bx = (((sigmoid(tx) + x) * mYoloLayerParam->getImageSize().width()) / gridWidth) - (bw / 2); // top left x coordinate
by = (((sigmoid(ty) + y) * mYoloLayerParam->getImageSize().height()) / gridHeight) - (bh / 2); // top left y coordinate
// 根据maxIndex获取目标类型
ObjectType type = (maxIndex < types.size()) ? types[maxIndex] : types[0];
QRect position(bx, by, bw, bh);
std::shared_ptr<ObjectInfo> object = std::make_shared<ObjectInfo>(type, position, maxProb);
result.push_back(object);
}
}
}
}
return result;
}
憧憬
-
坚持创作。
-
坚持看书,无论上班还是休假,每天看书1h。
-
在非程序员领域也有成绩。