标签:python

0

746

insightface人脸识别算法的应用

在研究 stable-diffusion 的一些 ai 功能时,发现了 insightface 这个开源的人脸检测识别、比对算法模型库。

github 源码

python 类库 : https://pypi.org/project/insightface/

在对它应用时发现一些环境兼容性的问题,因此作一下笔记。

insightface 安装

insightface 目前 python 官方的版本是 0.7.3

pip install insightface

命令即可安装

环境兼容性问题

由于 0.7.3 版本大概两年前,彼时 numpy 版本应该是 1.22.3
因此它使用了 numpy.ini 这个属性,但目前 numpy 版本已经迭代到 1.26 以上, numpy.intNumPy 1.20中已弃用,在NumPy 1.24中已被删除,所以没有numpy.int

因此,insightface 实际使用时会报错:

Traceback (most recent call last):
  File "/data/work/py/sd-api/main.py", line 80, in <module>
    start(sys.argv[1:])
  File "/data/work/py/sd-api/main.py", line 72, in start
    img2img.img2img(filename)
  File "/data/work/py/sd-api/img2img.py", line 150, in img2img
    cv2.imwrite(faceSaveName, face_analyser.draw_on(faceCheckImg, faces))
  File "/home/xiao/anaconda3/envs/sd/lib/python3.10/site-packages/insightface/app/face_analysis.py", line 84, in draw_on
    box = face.bbox.astype(np.int)
  File "/home/xiao/anaconda3/envs/sd/lib/python3.10/site-packages/numpy/__init__.py", line 324, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'inf'?

解决办法,要么根据提示,将代码中对应的 numpy.ini 修改成 numpy.ini_, 即修改 insightface 源码。

……

乐果   发表于   2024 年 05 月 08 日 标签:pythonai 继续阅读

0

441

ubuntu 22.04 系统下python开发环境以及IDE工具搭建

安装Anaconda

下载 : Anaconda

安装Anaconda

#假设下载目录在download
cd ~/download
chmod 755 Anaconda3-2023.09-0-Linux-x86_64.sh
./Anaconda3-2023.09-0-Linux-x86_64.sh
#后面按提示操作即可。。。如下是本机安装成功后的提示:
...
done
installation finished.
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
   run the following command when conda is activated:

conda config --set auto_activate_base false

You can undo this by running `conda init --reverse $SHELL`? [yes|no]
[no] >>> yes
no change     /home/xiao/anaconda3/condabin/conda
no change     /home/xiao/anaconda3/bin/conda
no change     /home/xiao/anaconda3/bin/conda-env
no change     /home/xiao/anaconda3/bin/activate
no change     /home/xiao/anaconda3/bin/deactivate
no change     /home/xiao/anaconda3/etc/profile.d/conda.sh
no change     /home/xiao/anaconda3/etc/fish/conf.d/conda.fish
no change     /home/xiao/anaconda3/shell/condabin/Conda.psm1
no change     /home/xiao/anaconda3/shell/condabin/conda-hook.ps1
no change     /home/xiao/anaconda3/lib/python3.11/site-packages/xontrib/conda.xsh
no change     /home/xiao/anaconda3/etc/profile.d/conda.csh
modified      /home/xiao/.zshrc

==> For changes to take effect, close and re-open your current shell. <==

Thank you for installing Anaconda3!

如果是windows安装,安装后加入环境变量(假如你安装的目录为 D:\opt\Anaconda3 ):

D:\opt\Anaconda3
D:\opt\Anaconda3\Scripts
D:\opt\Anaconda3\Library\bin

假设上面安装的目录地址为:/home/xiao/anaconda3 ,创建 spyder IDE 用应的图标:

#拷贝png图标图片到根目录
cp /home/xiao/anaconda3/pkgs/spyder-5.4.3-py311h06a4308_1/share/icons/spyder.png /home/xiao/anaconda3
#编辑desktop应用配置文件
vim /usr/share/applications/spyder.desktop

将如下保存至 /usr/share/applications/spyder.desktop

[Desktop Entry]
Version=1.0
Type=Application
Name=Spyder
Exec="/home/xiao/anaconda3/bin/spyder" %f
Icon=/home/xiao/anaconda3/spyder.png
Comment=The Drive to Develop
Categories=Development;IDE;
Terminal=false
StartupWMClass=Spyder

……

乐果   发表于   2023 年 11 月 30 日 标签:ubuntupythonconda 继续阅读

0

2443

数据类型

笔记于2012-12-31, 百度空间。

现因百度空间封闭,故转载过来。

第一次了解“数据类型”这个概念,是学习javascript的时候。

js将数据分为两大类型:“基本类型”(或称“值类型”)和“引用类型”,二者的区别可以用一个经典的例子来说明:

……

乐果   发表于   2016 年 09 月 06 日 标签:JavaScriptPHPpython 继续阅读

热评文章