Skip to main content

robotpipe Python Library

========================

License


The code of robotpipe Python Library is released under the MIT License.

There is no limitation for both academic and commercial usage.

robotpipe Python Library is an artificial intelligence learning library,

including mainstream advanced artificial intelligence libraries, such as

InsightFace, yolov8, paddleocr, etc.

本项目具备如下推理功能:

  • 人脸检测

  • 人脸识别

  • 人脸年龄与性别识别

  • 人脸106个特征点

  • 换脸

B站演示地址: https://space.bilibili.com/485304569

安装


安装opencv

.. code:: python

pip install opencv-python-headless==4.6.0.66

pip install opencv-python==4.6.0.66

pip install opencv-contrib-python==4.6.0.66

安装onnxruntime

.. code:: python

pip install onnxruntime

若你的电脑支持gpu,可以进入如下安装

.. code:: python

pip install onnxruntime-gpu

pip安装

.. code:: python

pip install robotpipe==0.0.3

若安装失败,请指定安装路径

.. code:: python

pip install robotpipe==0.0.3 -i https://pypi.tuna.tsinghua.edu.cn/simple

导入权重文件




在用户目录下新建\ ``.robotpipe``\ 文件夹



.. code:: python



   C:\Users\KAI\.robotpipe\models

   在models里面放入权重文件



从百度网盘中下载权重文件,并解压释放进去



功能演示

--------



人脸检测

~~~~~~~~



.. image:: ./images/detect.jpg



.. code:: python



   from robotpipe import FaceDetection

   from robotpipe import draw_faces

   import cv2 as cv

   import numpy as np



   if __name__ == '__main__':

       face_detection = FaceDetection()

       img = cv.imread('images/trump1.jpg')

       faces = face_detection.predict(img)

      

       dst = draw_faces(img,faces)

       

       cv.imshow('img',dst)

       cv.waitKey(0)



人脸识别

~~~~~~~~



.. image:: images/recog.jpg



.. code:: python



   from robotpipe import FaceRecognition

   import cv2 as cv

   import numpy as np



   if __name__ == '__main__':

       face_recognition = FaceRecognition()

       trump1 = cv.imread('images/trump1.jpg')

       trump2 = cv.imread('images/trump2.jpg')

       

       # 获取人脸特征

       feats1 = face_recognition.predict(trump1)

       feats2 = face_recognition.predict(trump2)

       

       sim = face_recognition.compute_sim(feats1,feats2)



       # 根据相似度,输出结果

       if sim<0.2:

           conclu = 'they are not the same'

       elif sim>=0.2 and sim<0.28:

           conclu = 'they are looks like the same people'

       else:

           conclu = 'they are the same people'



       print(sim,conclu)



       cv.imshow('trump1',trump1)

       cv.imshow('trump2',trump2)

       cv.waitKey(0)



人脸年龄与性别识别

.. image:: images/genderage.jpg

.. code:: python

from robotpipe import FaceAttribute

from robotpipe import draw_faces

import cv2 as cv

import numpy as np

if name == 'main':

   face_attr = FaceAttribute()

   img = cv.imread('images/trump1.jpg')

   

   # 获取人脸特征

   faces = face_attr.predict(img)

   # 1 表示男性, 0,表示女性

   print(faces[0])

   dst = draw_faces(img,faces)

   cv.imshow("images/1.jpg",dst)

   cv.waitKey(0)

人脸106个特征点




.. image:: images/landmark.jpg



.. code:: python



   from robotpipe import FaceLandmark

   import cv2 as cv

   import numpy as np

   from robotpipe import draw_faces,draw_landmarks



   if __name__ == '__main__':

       face_attr = FaceLandmark()

       trump1 = cv.imread('images/trump1.jpg')



       # 获取人脸特征106个特征点

       faces = face_attr.predict(trump1)



       retimg = draw_landmarks(trump1,faces)

       cv.imshow('trump1_landmark',retimg)

       cv.waitKey(0)



换脸

~~~~



.. image:: images/swapper.jpg



.. code:: python



   from robotpipe import FaceSwapper



   import cv2 as cv

   import numpy as np



   if __name__ == '__main__':

       face_swapper = FaceSwapper()

       trump1 = cv.imread('images/trump1.jpg')

       target = cv.imread('images/1.jpg')



       sourceFace = face_swapper.get_source_face(trump1)



       dst = face_swapper.predict(sourceFace, target)

      

       cv.imshow("trump1",trump1)

       cv.imshow("1",target)

       cv.imshow("dst", dst)

       cv.waitKey()



若运行代码出现一下错误,则是\ ``opencv-python-headless``\ 与\ ``opencv-python``\ 版本不匹配的原因



.. code:: python



   cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\highgui\src\window.cpp:1272: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'



卸载\ ``opencv-python-headless``,重新安装



.. code:: python



   pip install opencv-python-headless==4.6.0.66

   pip install opencv-python==4.6.0.66

   pip install opencv-contrib-python==4.6.0.66



本项目参考以下工程:



`InsightFace <https://insightface.ai/>`__



`PaddleOCR <https://github.com/PaddlePaddle/PaddleOCR>`__

Metadata

Release files for robotpipe 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for robotpipe 0.0.4
File Size Uploaded Provenance Actions
robotpipe-0.0.4.tar.gz 482.4 kB Without provenance Details for robotpipe-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for robotpipe 0.0.4
File Interpreter ABI Platform Actions
robotpipe-0.0.4-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details for robotpipe-0.0.4-cp39-cp39-win_amd64.whl

Total release size: 1.9 MB

Release files / robotpipe-0.0.4.tar.gz

Download URL robotpipe-0.0.4.tar.gz
Size 482.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3dac9f36efd713a3c866f855ea6e258d51c6ba653d9b5ac1d33a900e64ce393b
BLAKE2b-256 checksum
How to use checksums
83a15714d34c04fa4d7a76fd372622f0e42e4ba441c7df073e0802892dbbacdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / robotpipe-0.0.4-cp39-cp39-win_amd64.whl

Download URL robotpipe-0.0.4-cp39-cp39-win_amd64.whl
Size 1.4 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
2858cd94e486cba47b9a00835f3cdda0b12baabded6a16af33bbb40e2eeb183a
BLAKE2b-256 checksum
How to use checksums
c9cc19f9591d9927ab70914abc1276c6cb32b3703081d7746ccc67c192ff9aac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Security for robotpipe 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page