Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPShitu特征提取后,为何2张图很相似的图,特征向量的距离值很大(distance: [0.27994147])? #3157

Open
GreenValue opened this issue May 28, 2024 · 1 comment
Assignees

Comments

@GreenValue
Copy link

欢迎您使用PaddleClas并反馈相关问题,非常感谢您对PaddleClas的贡献!
提出issue时,辛苦您提供以下信息,方便我们快速定位问题并及时有效地解决您的问题:

  1. PaddleClas版本以及PaddlePaddle版本:
    conda中安装了
    paddlepaddle 2.4.2 py310_cpu_windows https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle

然后在conda环境中,用PaddleClas release/2.5代码,执行了 python setup.py install
2. 涉及的其他产品使用的版本号:
3. 训练环境信息:
a. 具体操作系统,如Windows 的conda环境
b. Python版本号,如F:\PaddleClas\deploy\python\predict_rec.py
c. CUDA/cuDNN版本:无
4. 完整的代码(相比于repo中代码,有改动的地方)、详细的错误信息及相关log

按照【特征提取

使用模型:general_PPLCNetV2_base_pretrained_v1.0_infer

color_small
color_big

F:\PaddleClas\deploy>python python/predict_rec.py -c configs/inference_rec.yaml
inference_rec.yaml的内容,如附件inference_rec.txt

抽取2图特征向量,并求2个特征向量的距离。
看起来很相似的图,但距离值很大,distance: [0.27994147]

这是自己写的求特征向量距离的函数:

def euclidean_distance(output1, output2):
# 计算两个batch_output之间的差值
diff = output1 - output2
# 计算每个样本的平方差值
squared_diff = np.square(diff)
# 沿axis=1对每个样本的平方差值求和
sum_squared_diff = np.sum(squared_diff, axis=1)
# 求和后再开平方得到欧几里德距离
distances = np.sqrt(sum_squared_diff)

return distances
@cuicheng01
Copy link
Collaborator

建议去看下余弦距离哦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants