SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
David Chang

秘銀科技
@chechiachang
Location
從零開始的⼈人臉辨識
七⿓龍珠戰⾾鬥⼒力力探測器器
David Chang
專⻑⾧長是後端⼯工程,容器器化技術,Kubernetes 管
理理,雲平台維運
Golang Taipei Meetup
SDN x Cloud Native Meetup
DevOps@秘銀科技
David Chang
我的專⻑⾧長沒有⼈人臉辨識,但我今天要來來講⼈人臉
辨識XD
因為不不會,所以真的是帶⼤大家從零開始,不不開
玩笑
DevOps@秘銀科技
從零開始的⼈人臉辨識
七⿓龍珠戰⾾鬥⼒力力探測器器
Location
⼯工程師的戰⾾鬥⼒力力就
是 contributions !!
⼿手機拍臉 ⼈人臉辨識 Github
回傳
Contrib.
User Story
身為⼀一個使⽤用者,我想使⽤用⼿手機鏡頭拍⼈人臉,讓⼿手機顯示
畫⾯面中⼈人物的 Github contribution
Let’s Live Demo!
⼿手機端做的事情
1. 把『畫⾯面』傳回後端 API Server
2. 顯示 API 回傳的數數值
3. 做⼀一點有點酷的特效
WebCam
後端做的事情
1. 從⼿手機端收到『畫⾯面』
2. ⽤用『畫⾯面』作⼈人臉辨識,取得使⽤用者ID
3. ⽤用 ID 取得 contributions,就是綠綠的
4. 把數數據回傳
Face recognition
⼿手機拍臉 ⼈人臉辨識 Github
回傳
Contrib.
基本架構
User Story 的基本流程
⼈人臉辨識 Github
取得 Github 的使⽤用者資料料
從零開始的 Data Mining
Github API
1. 搜尋台灣的使⽤用者
2. 取得每⼀一個使⽤用者頭像
3. 批次取得使⽤用者數數據

https://github.com/
search?q=location:Taiwan+type:user
https://developer.github.com/v3/
https://github.com/search

?q=location:Taiwan+type:user
https://api.github.com/search/users

?q=type:user+location:taiwan
&sort=follower&order=asc
Go-Github
https://github.com/google/go-github
完整的⽀支援 Github API
使⽤用簡易易
import (
“github.com/google/go-github/github"
"golang.org/x/oauth2"
)
func main() {
ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: "... your access token ..."},
)
tc := oauth2.NewClient(ctx, ts)
client := github.NewClient(tc)
// list all repositories for the authenticated user
repos, _, err := client.Repositories.List(ctx, "", nil)
}
// https://developer.github.com/v3/search/#search-users
func SearchGithubUsers(tc *http.Client, page int, query, sort, order
string) (*github.UsersSearchResult, error) {
client := github.NewClient(tc)
opt := &github.SearchOptions{
Sort: sort,
Order: order,
TextMatch: false,
ListOptions: github.ListOptions{
Page: page,
PerPage: SearchMaxPerPage,
},
}
result, resp, err := client.Search.Users(context.Background(), query,
opt)
return result, err
}
Github API Limitation
1. Paging

Search API return first 1000 users only

2. Rate Limit

Search API < 30 q/min

User API < 5,000 q/hr
https://developer.github.com/v3/
Github API Limitation
1. Batch

https://api.github.com/search/users

?q=location:taiwan

+created:2008-01-01..2008-02-01
2. Rate Control

go routine

wait group

runtime.GOMAXPROCS()
https://developer.github.com/v3/
⼈人臉辨識 Github
從原始資料料到⼈人臉辨識
把10000使⽤用者頭像『編碼』(encoding),產⽣生

頭像 -> ID 的⼀一對⼀一映射
David Chang
100 contributions@2018
⼈人臉辨識 API
https://github.com/ageitgey/face_recognition
The world's simplest facial recognition api. No kidding :P
Face Detection 圖 -> 臉
Face Recognition 臉 -> ID
Location
已知圖⽚片 API 矩陣
回傳
Contrib.
Face Recognition
把已知圖⽚片輸⼊入,使⽤用 API 取得特徵值

[特徵值 -> 使⽤用者ID] 的映射,放到⼀一個矩陣
David Chang 的 User ID
未知圖⽚片 API 矩陣
回傳
Contrib.
Face Recognition
把未知圖⽚片輸⼊入,使⽤用 API 取得特徵值

