Skip to content

Instantly share code, notes, and snippets.

View hewumars's full-sized avatar

Mars hewumars

View GitHub Profile
@hewumars
hewumars / 1.md
Last active March 28, 2024 10:04
1. 自我介绍及杂项 2. 新基建公司名单 3. 面试总结
  1. 根据AI产品需求完成技术方案设计及算法设计和核心模块开发
  2. 计算机视觉算法的技术方向、技术难点攻关、性能优化等
  3. AI算法在嵌入式(异构平台)和服务器平台部署的研究和实现
  4. 技术上把关交付算法的性能和功能

我优势:

  1. 独立完成算法技术方案设计、嵌入式和服务器平台部署
  2. 模型压缩、量化
@hewumars
hewumars / 1.md
Last active June 21, 2022 12:26
1. 以图搜图2.0版本方案

以图搜图2.0版本方案

1.以图搜图2.0架构图

先通过 Milvus 进行特征值搜索,返回 top 2048条最相似的记录,然后根据特征值ID从Redis 查出相关联结构化信息,如900记录ID+特征值ID+时间+地点等<120字节,进行二次条件过滤,达到10亿级数据 10秒内返回。

2.以图搜图2.0性能

@hewumars
hewumars / 1.md
Last active June 13, 2022 06:05
1. 论文列表 2. D2D Keypoint Extraction with Describe to Detect Approach 论文理解 3. R2D2 Repeatable and Reliable Detector and Descriptor 论文理解 4. ASLFeat Learning Local Features of Accurate Shape and Localization 论文理解 5. 局部特征检索专利技术交底书 6. Attention-Based Query

**关键问题:**尺度不变,具有辨别力的关键点,旋转不变,语义鸿沟(局部特征在表达高级视觉概念方面的局限性,如细微噪声敏感性太强,特征编码空间结构信息缺失,无法捕捉实际问题中的兴趣区域)

优化方向:

  1. 引入更多的监督信息;

  2. 不同程度、维度的attention(包括层、channel、类等等);

  3. Triplet loss及其各种变种;

  4. 不同的特征聚合方式;

  5. 2001.05027-DELG Unifying Deep Local and Global Features for Image Search 从conv4_x提取特征进入attention模块得到local feature,再经过降维从1024->40维,global feature从conv5_x经过聚合得到。端到端global和local特征提取方法

"""
Quantization module for generating the calibration tables will be used by
quantized (INT8) models from FP32 models.with bucket split,[k, k, cin, cout]
cut into "cout" buckets.
This tool is based on Caffe Framework.
"""
from __future__ import division
from __future__ import print_function
import argparse
import numpy as np
1.逐行扫描图像,把每一行连续的非零目标像素组成一个序列称为一个块(block),并加下它的起点start、它的终点end以及它所在的行号。
void fillBlockVectors(const Mat& img,Lanes& lanes){
for(int i=0; i < img.rows; ++i){
const uchar* rowData = img.ptr<uchar>(i);
if(rowData[0] != 0){
lanes.NumOfBlocks++;
lanes.stBlock.push_back(0);
lanes.rowBlock.push_back(i);
lanes.lane_type.push_back(rowData[0]);
}
  1. [ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running Div node GPU版时出现,CPU版正常
  2. INVALID_ARGUMENT : Unexpected input data type. 关注输入数据类型
@hewumars
hewumars / 1.md
Last active January 27, 2021 07:25
1. 图像检索测试demo流程 2. 图像re-rank流程 3. delg模型感受野计算 4. attention模块 5. pca降维 6. BOF,KV,VLAD等局部聚合描述符 7. GeM聚合描述符 8. 相似度比对
  1. gallery入库
  2. 测试query中每一类别图片与gallery中所有图片的特征相似度,保存gallery图片路径和相似度值
  3. 根据相似度排序检索的图片,并输出Top20图片到文件夹
  4. 统计检出的第一张图是同一类别,计数top1(不考虑阈值),计算相似度是否大于阈值,计数Top_One正确数
  5. 统计大于阈值的不是同一类别的图片数量,计算false_alarm_num虚警数
  6. 计算rank,统计底层中搜出同类别数量计数t,rank=rank+(float)t/(i+1)
  7. 检测精度rank/t,计入总mAP += rank/t
  8. 重复2-7,检索完成所有的query类别的所有图片
  9. 输出Top1检测数量top1,TOP1/Rank-1检出率top1/query_total_num,mAP平均均值精度mAP/query_total_num,余弦比对耗时,正确率Top_One/query_total_num,虚警数false_alarm_num,虚警率false_alarm_num/query_total_num

TRT7.1.3支持到Opset 11 TensorFlow2.0使用tf.saved_model.save自定义保存模型 python3 -m tf2onnx.convert

错误问题

  1. Use tf.compat.v1.graph_util.extract_sub_graph AssertionError: unknown_317 is not in graph
  2. trt不支持Round,改用tf.floor或者tf.ceil解决
  3. trt不支持NonZero,由于tf.where(condition, x=None, y=None, name=None)的x,y没有赋值导致,补全xy解决 indices = tf.reshape(tf.where(attention_prob >= abs_thres,tf.ones_like(attention_prob,dtype=tf.int64),tf.zeros_like(attention_prob,dtype=tf.int64)), [-1])
  4. Opset10时trt报错ERROR: builtin_op_importers.cpp:2549 In function importResize: Assertion failed: scales.is_weights() && "Resize scales must be an initializer!" ,使用Opset12转换
torch.mm()
torch.bmm() batch-matrix-matrix两个3-dims矩阵相乘
torch.matmul()
weights.reshape()
weights.resize_()
weights.view()
weights.from_numpy(numpy array)
tensor.numpy()
torch.detach()返回一个新的从当前图中分离出来的Variable,该Variable永远不需要梯度
pytorch均值方差(bgr*255-mean)/std => svn工程 bgr*vStd - vMean 用numpy转换vMean = np.array([mean_b,mean_g,mean_r])/np.array([std_b,std_g,std_r]) vStd = 1/(255*np.array([std_b,std_g,std_r]))
  1. 转换时注意不要有double()算子,因为trt不支持float64
    # export dynamic shape onnx  TensorRT动态输入
    x = torch.randn(4, 3, 256, 256, requires_grad=True).cuda()
    res = net(imgs=[x])
    torch.onnx.export(net,[x],"r2d2-0.onnx",opset_version=11)

    torch.onnx.export(net,                       # model being run
                      [x],                       # model input (or a tuple for multiple inputs)