DeepFace【部署 03】轻量级人脸识别和面部属性分析框架deepface在Linux环境下服务部署(conda虚拟环境+docker)_deepface部署

2.安装deprecated

pip install deprecated==1.2.13

防止报错

ModuleNotFoundError: No module named ‘deprecated’


使用`yum install mesa-libGL.x86_64`命令会在Linux系统中安装mesa-libGL包。这个包包含了Mesa 3D图形库的运行时库和DRI驱动。安装mesa-libGL包后,系统将能够支持OpenGL,这是一种用于渲染2D和3D矢量图形的跨语言、跨平台的应用程序编程接口(API)。


### 1.2 服务启动


DeepFace serves an API as well. You can clone `[/api]( )` folder and run the api via gunicorn server. This will get a rest service up. In this way, you can call deepface from an external system such as mobile app or web.



cd scripts
./service.sh


Linux系统使用这个命令是前台启动,实际的启动用的是shell脚本,内容如下:



#!/bin/bash
nohup python -u ./api/api.py > ./deepfacelog.out 2>&1 &


Face recognition, facial attribute analysis and vector representation functions are covered in the API. You are expected to call these functions as http post methods. Default service endpoints will be `http://localhost:5000/verify` for face recognition, `http://localhost:detector_backend` for facial attribute analysis, and `http://localhost:5000/represent` for vector representation. You can pass input images as exact image paths on your environment, base64 encoded strings or images on web. [Here]( ), you can find a postman project to find out how these methods should be called.  
 这里仅贴出如何传递base64进行接口调用:



{
“img_path”: “data:image/,image_base64_str”
}


仅看一下base64相关源码:



def load_image(img):
# The image is a base64 string
if img.startswith(“data:image/”):
return loadBase64Img(img)

def loadBase64Img(uri):
encoded_data = uri.split(“,”)[1]
nparr = np.fromstring(base64.b64decode(encoded_data), np.uint8)
img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
return img


## 2.使用Docker[680ms]


You can deploy the deepface api on a kubernetes cluster with docker. The following [shell script]( ) will serve deepface on `localhost:5000`. You need to re-configure the [Dockerfile]( ) if you want to change the port. Then, even if you do not have a development environment, you will be able to consume deepface services such as verify and analyze. You can also access the inside of the docker image to run deepface related commands. Please follow the instructions in the [shell script]( ).  
 修改Dockerfile,调整镜像库:



base image

FROM python:3.8
LABEL org.opencontainers.image.source https://github.com/serengil/deepface

-----------------------------------

create required folder

RUN mkdir /app
RUN mkdir /app/deepface

-----------------------------------

Copy required files from repo into image

COPY ./deepface /app/deepface
COPY ./api/app.py /app/
COPY ./api/routes.py /app/
COPY ./api/service.py /app/
COPY ./requirements.txt /app/
COPY ./setup.py /app/
COPY ./README.md /app/

-----------------------------------

switch to application directory

WORKDIR /app

-----------------------------------

update image os

RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6 -y

-----------------------------------

if you will use gpu, then you should install tensorflow-gpu package

RUN pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host=files.pythonhosted.org tensorflow-gpu

-----------------------------------

install deepface from pypi release (might be out-of-the-date)

RUN pip install deepface -i https://pypi.tuna.tsinghua.edu.cn/simple

-----------------------------------

environment variables

ENV PYTHONUNBUFFERED=1

-----------------------------------

run the app (re-configure port if necessary)

EXPOSE 5000
CMD [“gunicorn”, “–workers=1”, “–timeout=3600”, “–bind=0.0.0.0:5000”, “app:create_app()”]


官网启动命令:



cd scripts
./dockerize.sh


报错:



unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/deepface/scripts/Dockerfile: no such file or directory
Unable to find image ‘deepface:latest’ locally
docker: Error response from daemon: pull access denied for deepface, repository does not exist or may require ‘docker login’: denied: requested access to the resource is denied.
See ‘docker run --help’.


解决【不要 cd scripts】原因是执行脚本的文件夹要跟构建镜像使用的Dockerfile同级:



./scripts/dockerize.sh

这个过程一共有两个步骤:1是构建镜像;2是启动容器。构建镜像的速度取决于网速【时间可能会比较久】


分解步骤:



构建镜像

docker build -t deepface_image .

为了做好运维面试路上的助攻手,特整理了上百道 【运维技术栈面试题集锦】 ,让你面试不慌心不跳,高薪offer怀里抱!

这次整理的面试题,小到shell、MySQL,大到K8s等云原生技术栈,不仅适合运维新人入行面试需要,还适用于想提升进阶跳槽加薪的运维朋友。

本份面试集锦涵盖了

  • 174 道运维工程师面试题
  • 128道k8s面试题
  • 108道shell脚本面试题
  • 200道Linux面试题
  • 51道docker面试题
  • 35道Jenkis面试题
  • 78道MongoDB面试题
  • 17道ansible面试题
  • 60道dubbo面试题
  • 53道kafka面试
  • 18道mysql面试题
  • 40道nginx面试题
  • 77道redis面试题
  • 28道zookeeper

总计 1000+ 道面试题, 内容 又全含金量又高

  • 174道运维工程师面试题

1、什么是运维?

2、在工作中,运维人员经常需要跟运营人员打交道,请问运营人员是做什么工作的?

3、现在给你三百台服务器,你怎么对他们进行管理?

4、简述raid0 raid1raid5二种工作模式的工作原理及特点

5、LVS、Nginx、HAproxy有什么区别?工作中你怎么选择?

6、Squid、Varinsh和Nginx有什么区别,工作中你怎么选择?

7、Tomcat和Resin有什么区别,工作中你怎么选择?

8、什么是中间件?什么是jdk?

9、讲述一下Tomcat8005、8009、8080三个端口的含义?

10、什么叫CDN?

11、什么叫网站灰度发布?

12、简述DNS进行域名解析的过程?

13、RabbitMQ是什么东西?

14、讲一下Keepalived的工作原理?

15、讲述一下LVS三种模式的工作过程?

16、mysql的innodb如何定位锁问题,mysql如何减少主从复制延迟?

17、如何重置mysql root密码?
详情docs.qq.com/doc/DSmdCdUNwcEJDTXFK
度发布?

12、简述DNS进行域名解析的过程?

13、RabbitMQ是什么东西?

14、讲一下Keepalived的工作原理?

15、讲述一下LVS三种模式的工作过程?

16、mysql的innodb如何定位锁问题,mysql如何减少主从复制延迟?

17、如何重置mysql root密码?
详情docs.qq.com/doc/DSmdCdUNwcEJDTXFK

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值