1

请问有人可以帮忙吗?我已经搜索了网络,显然是 Stackoverflow,但我仍然遇到看起来很容易解决但实际上不是(无论如何对我来说)的错误创建这样的项目。请原谅我的评论!:)

%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)

所以我现在相信我哪里出错了?它在代码中关于端点和密钥的部分不应该在那里,而是在 bash 文件中。现在这就是我现在遇到麻烦的地方!哈哈(不下雨但倾盆大雨!)。我正在尝试使用 vim,但这是新事物,现在我自己也在努力解决 *facepalms

4

1 回答 1

1

尽管我不太确定您共享的代码段的确切要求,但我建议您阅读下面的官方示例以获取端到端指南,然后尝试在本地计算机上运行/调试这些代码示例。(学习新东西的一种方法是玩很多其他人的代码示例:))

快速入门:使用人脸客户端库

快速入门:使用人脸 REST API 和 Python 检测图像中的人脸

更新:回到您的代码并跟进询问的说明。我看到您尝试使用认知面部 SDK 的问题。我没有看到您在代码中创建 FaceClient 对象!类似于:face_client = FaceClient(ENDPOINT, CognitiveServicesCredentials(KEY))

于 2020-08-28T16:08:58.823 回答