简体   繁体   English

使用 Azure 和 Juypter Notebook 进行面部识别

[英]Facial recognition with Azure and Juypter Notebook

Please could someone help?请问有人可以帮忙吗? I have scoured the web and obviously Stackoverflow and yet i am still getting bugs that look simple to solve but are actually not (for me anyway) i am pretty new with python working on code tutorials and not really learning much until I've started trying to create projects like this.我已经浏览了网络,显然是 Stackoverflow,但我仍然遇到看起来很容易解决但实际上不是(无论如何对我来说)的错误创建这样的项目。 Please excuse my comments!:)请原谅我的评论!:)

%matplotlib inline
from matplotlib.pyplot import imshow
from PIL import Image
import requests
from io import BytesIO

import numpy as np 
import imageio
import matplotlib.pyplot as plt
from PIL import Image

im1 = imageio.imread('DM.jpg') #Read the image from the desktop
# print(im1.shape) #Returns the number of rows, columns and channels (if image is colour returns "3")

#plt.imshow(im1)
#plt.show() !!!This works.Take away the hash tag and it will show the image!!!

#New script to try a face recognition
faceURI = "https://*****************azure.com/"
faceKey = "*********************"

import cognitive_face as CF

# Set URI and Key
CF.BaseUrl.set(faceURI)
CF.Key.set(faceKey)

# Detect faces in an image
img_url = 'DM.jpg'
result = CF.face.detect(img_url)
print (result)

So i now believe where i am going wrong?所以我现在相信我哪里出错了? The part where it has in code about the end point and the key should not be there but be in a bash file.它在关于终点和密钥的代码中的部分不应该在那里,而应该在一个 bash 文件中。 Now that's where i'm having trouble now!这就是我现在遇到麻烦的地方! haha (it doesnt rain but pours!).哈哈(不下雨而是倾盆大雨!)。 i am trying to use vim however this is something new and now i'm struggling with that *facepalms myself我正在尝试使用 vim,但是这是新的东西,现在我自己也在努力解决 *facepalms

Although I am not quite sure about the exact ask on the piece of code you shared, but I would suggest you to go through the official examples below for end to end guide and then try to run/debug those code examples on your local machine.虽然我不太确定您共享的代码片段的确切要求,但我建议您阅读下面的官方示例以获取端到端指南,然后尝试在您的本地机器上运行/调试这些代码示例。 (One way to learn something new is to play with lot of examples of others' code :)) (学习新东西的一种方法是玩很多其他人的代码示例:))

Quickstart: Use the Face client library 快速入门:使用人脸客户端库

Quickstart: Detect faces in an image using the Face REST API and Python 快速入门:使用 Face REST API 和 Python 检测图像中的人脸

Update: Coming back to your code and follow up clarification on the ask.更新:回到您的代码并跟进询问的澄清。 I see a problem where you are trying use the cognitive face SDK.我发现您尝试使用认知人脸 SDK 时出现问题。 I don't see you creating the FaceClient object in your code!我没有看到您在代码中创建 FaceClient 对象! Something like: face_client = FaceClient(ENDPOINT, CognitiveServicesCredentials(KEY))类似于: face_client = FaceClient(ENDPOINT, CognitiveServicesCredentials(KEY))

(I'd post this as a comment, but SO says I don't have enough reputation to do so). (我会将此作为评论发布,但 SO 说我没有足够的声誉这样做)。

Hi Towvis,嗨托维斯,

Happy to help!乐于帮助! Can you include where you're running into trouble?你能包括你遇到麻烦的地方吗? What kind of errors you're getting?你得到什么样的错误? Also can you confirm that you're using the azure-cognitiveservices-vision-face package in your code snippet?您还可以确认您在代码片段中使用了 azure-cognitiveservices-vision-face 包吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM