728x90
728x90
Microsoft Azure Cognitive Services의 Computer Vision을 이용하여 이미지 분석(Image Analysis) 하기
[Microsoft Azure Cognitive Services] Computer Vision
- Microsoft Azure Cognitive Services의 서비스 중 하나로, 컴퓨터 비전(Computer Vision) 관련 작업을 수행할 수 있다.
Computer Vision | Microsoft Azure
Azure Cognitive Service인 Computer Vision으로 이미지에서 풍부한 정보를 추출하고 콘텐츠를 분석합니다.
azure.microsoft.com
Azure Cognitive Services 란?
- AI를 활용하여 다양한 기능을 구현할 때, Microsoft에 의해 미리 구현된 여러가지 기능들을 API를 이용하여 불러올 수 있는 서비스이다.
Cognitive Services - AI 솔루션용 API | Microsoft Azure
Azure Cognitive Services는 기계 학습 전문 지식이 필요하지 않은 API를 통해 개발자에게 AI를 제공합니다. 30일 만에 AI 솔루션을 빌드하는 방법을 알아보세요.
azure.microsoft.com
방법
① Microsoft Azure에서 키 값과 엔드포인트 값 긁어오기

② 코드 작성하기
- ✅ 표시된 부분에 자신의 ①분석할 이미지, ②키 값, ③엔드포인트 값을 넣어준다.
import requests from io import BytesIO from PIL import Image # 분석할 이미지를 불러온다. image_url = '_______________' # ✅ 분석할 이미지의 주소를 넣는다. image = Image.open(BytesIO(requests.get(image_url).content)) image # 불러온 이미지를 출력한다. # 필요한 값들을 준비한다. key = '________________' # ✅ Azure의 키 값을 넣는다. endpoint = '______________' # ✅ Azure의 엔드포인트 값을 넣는다. # 컴퓨터 비전 2.0 버전을 사용할 것이기 때문에 endpoint 뒤에 붙여준다. endpoint += 'vision/v2.0/' # endpoint로 이미지 분석과, 이미지 감지 작업을 할 수 있다. analyze_endpoint = endpoint + 'analyze' # 분석을 위해 끝에 analyze 붙인다. # 웹 통신할 때는 header, parameter, data 3가지가 필요하다. header = { 'Ocp-Apim-Subscription-Key' : key } params = { 'visualFeatures' : 'Categories,Description,Color' } data = { 'url' : image_url } # 외부로 요청하기 (클라우드에서 분석 후, 분석값을 가져온다.) response = requests.post(analyze_endpoint, headers=header, params=params, json=data) # 분석 결과 확인하기 result = response.json() result # JSON으로 결과를 출력시킨다.
실행 결과



728x90
728x90
'DevOps > Azure' 카테고리의 다른 글
[Azure] 비주얼 스튜디오 코드(VS Code)와 애저(Azure) 연동하기 (0) | 2023.05.19 |
---|---|
[Azure] 애저(Azure) 테넌트(Tenant) ID 찾는 방법 (0) | 2023.05.18 |
[Azure] 스토리지 계정(Storage Account) Blob Service/File Service/Queue Service 연동 및 실습 (0) | 2023.05.15 |
[Azure] Microsoft Azure 공부 내용 정리 📝 (0) | 2023.05.09 |
[Azure] 윈도우(Windows) VM 배포/연결 (0) | 2023.05.09 |
[Azure] 리눅스 VM 배포/연결 및 실습 (0) | 2023.05.08 |
[Azure] GPT(Generative Pre-trained Transformer) (0) | 2023.05.05 |
[Azure] Azure Friday (0) | 2023.05.05 |