java调用python的人脸聚类

java代码

    @Test
    public void test2() {
        Process proc;
        try {
            proc = Runtime.getRuntime().exec("src/test/java/run.bat");// 执行文件
            //用输入输出流来截取结果
            BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
            String line = null;
            while ((line = in.readLine()) != null) {
                System.out.println(line);
            }
            in.close();
            int i = proc.waitFor();
            System.out.println(i);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

 bat

(python项目路径)
cd C:\PyCharmProject\face-cluster-framework
(进入anaconda虚拟环境,通过右键anaconda prompt获取网上有教程)
call C:\apply\anaconda3\Scripts\activate.bat C:\apply\anaconda3\envs\c38
(运行)
python main.py

 python

人脸聚类框架(Face Cluster Framework)_Mr_不想起床的博客-CSDN博客_人脸聚类

python3.8(3.9跟faiss有冲突)

遇到的问题

1.刚开始pycharm pip安装几个第三方包失败:可以去官网下载

2.pycharm上能运行到cmd就不行:因为我pycharm中用的anaconda的虚拟环境,cmd中要运行可以 conda activate 环境所在的路径,然后python.py运行

3.pytorch安装:官网,根据自己cuda版本选就行,查看版本

4.proc.waitFor()值为1:python运行失败了,用cmd运行查看错误在哪,我是因为系统环境没有faiss,pycharm不会显示报错

5.找不到指定模块:可以根据倒数第八行找到错误,再通过2或者官方下载方式解决

Traceback (most recent call last):
  File "main.py", line 61, in <module>
    cluster_main(args, extract_features)
  File "C:\PyCharmProject\face-cluster-framework\face_cluster\face_cluster_by_infomap.py", line 235, in cluster_main
    dists, nbrs = get_dist_nbr(features=extract_features, args=args)
  File "C:\PyCharmProject\face-cluster-framework\face_cluster\face_cluster_by_infomap.py", line 228, in get_dist_nbr
    index = knn_faiss(feats=features, k=args.k, knn_method=args.knn_method)
  File "C:\PyCharmProject\face-cluster-framework\face_cluster\face_cluster_by_infomap.py", line 65, in __init__
    import faiss
  File "C:\apply\anaconda3\envs\c38\lib\site-packages\faiss\__init__.py", line 18, in <module>
    from .loader import *
  File "C:\apply\anaconda3\envs\c38\lib\site-packages\faiss\loader.py", line 65, in <module>
    from .swigfaiss import *
  File "C:\apply\anaconda3\envs\c38\lib\site-packages\faiss\swigfaiss.py", line 13, in <module>
    from . import _swigfaiss
ImportError: DLL load failed while importing _swigfaiss: 找不到指定的模块。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Abstract—Clustering face images according to their latent identity has two important applications: (i) grouping a collection of face images when no external labels are associated with images, and (ii) indexing for efficient large scale face retrieval. The clustering problem is composed of two key parts: representation and similarity metric for face images, and choice of the partition algorithm. We first propose a representation based on ResNet, which has been shown to perform very well in image classification problems. Given this representation, we design a clustering algorithm, Conditional Pairwise Clustering (ConPaC), which directly estimates the adjacency matrix only based on the similarities between face images. This allows a dynamic selection of number of clusters and retains pairwise similarities between faces. ConPaC formulates the clustering problem as a Conditional Random Field (CRF) model and uses Loopy Belief Propagation to find an approximate solution for maximizing the posterior probability of the adjacency matrix. Experimental results on two benchmark face datasets (LFW and IJB-B) show that ConPaC outperforms well known clustering algorithms such as k-means, spectral clustering and approximate Rank-order. Additionally, our algorithm can naturally incorporate pairwise constraints to work in a semi-supervised way that leads to improved clustering performance. We also propose an k-NN variant of ConPaC, which has a linear time complexity given a k-NN graph, suitable for large datasets. Index Terms—face clustering, face representation, Conditional Random Fields, pairwise constraints, semi-supervised clustering.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值