把未知的特徵值,放到剛剛的矩陣,⽐比對,找到最近的⼀一張圖
???
回傳
距離 David Chang 的圖⽚片距離最短
import face_recognition
import pickle
all_face_encodings = {}
img1 = face_recognition.load_image_file("david.jpg")
all_face_encodings["david"] =
face_recognition.face_encodings(david_img1)[0]
img2 = face_recognition.load_image_file("chang.jpg")
all_face_encodings["chang"] =
face_recognition.face_encodings(chang_img2)[0]
with open('dataset_faces.dat', 'wb') as f:
pickle.dump(all_face_encodings, f)
import face_recognition
import pickle
import numpy as np
# Load face encodings. read binary
with open('dataset_faces.dat', 'rb') as f:
all_face_encodings = pickle.load(f)
# Grab the list of names and the list of encodings
face_names = list(all_face_encodings.keys())
face_encodings = np.array(list(all_face_encodings.values()))
# Try comparing an unknown image
unknown_img = face_recognition.load_image_file("unknown.jpg")
unknown_face = face_recognition.face_encodings(unknown_img)
result = face_recognition.compare_faces(face_encodings, unknown_face)

[('david', True), (‘chang', False)]
⼿手機拍臉 ⼈人臉辨識
⼿手機端實作
取得 Iphone 上的 WebCam,取得影像,發 API 到後端
Unity
1. 當初選⽤用的原因是覺得好像可以做出很炫的
東⻄西
2. ⽀支援 OpenCV,做⼿手機端的 Face Detection
使⽤用圖形介⾯面與C#實作前端
前端的效能負荷取捨
1. 視訊串串流
2. 螢幕截圖影像
3. 偵測到的⼈人臉部分影像
4. 客⼾戶端 Face recognition encoding,只傳特
徵值
傳送到後端的介⾯面其實有蠻多選擇
實作
1. ⼿手機端使⽤用 OpenCV 做影像處理理
2. 整合 dlib 使⽤用現成的 cnn based model 做
Face Detection
3. 傳送⼈人臉部分影像⾄至後端
4. 後端進⾏行行 encoding,並⽐比較其他 encodings
在⾼高維陣列列中的距離
效能與調適
1. 前端處理理 OpenCV 繪圖,iPhone 6 > 20
fps

2. 瓶頸在後端 API

圖⽚片送到後端 -> encoding -> ⽐比對距離

-> 送回前端

3. 前端等後端 Skip frame / Skip API request
~= 10 fps
⼿手機拍臉 ⼈人臉辨識 Github
回傳
Contrib.
⼩小結⼀一下
Issue
1. 最根本的原因,⼤大家的 Github 頭像都是

像素圖跟⼩小動物,或是不不看正⾯面的⽂文⻘青照
2. 使⽤用的 Model 是使⽤用⻄西⽅方⽩白⼈人臉訓練,認亞
洲⼈人失準

3. 使⽤用⾼高清的圖⽚片,幾百⼈人也有 80% 的準確
其實根本認錯⼈人
要做⼈人臉辨識,先拿到夠好的圖⽚片
做這個專案的動機
從零開始的⼼心路路歷歷程
Location
從 DevOps 到⼈人臉辨識
1. 嘗試做⾃自⼰己專業以外的領域,是⼀一場愛與勇
氣的探險

2. Side project 讓⼈人重拾拾軟體⼯工程的熱愛
3. 這個專案技術⾨門檻低,沒有跨不不過去的坎



4. 有作品,⾯面試很好⽤用
斜槓⼯工程師槓起來來
Conferences & Meetups
1. 這個專案是為了了 COSCUP 2018 Aug. 做的 

2. ⼀一個⽉月從零開始的⼈人臉辨識
3. 我想分享的是⼀一個越級打怪,⼀一邊快速成⻑⾧長
的捷徑
上台演講,⾃自⼰己的收穫最多
Golang Taipei
來來 Meetup 報名講者吧~
GolangTaipei@Facebook
David Chang, 秘銀科技
@chechiachang
Location
Thank you!
Q&A
This is a Sub-head
Location

Weitere ähnliche Inhalte

Ähnlich wie Gdg devfest-2018

Mobile App 高保真原型设计
Mobile App 高保真原型设计 Mobile App 高保真原型设计
Mobile App 高保真原型设计 hehewish
 
容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中Andrew Wu
 
使用OpenCV 進行人臉辨識
使用OpenCV進行人臉辨識使用OpenCV進行人臉辨識
使用OpenCV 進行人臉辨識Yanwei Liu
 
Android Studio & Cloud Vision API 玩圖像辨識
Android Studio & Cloud Vision API 玩圖像辨識Android Studio & Cloud Vision API 玩圖像辨識
Android Studio & Cloud Vision API 玩圖像辨識政斌 楊
 
摩登開發團隊的DevOps之道 (@DevOpsTaiwan)
摩登開發團隊的DevOps之道 (@DevOpsTaiwan)摩登開發團隊的DevOps之道 (@DevOpsTaiwan)
摩登開發團隊的DevOps之道 (@DevOpsTaiwan)Chen Cheng-Wei
 
Kinect 2.0 Programming (4)
Kinect 2.0 Programming (4)Kinect 2.0 Programming (4)
Kinect 2.0 Programming (4)IngChyuan Wu
 
Kinect 2.0 Programming (2)
Kinect 2.0 Programming (2)Kinect 2.0 Programming (2)
Kinect 2.0 Programming (2)IngChyuan Wu
 
基于Android ndk的软件开发简介 放映
基于Android ndk的软件开发简介 放映基于Android ndk的软件开发简介 放映
基于Android ndk的软件开发简介 放映heyfluke
 
基于Android ndk的软件开发简介 放映
基于Android ndk的软件开发简介 放映基于Android ndk的软件开发简介 放映
基于Android ndk的软件开发简介 放映heyfluke
 
移动互联网时代的Mobile app设计和开发
移动互联网时代的Mobile app设计和开发移动互联网时代的Mobile app设计和开发
移动互联网时代的Mobile app设计和开发fangdeng
 
A dev ops team's practice in trend micro in agile summit 2018
A dev ops team's practice in trend micro in agile summit 2018A dev ops team's practice in trend micro in agile summit 2018
A dev ops team's practice in trend micro in agile summit 2018Juggernaut Liu
 
[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台
[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台
[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台Shengyou Fan
 
Kinect 2.0 Programming (1)
Kinect 2.0 Programming (1)Kinect 2.0 Programming (1)
Kinect 2.0 Programming (1)IngChyuan Wu
 
Processing Tutorial - Create your interactive program in a click~
Processing Tutorial - Create your interactive program in a click~Processing Tutorial - Create your interactive program in a click~
Processing Tutorial - Create your interactive program in a click~CAVEDU Education
 
Web view on the way
Web view on the wayWeb view on the way
Web view on the wayLiddle Fang
 
极速 Angular 开发:效能调校技巧 (ngChina 2019)
极速 Angular 开发:效能调校技巧 (ngChina 2019)极速 Angular 开发:效能调校技巧 (ngChina 2019)
极速 Angular 开发:效能调校技巧 (ngChina 2019)Will Huang
 
Is it really easy for companies to import Ansible automation
Is it really easy for companies to import Ansible automationIs it really easy for companies to import Ansible automation
Is it really easy for companies to import Ansible automationChu-Siang Lai
 
ASP.NET Core 2.1設計新思維與新發展
ASP.NET  Core 2.1設計新思維與新發展ASP.NET  Core 2.1設計新思維與新發展
ASP.NET Core 2.1設計新思維與新發展江華 奚
 
20110821 Web Development on Cloud Platform - PIXNET
20110821 Web Development on Cloud Platform - PIXNET20110821 Web Development on Cloud Platform - PIXNET
20110821 Web Development on Cloud Platform - PIXNETJui-Nan Lin
 

Ähnlich wie Gdg devfest-2018 (20)

Mobile App 高保真原型设计
Mobile App 高保真原型设计 Mobile App 高保真原型设计
Mobile App 高保真原型设计
 
容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中容器驅動開發 - .NET Conf 2017 @ 台中
容器驅動開發 - .NET Conf 2017 @ 台中
 
使用OpenCV 進行人臉辨識
使用OpenCV進行人臉辨識使用OpenCV進行人臉辨識
使用OpenCV 進行人臉辨識
 
Android Studio & Cloud Vision API 玩圖像辨識
Android Studio & Cloud Vision API 玩圖像辨識Android Studio & Cloud Vision API 玩圖像辨識
Android Studio & Cloud Vision API 玩圖像辨識
 
摩登開發團隊的DevOps之道 (@DevOpsTaiwan)
摩登開發團隊的DevOps之道 (@DevOpsTaiwan)摩登開發團隊的DevOps之道 (@DevOpsTaiwan)
摩登開發團隊的DevOps之道 (@DevOpsTaiwan)
 
Kinect 2.0 Programming (4)
Kinect 2.0 Programming (4)Kinect 2.0 Programming (4)
Kinect 2.0 Programming (4)
 
Kinect 2.0 Programming (2)
Kinect 2.0 Programming (2)Kinect 2.0 Programming (2)
Kinect 2.0 Programming (2)
 
基于Android ndk的软件开发简介 放映
基于Android ndk的软件开发简介 放映基于Android ndk的软件开发简介 放映
基于Android ndk的软件开发简介 放映
 
基于Android ndk的软件开发简介 放映
基于Android ndk的软件开发简介 放映基于Android ndk的软件开发简介 放映
基于Android ndk的软件开发简介 放映
 
移动互联网时代的Mobile app设计和开发
移动互联网时代的Mobile app设计和开发移动互联网时代的Mobile app设计和开发
移动互联网时代的Mobile app设计和开发
 
A dev ops team's practice in trend micro in agile summit 2018
A dev ops team's practice in trend micro in agile summit 2018A dev ops team's practice in trend micro in agile summit 2018
A dev ops team's practice in trend micro in agile summit 2018
 
[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台
[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台
[MOPCON 2022] 以 Kotlin Multiplatform 制霸全平台
 
Kinect 2.0 Programming (1)
Kinect 2.0 Programming (1)Kinect 2.0 Programming (1)
Kinect 2.0 Programming (1)
 
Processing Tutorial - Create your interactive program in a click~
Processing Tutorial - Create your interactive program in a click~Processing Tutorial - Create your interactive program in a click~
Processing Tutorial - Create your interactive program in a click~
 
Web view on the way
Web view on the wayWeb view on the way
Web view on the way
 
极速 Angular 开发:效能调校技巧 (ngChina 2019)
极速 Angular 开发:效能调校技巧 (ngChina 2019)极速 Angular 开发:效能调校技巧 (ngChina 2019)
极速 Angular 开发:效能调校技巧 (ngChina 2019)
 
2021laravelconftwslides10
2021laravelconftwslides102021laravelconftwslides10
2021laravelconftwslides10
 
Is it really easy for companies to import Ansible automation
Is it really easy for companies to import Ansible automationIs it really easy for companies to import Ansible automation
Is it really easy for companies to import Ansible automation
 
ASP.NET Core 2.1設計新思維與新發展
ASP.NET  Core 2.1設計新思維與新發展ASP.NET  Core 2.1設計新思維與新發展
ASP.NET Core 2.1設計新思維與新發展
 
20110821 Web Development on Cloud Platform - PIXNET
20110821 Web Development on Cloud Platform - PIXNET20110821 Web Development on Cloud Platform - PIXNET
20110821 Web Development on Cloud Platform - PIXNET
 

Mehr von Che-Chia Chang

COSCUP Scouter: Face recognizer retrieves your Github contribution
COSCUP Scouter: Face recognizer retrieves your Github contributionCOSCUP Scouter: Face recognizer retrieves your Github contribution
COSCUP Scouter: Face recognizer retrieves your Github contributionChe-Chia Chang
 
Intro to go web assembly
Intro to go web assemblyIntro to go web assembly
Intro to go web assemblyChe-Chia Chang
 
Elk for applications on k8s
Elk for applications on k8sElk for applications on k8s
Elk for applications on k8sChe-Chia Chang
 
Automated container-deployment-on-kubernetes
Automated container-deployment-on-kubernetesAutomated container-deployment-on-kubernetes
Automated container-deployment-on-kubernetesChe-Chia Chang
 
Deploy High Availability Kubernetes with Kubespray
Deploy High Availability Kubernetes with KubesprayDeploy High Availability Kubernetes with Kubespray
Deploy High Availability Kubernetes with KubesprayChe-Chia Chang
 
K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210Che-Chia Chang
 

Mehr von Che-Chia Chang (8)

COSCUP Scouter: Face recognizer retrieves your Github contribution
COSCUP Scouter: Face recognizer retrieves your Github contributionCOSCUP Scouter: Face recognizer retrieves your Github contribution
COSCUP Scouter: Face recognizer retrieves your Github contribution
 
Intro to go web assembly
Intro to go web assemblyIntro to go web assembly
Intro to go web assembly
 
Elk for applications on k8s
Elk for applications on k8sElk for applications on k8s
Elk for applications on k8s
 
CRI, OCI, and CRI-O
CRI, OCI, and CRI-OCRI, OCI, and CRI-O
CRI, OCI, and CRI-O
 
Kubernetes networks
Kubernetes networksKubernetes networks
Kubernetes networks
 
Automated container-deployment-on-kubernetes
Automated container-deployment-on-kubernetesAutomated container-deployment-on-kubernetes
Automated container-deployment-on-kubernetes
 
Deploy High Availability Kubernetes with Kubespray
Deploy High Availability Kubernetes with KubesprayDeploy High Availability Kubernetes with Kubespray
Deploy High Availability Kubernetes with Kubespray
 
K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210K8s storage-glusterfs-20180210
K8s storage-glusterfs-20180210
 

Gdg devfest-2018