SlideShare a Scribd company logo
1 of 55
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
2018
김무현
Solutions Architect, AWS
AWS 머신러닝 서비스를 활용한
실시간 영상 및 이미지 분석
강연 중 질문하는 방법
자신이 질문한 내역이 표시되며,
전체 공개로 답변된 내용은 검은색,
질문자 본인에게만 공개로 답변된
내용은 붉은 색으로 돌아옵니다.
본 컨텐츠는 고객의 편의를 위해 AWS 서비스 설명을 위해 온라인 세미나용으로 별도로 제작, 제공된 것입니다. 만약
AWS 사이트와 컨텐츠 상에서 차이나 불일치가 있을 경우, AWS 사이트(aws.amazon.com)가 우선합니다. 또한 AWS
사이트 상에서 한글 번역문과 영어 원문에 차이나 불일치가 있을 경우(번역의 지체로 인한 경우 등 포함), 영어 원문이
우선합니다.
AWS는 본 컨텐츠에 포함되거나 컨텐츠를 통하여 고객에게 제공된 일체의 정보, 콘텐츠, 자료, 제품(소프트웨어 포함) 또는 서비스를 이용함으로 인하여 발생하는
여하한 종류의 손해에 대하여 어떠한 책임도 지지 아니하며, 이는 직접 손해, 간접 손해, 부수적 손해, 징벌적 손해 및 결과적 손해를 포함하되 이에 한정되지
아니합니다.
고지 사항(Disclaimer)
본 세션의 주요 주제
• 간단한 실시간 이미지 분석 예제
• Amazon Rekognition Image
• 디바이스에서 직접 분석하는 방법
• AWS Greengrass ML Inference
• AWS DeepLens
• 실시간 영상 활용 방법
• Amazon Kinesis Video Streams
• Amazon Rekognition Video
간단한 실시간 이미지 분석
간단한 실시간 이미지 분석 시나리오
• 카메라가 설치된 디바이스에서 카메라에 비춰진
이미지를 실시간으로 분석하고 그 결과를 활용하는 예제
Amazon
Rekognition
스마트 CCTV실시간 영상 분석 결과
분석 요청결과 스트리밍
카메라에서 영상 얻기
• OpenCV 라이브러리의 VideoCapture 클래스 활용
• 비디오 파일, 이미지 시퀀스 또는 카메라에서 비디오를 캡춰하는데 활용
import cv2
webcam = cv2.VideoCapture(0)
success, image = webcam.read()
Rekognition Image 서비스에 요청
• Amazon Rekognition의 객체 탐지 기능을 활용
• 이미지를 byte로 변환해서, DetectLabels API 호출
import boto3
Rekog = boto3.client(‘rekognition’)
h,w = image.shape[:2]
regImg = cv2.resize(image, (int(0.2*w), int(0.2*h)))
_, newjpeg = cv2.imencode('.jpg', regImg)
imgbytes = newjpeg.tobytes()
resp = rekog.detect_labels(Image={'Bytes':imgbytes})
Rekognition Image 서비스 응답
• Amazon Rekognition의 응답은 JSON 형태임
• 탐지된 객체들을 Labels 배열 형태로, 객체 이름과 확율값들이 리턴됨
{
'Labels’: [
{'Confidence': 98.9703369140625, 'Name': 'Human’},
{'Confidence': 98.9703140258789, 'Name': 'People’},
{'Confidence': 98.9703369140625, 'Name': 'Person’}
],
'ResponseMetadata’:
{'RequestId': '2531323b-2537-11e8-8d75-994d4bd0f8ee’,
'HTTPStatusCode': 200,
'HTTPHeaders’: { … },
'RetryAttempts’: 0
},
'OrientationCorrection': 'ROTATE_0’
}
분석 결과를 비디오 스트리밍으로 출력
• Flask (마이크로 웹 프레임워크)를 활용해서 웹 서비스 구성
• 분석 결과를 포함한 이미지를 MJPEG 형식으로 출력
from flask import Flask, render_template, Response
@app.route('/video_feed’)
def video_feed():
return Response(gen(VideoCamera()),mimetype='multipart/x-mixed-replace; boundary=frame')
데모
https://github.com/muhyun/rekognition-video-stream-server
디바이스에서 직접 분석하기
왜 디바이스에서 예측 수행이 필요할까요?
• 다음과 같은 제약이 있을 수 있습니다.
• 응답 속도
• 네트워크 연결성
• 규제
• 비용
• 이 경우, 클라우드 머신러닝 서비스를 이용한 예측이
아닌, 디바이스에서 직접 머신러닝 예측을 수행하는
것이 필요
디바이스에서 머신러닝 예측을 한다면 …
• 머신러닝 모델을 어떻게 배포할 것인가?
• 머신러닝 모델을 이용한 예측 프로그램을 어떻게 배포할
것인가?
• 머신 러닝 예측을 어떻게 수행할지?
• 예측 결과를 클라우드 서비스와 어떻게 연동할 것인가?
2가지 방법
AWS Greengrass
ML Inference
AWS DeepLens
AWS Greengrass Core
• AWS IoT 기능의 일부를 로컬에서 수행할 수 있도록
해주는 소프트웨어
Greengrass ML Inference
• 머신 러닝 모델 및 예측 코드를 Greengrass Core
디바이스에 배포하고 수행하는 환경을 제공함
AWS Greengrass
콘솔에서 기기로 모델
배포
디바이스에서
모델 기반 예측
인터넷 비연결시에도
동작 가능
클라우드에서 모델
학습 및 훈련
배포할 모델 및 Lambda 함수
• 머신러닝 모델: SqueezeNet
• AlexNet 수준의 정확도
• 50배 정도 적은 파라메터 및 작은 모델 크기 (0.5MB 이하)
• https://arxiv.org/abs/1602.07360
• Lambda 함수
• Python 2.7, Apache MXNet 0.11.0
• 카메라 접근을 위한 로컬 리소스 추가
Greengrass : Lambda
Greengrass : Lambda 설정
Greengrass : Lambda 로컬 리소스
카메라 접근을 위한
Local Resource들
머신러닝 모델
Greengrass Core 디바이스로 배포
Lambda 함수를 살펴보면 …
객체 탐지를 위한 머신러닝 모델을 로딩
카메라 이미지에 대한 객체 탐지 예측 수행
객체 탐지 결과를 AWS IoT Cloud로 전송
3초 후, 탐지 함수 재호출
머신러닝 모델 로딩 코드
머신러닝 모델 네트워크 정의 (sym) 및
파라메터 (arg_params, aux_params) 로딩
로딩된 값들을 이용해서 MXNet Module 생성
카메라에서 이미지 획득 코드
def predict_from_webcam(self, capfile='cap.jpg', reshape=(224, 224), N=5):
cv2.VideoCapture(0)
vidcap=cv2.VideoCapture(0)
vidcap.open(0)
#sleep(1)
retval, image = vidcap.read()
vidcap.release()
return self.predict_from_image(image, reshape, N)
머신러닝 예측 수행 코드
def predict_from_image(self, cvimage, reshape=(224, 224), N=5):
topN = []
# Switch RGB to BGR format (which ImageNet networks take)
img = cv2.cvtColor(cvimage, cv2.COLOR_BGR2RGB)
if img is None:
return topN
# Resize image to fit network input
img = cv2.resize(img, reshape)
img = np.swapaxes(img, 0, 2)
img = np.swapaxes(img, 1, 2)
img = img[np.newaxis, :]
# Run forward on the image
self.mod.forward(Batch([mx.nd.array(img)]))
prob = self.mod.get_outputs()[0].asnumpy()
prob = np.squeeze(prob)
# Extract the top N predictions from the softmax output
a = np.argsort(prob)[::-1]
for i in a[0:N]:
topN.append((prob[i], self.synsets[i]))
return topN
이미지에 대한 예측 수행
탐지된 객체 상위 N 개 추출
Greengrass 예측 수행 데모 – Lambda 로그
Greengrass 예측 수행 데모 – IoT 메시지
’hello/world’ IoT 토픽으로 전송된
이미지에 대한 예측 수행 결과
AWS DeepLens Community Project
https://aws.amazon.com/deeplens/community-projects/
DeepLens Project 정의
DeepLens 샘플 모델 – 객체 분류 모델
모델을 로딩하고, 예측을 수행할 Lambda 함수
DeepLens Project 배포
DeepLens Project – 대상 디바이스 선택
DeepLens Project – 배포 리뷰
DeepLens Project – 배포 수행
DeepLens Dee 수행
실시간 영상 분석 방법
이미지 기반의 실시간 영상 분석 솔루션 구성
https://github.com/aws-samples/amazon-rekognition-video-analyzer
어떤 개선이 필요할까요?
• 카메라 디바이스가 여러가지 종류라면?
• 프레임 단위가 아닌 영상으로 저장하고 싶다면?
• 이미지 기반으로 할 수 없는 예측은?
영상 스트림 입수 및 분석을 위한 서비스
실시간 비디오 스트림
Amazon Kinesis Video Streams
딥러닝 기반 영상 분석
Amazon Rekognition Video
활용 예 – 실시간 위험 인물 탐지
Kinesis Video Streams – 구성 요소
• Producer
• Kinesis Video Streams Producer 라이브러리 활용
• 비디오 및 다른 데이터(오디오, 이미지, RADAR)를
Kinesis Video Streams로 보내는 역할
• C++, Java, Android
• Consumer
• Kinesis Video Streams Parser 라이브러리 사용
• 데이터를 읽고, 처리하고, 분석하는 역할을 하는
Kinesis Video Streams 어플리케이션
• Java
Amazon Rekognition Video 기능
객체 및 행동 탐지 사람 추적 얼굴 인식 실시간 라이브
스트림
안전하지 않은
비디오 탐지
유명인 인식
실시간 인물 검색을 구성해보면 …
Consumer
Producer
Kinesis Video Streams 생성하기
Kinesis Video Streams 생성하기 - 설정
Raspberry Pi를 Producer로 만들기
• Amazon Kinesis Video Streams Raspberry Pi 가이드
• https://aws.amazon.com/kinesis/video-streams/raspberry-pi-
tutorial/
• Step-by-Step 가이드 (AWS re:Invent 2017)
• http://amzn.to/video-streams-workshop
• https://www.slideshare.net/AmazonWebServices/new-launch-
stream-video-from-edge-devices-to-aws-for-playback-storage-
and-processing-using-amazon-kinesis-video-streams-abd340-
reinvent-2017
Producer 시작 및 스트리밍 확인
$ AWS_ACCESS_KEY_ID=<your aws_access_key_id> AWS_SECRET_ACCESS_KEY=<your
aws_secret_access_key> ./kinesis_video_gstreamer_sample_app <stream_name>
Rekognition Video 연결은 어떻게 …
• Kinesis Video Streams의 Consumer에서 다음 과정을
수행합니다.
1) Rekognition이 어떤 분석을 할지 정하는 StreamProcessorSetting
생성
2) 이 설정을 적용한 Stream Processor를 생성하고,
3) 원하는 시점에 Stream Processor를 시작, 중지, 삭제합니다.
• Rekognition Video 결과는, Kinesis Data Streams으로 전송
Consumer – Kinesis Video + Rekognition
얼굴 검색을 위한
StreamProcessorSettings 정의
Consumer – Kinesis Video + Rekognition
위에서 정의된 Processor 설정을
적용한, StreamProcessor 생성
Consumer – Kinesis Video + Rekognition
StreamProcessor 시작, 중지, 삭제
Kinesis Video Streams
Kinesis Data Stream 값 확인
참고 자료
• 실시간 영상 분석 및 스트리밍 웹 서비스
• https://github.com/muhyun/rekognition-video-stream-server
• Serverless Pipeline for Video Frame Analysis and Alerting
• https://github.com/aws-samples/amazon-rekognition-video-analyzer
• Amazon Kinesis Video Streams Producer
• https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp
• https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-java
• DeepLens Community Projects
• https://aws.amazon.com/deeplens/community-projects/
감사합니다
질문에 대한 답변 드립니다.
발표자료/녹화영상 제공합니다.
http://bit.ly/awskr-webinar
더 나은 세미나를 위해
여러분의 의견을 남겨 주세요!

More Related Content

More from Amazon Web Services Korea

Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...Amazon Web Services Korea
 
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...Amazon Web Services Korea
 
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...Amazon Web Services Korea
 
Amazon Redshift Deep Dive - Serverless, Streaming, ML, Auto Copy (New feature...
Amazon Redshift Deep Dive - Serverless, Streaming, ML, Auto Copy (New feature...Amazon Redshift Deep Dive - Serverless, Streaming, ML, Auto Copy (New feature...
Amazon Redshift Deep Dive - Serverless, Streaming, ML, Auto Copy (New feature...Amazon Web Services Korea
 
From Insights to Action, How to build and maintain a Data Driven Organization...
From Insights to Action, How to build and maintain a Data Driven Organization...From Insights to Action, How to build and maintain a Data Driven Organization...
From Insights to Action, How to build and maintain a Data Driven Organization...Amazon Web Services Korea
 
[Keynote] Accelerating Business Outcomes with AWS Data - 발표자: Saeed Gharadagh...
[Keynote] Accelerating Business Outcomes with AWS Data - 발표자: Saeed Gharadagh...[Keynote] Accelerating Business Outcomes with AWS Data - 발표자: Saeed Gharadagh...
[Keynote] Accelerating Business Outcomes with AWS Data - 발표자: Saeed Gharadagh...Amazon Web Services Korea
 
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...Amazon Web Services Korea
 
LG전자 - Amazon Aurora 및 RDS 블루/그린 배포를 이용한 데이터베이스 업그레이드 안정성 확보 - 발표자: 이은경 책임, L...
LG전자 - Amazon Aurora 및 RDS 블루/그린 배포를 이용한 데이터베이스 업그레이드 안정성 확보 - 발표자: 이은경 책임, L...LG전자 - Amazon Aurora 및 RDS 블루/그린 배포를 이용한 데이터베이스 업그레이드 안정성 확보 - 발표자: 이은경 책임, L...
LG전자 - Amazon Aurora 및 RDS 블루/그린 배포를 이용한 데이터베이스 업그레이드 안정성 확보 - 발표자: 이은경 책임, L...Amazon Web Services Korea
 
KB국민카드 - 클라우드 기반 분석 플랫폼 혁신 여정 - 발표자: 박창용 과장, 데이터전략본부, AI혁신부, KB카드│강병억, Soluti...
KB국민카드 - 클라우드 기반 분석 플랫폼 혁신 여정 - 발표자: 박창용 과장, 데이터전략본부, AI혁신부, KB카드│강병억, Soluti...KB국민카드 - 클라우드 기반 분석 플랫폼 혁신 여정 - 발표자: 박창용 과장, 데이터전략본부, AI혁신부, KB카드│강병억, Soluti...
KB국민카드 - 클라우드 기반 분석 플랫폼 혁신 여정 - 발표자: 박창용 과장, 데이터전략본부, AI혁신부, KB카드│강병억, Soluti...Amazon Web Services Korea
 
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...Amazon Web Services Korea
 
코리안리 - 데이터 분석 플랫폼 구축 여정, 그 시작과 과제 - 발표자: 김석기 그룹장, 데이터비즈니스센터, 메가존클라우드 ::: AWS ...
코리안리 - 데이터 분석 플랫폼 구축 여정, 그 시작과 과제 - 발표자: 김석기 그룹장, 데이터비즈니스센터, 메가존클라우드 ::: AWS ...코리안리 - 데이터 분석 플랫폼 구축 여정, 그 시작과 과제 - 발표자: 김석기 그룹장, 데이터비즈니스센터, 메가존클라우드 ::: AWS ...
코리안리 - 데이터 분석 플랫폼 구축 여정, 그 시작과 과제 - 발표자: 김석기 그룹장, 데이터비즈니스센터, 메가존클라우드 ::: AWS ...Amazon Web Services Korea
 
LG 이노텍 - Amazon Redshift Serverless를 활용한 데이터 분석 플랫폼 혁신 과정 - 발표자: 유재상 선임, LG이노...
LG 이노텍 - Amazon Redshift Serverless를 활용한 데이터 분석 플랫폼 혁신 과정 - 발표자: 유재상 선임, LG이노...LG 이노텍 - Amazon Redshift Serverless를 활용한 데이터 분석 플랫폼 혁신 과정 - 발표자: 유재상 선임, LG이노...
LG 이노텍 - Amazon Redshift Serverless를 활용한 데이터 분석 플랫폼 혁신 과정 - 발표자: 유재상 선임, LG이노...Amazon Web Services Korea
 
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...Amazon Web Services Korea
 
AWS Summit Seoul 2023 | Amazon Neptune 및 Elastic을 이용한 추천 서비스 및 검색 플랫폼 구축하기
AWS Summit Seoul 2023 | Amazon Neptune 및 Elastic을 이용한 추천 서비스 및 검색 플랫폼 구축하기AWS Summit Seoul 2023 | Amazon Neptune 및 Elastic을 이용한 추천 서비스 및 검색 플랫폼 구축하기
AWS Summit Seoul 2023 | Amazon Neptune 및 Elastic을 이용한 추천 서비스 및 검색 플랫폼 구축하기Amazon Web Services Korea
 
AWS Summit Seoul 2023 | 생성 AI 모델의 임베딩 벡터를 이용한 서버리스 추천 검색 구현하기
AWS Summit Seoul 2023 | 생성 AI 모델의 임베딩 벡터를 이용한 서버리스 추천 검색 구현하기AWS Summit Seoul 2023 | 생성 AI 모델의 임베딩 벡터를 이용한 서버리스 추천 검색 구현하기
AWS Summit Seoul 2023 | 생성 AI 모델의 임베딩 벡터를 이용한 서버리스 추천 검색 구현하기Amazon Web Services Korea
 
AWS Summit Seoul 2023 | 스타트업의 서버리스 기반 SaaS 데이터 처리 및 데이터웨어하우스 구축 사례
AWS Summit Seoul 2023 | 스타트업의 서버리스 기반 SaaS 데이터 처리 및 데이터웨어하우스 구축 사례AWS Summit Seoul 2023 | 스타트업의 서버리스 기반 SaaS 데이터 처리 및 데이터웨어하우스 구축 사례
AWS Summit Seoul 2023 | 스타트업의 서버리스 기반 SaaS 데이터 처리 및 데이터웨어하우스 구축 사례Amazon Web Services Korea
 
AWS Summit Seoul 2023 | Amazon EKS 데이터 전송 비용 절감 및 카오스 엔지니어링 적용 사례
AWS Summit Seoul 2023 | Amazon EKS 데이터 전송 비용 절감 및 카오스 엔지니어링 적용 사례AWS Summit Seoul 2023 | Amazon EKS 데이터 전송 비용 절감 및 카오스 엔지니어링 적용 사례
AWS Summit Seoul 2023 | Amazon EKS 데이터 전송 비용 절감 및 카오스 엔지니어링 적용 사례Amazon Web Services Korea
 
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기Amazon Web Services Korea
 
AWS Summit Seoul 2023 | 12가지 디자인 패턴으로 알아보는 클라우드 네이티브 마이크로서비스 아키텍처
AWS Summit Seoul 2023 | 12가지 디자인 패턴으로 알아보는 클라우드 네이티브 마이크로서비스 아키텍처AWS Summit Seoul 2023 | 12가지 디자인 패턴으로 알아보는 클라우드 네이티브 마이크로서비스 아키텍처
AWS Summit Seoul 2023 | 12가지 디자인 패턴으로 알아보는 클라우드 네이티브 마이크로서비스 아키텍처Amazon Web Services Korea
 
AWS Summit Seoul 2023 | AWS에서 OpenTelemetry 기반의 애플리케이션 Observability 구축/활용하기
AWS Summit Seoul 2023 | AWS에서 OpenTelemetry 기반의 애플리케이션 Observability 구축/활용하기AWS Summit Seoul 2023 | AWS에서 OpenTelemetry 기반의 애플리케이션 Observability 구축/활용하기
AWS Summit Seoul 2023 | AWS에서 OpenTelemetry 기반의 애플리케이션 Observability 구축/활용하기Amazon Web Services Korea
 

More from Amazon Web Services Korea (20)

Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
 
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
 
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...
 
Amazon Redshift Deep Dive - Serverless, Streaming, ML, Auto Copy (New feature...
Amazon Redshift Deep Dive - Serverless, Streaming, ML, Auto Copy (New feature...Amazon Redshift Deep Dive - Serverless, Streaming, ML, Auto Copy (New feature...
Amazon Redshift Deep Dive - Serverless, Streaming, ML, Auto Copy (New feature...
 
From Insights to Action, How to build and maintain a Data Driven Organization...
From Insights to Action, How to build and maintain a Data Driven Organization...From Insights to Action, How to build and maintain a Data Driven Organization...
From Insights to Action, How to build and maintain a Data Driven Organization...
 
[Keynote] Accelerating Business Outcomes with AWS Data - 발표자: Saeed Gharadagh...
[Keynote] Accelerating Business Outcomes with AWS Data - 발표자: Saeed Gharadagh...[Keynote] Accelerating Business Outcomes with AWS Data - 발표자: Saeed Gharadagh...
[Keynote] Accelerating Business Outcomes with AWS Data - 발표자: Saeed Gharadagh...
 
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...
Amazon DynamoDB - Use Cases and Cost Optimization - 발표자: 이혁, DynamoDB Special...
 
LG전자 - Amazon Aurora 및 RDS 블루/그린 배포를 이용한 데이터베이스 업그레이드 안정성 확보 - 발표자: 이은경 책임, L...
LG전자 - Amazon Aurora 및 RDS 블루/그린 배포를 이용한 데이터베이스 업그레이드 안정성 확보 - 발표자: 이은경 책임, L...LG전자 - Amazon Aurora 및 RDS 블루/그린 배포를 이용한 데이터베이스 업그레이드 안정성 확보 - 발표자: 이은경 책임, L...
LG전자 - Amazon Aurora 및 RDS 블루/그린 배포를 이용한 데이터베이스 업그레이드 안정성 확보 - 발표자: 이은경 책임, L...
 
KB국민카드 - 클라우드 기반 분석 플랫폼 혁신 여정 - 발표자: 박창용 과장, 데이터전략본부, AI혁신부, KB카드│강병억, Soluti...
KB국민카드 - 클라우드 기반 분석 플랫폼 혁신 여정 - 발표자: 박창용 과장, 데이터전략본부, AI혁신부, KB카드│강병억, Soluti...KB국민카드 - 클라우드 기반 분석 플랫폼 혁신 여정 - 발표자: 박창용 과장, 데이터전략본부, AI혁신부, KB카드│강병억, Soluti...
KB국민카드 - 클라우드 기반 분석 플랫폼 혁신 여정 - 발표자: 박창용 과장, 데이터전략본부, AI혁신부, KB카드│강병억, Soluti...
 
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
SK Telecom - 망관리 프로젝트 TANGO의 오픈소스 데이터베이스 전환 여정 - 발표자 : 박승전, Project Manager, ...
 
코리안리 - 데이터 분석 플랫폼 구축 여정, 그 시작과 과제 - 발표자: 김석기 그룹장, 데이터비즈니스센터, 메가존클라우드 ::: AWS ...
코리안리 - 데이터 분석 플랫폼 구축 여정, 그 시작과 과제 - 발표자: 김석기 그룹장, 데이터비즈니스센터, 메가존클라우드 ::: AWS ...코리안리 - 데이터 분석 플랫폼 구축 여정, 그 시작과 과제 - 발표자: 김석기 그룹장, 데이터비즈니스센터, 메가존클라우드 ::: AWS ...
코리안리 - 데이터 분석 플랫폼 구축 여정, 그 시작과 과제 - 발표자: 김석기 그룹장, 데이터비즈니스센터, 메가존클라우드 ::: AWS ...
 
LG 이노텍 - Amazon Redshift Serverless를 활용한 데이터 분석 플랫폼 혁신 과정 - 발표자: 유재상 선임, LG이노...
LG 이노텍 - Amazon Redshift Serverless를 활용한 데이터 분석 플랫폼 혁신 과정 - 발표자: 유재상 선임, LG이노...LG 이노텍 - Amazon Redshift Serverless를 활용한 데이터 분석 플랫폼 혁신 과정 - 발표자: 유재상 선임, LG이노...
LG 이노텍 - Amazon Redshift Serverless를 활용한 데이터 분석 플랫폼 혁신 과정 - 발표자: 유재상 선임, LG이노...
 
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
[Keynote] Data Driven Organizations with AWS Data - 발표자: Agnes Panosian, Head...
 
AWS Summit Seoul 2023 | Amazon Neptune 및 Elastic을 이용한 추천 서비스 및 검색 플랫폼 구축하기
AWS Summit Seoul 2023 | Amazon Neptune 및 Elastic을 이용한 추천 서비스 및 검색 플랫폼 구축하기AWS Summit Seoul 2023 | Amazon Neptune 및 Elastic을 이용한 추천 서비스 및 검색 플랫폼 구축하기
AWS Summit Seoul 2023 | Amazon Neptune 및 Elastic을 이용한 추천 서비스 및 검색 플랫폼 구축하기
 
AWS Summit Seoul 2023 | 생성 AI 모델의 임베딩 벡터를 이용한 서버리스 추천 검색 구현하기
AWS Summit Seoul 2023 | 생성 AI 모델의 임베딩 벡터를 이용한 서버리스 추천 검색 구현하기AWS Summit Seoul 2023 | 생성 AI 모델의 임베딩 벡터를 이용한 서버리스 추천 검색 구현하기
AWS Summit Seoul 2023 | 생성 AI 모델의 임베딩 벡터를 이용한 서버리스 추천 검색 구현하기
 
AWS Summit Seoul 2023 | 스타트업의 서버리스 기반 SaaS 데이터 처리 및 데이터웨어하우스 구축 사례
AWS Summit Seoul 2023 | 스타트업의 서버리스 기반 SaaS 데이터 처리 및 데이터웨어하우스 구축 사례AWS Summit Seoul 2023 | 스타트업의 서버리스 기반 SaaS 데이터 처리 및 데이터웨어하우스 구축 사례
AWS Summit Seoul 2023 | 스타트업의 서버리스 기반 SaaS 데이터 처리 및 데이터웨어하우스 구축 사례
 
AWS Summit Seoul 2023 | Amazon EKS 데이터 전송 비용 절감 및 카오스 엔지니어링 적용 사례
AWS Summit Seoul 2023 | Amazon EKS 데이터 전송 비용 절감 및 카오스 엔지니어링 적용 사례AWS Summit Seoul 2023 | Amazon EKS 데이터 전송 비용 절감 및 카오스 엔지니어링 적용 사례
AWS Summit Seoul 2023 | Amazon EKS 데이터 전송 비용 절감 및 카오스 엔지니어링 적용 사례
 
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
 
AWS Summit Seoul 2023 | 12가지 디자인 패턴으로 알아보는 클라우드 네이티브 마이크로서비스 아키텍처
AWS Summit Seoul 2023 | 12가지 디자인 패턴으로 알아보는 클라우드 네이티브 마이크로서비스 아키텍처AWS Summit Seoul 2023 | 12가지 디자인 패턴으로 알아보는 클라우드 네이티브 마이크로서비스 아키텍처
AWS Summit Seoul 2023 | 12가지 디자인 패턴으로 알아보는 클라우드 네이티브 마이크로서비스 아키텍처
 
AWS Summit Seoul 2023 | AWS에서 OpenTelemetry 기반의 애플리케이션 Observability 구축/활용하기
AWS Summit Seoul 2023 | AWS에서 OpenTelemetry 기반의 애플리케이션 Observability 구축/활용하기AWS Summit Seoul 2023 | AWS에서 OpenTelemetry 기반의 애플리케이션 Observability 구축/활용하기
AWS Summit Seoul 2023 | AWS에서 OpenTelemetry 기반의 애플리케이션 Observability 구축/활용하기
 

Recently uploaded

캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Kim Daeun
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Wonjun Hwang
 
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionKim Daeun
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Wonjun Hwang
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)Tae Young Lee
 

Recently uploaded (6)

캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)
 
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)
 

AWS 머신러닝 서비스를 활용한 실시간 이미지 분석 - 김무현 (AWS 솔루션즈 아키텍트)

  • 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2018 김무현 Solutions Architect, AWS AWS 머신러닝 서비스를 활용한 실시간 영상 및 이미지 분석
  • 2. 강연 중 질문하는 방법 자신이 질문한 내역이 표시되며, 전체 공개로 답변된 내용은 검은색, 질문자 본인에게만 공개로 답변된 내용은 붉은 색으로 돌아옵니다. 본 컨텐츠는 고객의 편의를 위해 AWS 서비스 설명을 위해 온라인 세미나용으로 별도로 제작, 제공된 것입니다. 만약 AWS 사이트와 컨텐츠 상에서 차이나 불일치가 있을 경우, AWS 사이트(aws.amazon.com)가 우선합니다. 또한 AWS 사이트 상에서 한글 번역문과 영어 원문에 차이나 불일치가 있을 경우(번역의 지체로 인한 경우 등 포함), 영어 원문이 우선합니다. AWS는 본 컨텐츠에 포함되거나 컨텐츠를 통하여 고객에게 제공된 일체의 정보, 콘텐츠, 자료, 제품(소프트웨어 포함) 또는 서비스를 이용함으로 인하여 발생하는 여하한 종류의 손해에 대하여 어떠한 책임도 지지 아니하며, 이는 직접 손해, 간접 손해, 부수적 손해, 징벌적 손해 및 결과적 손해를 포함하되 이에 한정되지 아니합니다. 고지 사항(Disclaimer)
  • 3. 본 세션의 주요 주제 • 간단한 실시간 이미지 분석 예제 • Amazon Rekognition Image • 디바이스에서 직접 분석하는 방법 • AWS Greengrass ML Inference • AWS DeepLens • 실시간 영상 활용 방법 • Amazon Kinesis Video Streams • Amazon Rekognition Video
  • 5. 간단한 실시간 이미지 분석 시나리오 • 카메라가 설치된 디바이스에서 카메라에 비춰진 이미지를 실시간으로 분석하고 그 결과를 활용하는 예제 Amazon Rekognition 스마트 CCTV실시간 영상 분석 결과 분석 요청결과 스트리밍
  • 6. 카메라에서 영상 얻기 • OpenCV 라이브러리의 VideoCapture 클래스 활용 • 비디오 파일, 이미지 시퀀스 또는 카메라에서 비디오를 캡춰하는데 활용 import cv2 webcam = cv2.VideoCapture(0) success, image = webcam.read()
  • 7. Rekognition Image 서비스에 요청 • Amazon Rekognition의 객체 탐지 기능을 활용 • 이미지를 byte로 변환해서, DetectLabels API 호출 import boto3 Rekog = boto3.client(‘rekognition’) h,w = image.shape[:2] regImg = cv2.resize(image, (int(0.2*w), int(0.2*h))) _, newjpeg = cv2.imencode('.jpg', regImg) imgbytes = newjpeg.tobytes() resp = rekog.detect_labels(Image={'Bytes':imgbytes})
  • 8. Rekognition Image 서비스 응답 • Amazon Rekognition의 응답은 JSON 형태임 • 탐지된 객체들을 Labels 배열 형태로, 객체 이름과 확율값들이 리턴됨 { 'Labels’: [ {'Confidence': 98.9703369140625, 'Name': 'Human’}, {'Confidence': 98.9703140258789, 'Name': 'People’}, {'Confidence': 98.9703369140625, 'Name': 'Person’} ], 'ResponseMetadata’: {'RequestId': '2531323b-2537-11e8-8d75-994d4bd0f8ee’, 'HTTPStatusCode': 200, 'HTTPHeaders’: { … }, 'RetryAttempts’: 0 }, 'OrientationCorrection': 'ROTATE_0’ }
  • 9. 분석 결과를 비디오 스트리밍으로 출력 • Flask (마이크로 웹 프레임워크)를 활용해서 웹 서비스 구성 • 분석 결과를 포함한 이미지를 MJPEG 형식으로 출력 from flask import Flask, render_template, Response @app.route('/video_feed’) def video_feed(): return Response(gen(VideoCamera()),mimetype='multipart/x-mixed-replace; boundary=frame')
  • 12. 왜 디바이스에서 예측 수행이 필요할까요? • 다음과 같은 제약이 있을 수 있습니다. • 응답 속도 • 네트워크 연결성 • 규제 • 비용 • 이 경우, 클라우드 머신러닝 서비스를 이용한 예측이 아닌, 디바이스에서 직접 머신러닝 예측을 수행하는 것이 필요
  • 13. 디바이스에서 머신러닝 예측을 한다면 … • 머신러닝 모델을 어떻게 배포할 것인가? • 머신러닝 모델을 이용한 예측 프로그램을 어떻게 배포할 것인가? • 머신 러닝 예측을 어떻게 수행할지? • 예측 결과를 클라우드 서비스와 어떻게 연동할 것인가?
  • 14. 2가지 방법 AWS Greengrass ML Inference AWS DeepLens
  • 15. AWS Greengrass Core • AWS IoT 기능의 일부를 로컬에서 수행할 수 있도록 해주는 소프트웨어
  • 16. Greengrass ML Inference • 머신 러닝 모델 및 예측 코드를 Greengrass Core 디바이스에 배포하고 수행하는 환경을 제공함 AWS Greengrass 콘솔에서 기기로 모델 배포 디바이스에서 모델 기반 예측 인터넷 비연결시에도 동작 가능 클라우드에서 모델 학습 및 훈련
  • 17. 배포할 모델 및 Lambda 함수 • 머신러닝 모델: SqueezeNet • AlexNet 수준의 정확도 • 50배 정도 적은 파라메터 및 작은 모델 크기 (0.5MB 이하) • https://arxiv.org/abs/1602.07360 • Lambda 함수 • Python 2.7, Apache MXNet 0.11.0 • 카메라 접근을 위한 로컬 리소스 추가
  • 20. Greengrass : Lambda 로컬 리소스 카메라 접근을 위한 Local Resource들 머신러닝 모델
  • 22. Lambda 함수를 살펴보면 … 객체 탐지를 위한 머신러닝 모델을 로딩 카메라 이미지에 대한 객체 탐지 예측 수행 객체 탐지 결과를 AWS IoT Cloud로 전송 3초 후, 탐지 함수 재호출
  • 23. 머신러닝 모델 로딩 코드 머신러닝 모델 네트워크 정의 (sym) 및 파라메터 (arg_params, aux_params) 로딩 로딩된 값들을 이용해서 MXNet Module 생성
  • 24. 카메라에서 이미지 획득 코드 def predict_from_webcam(self, capfile='cap.jpg', reshape=(224, 224), N=5): cv2.VideoCapture(0) vidcap=cv2.VideoCapture(0) vidcap.open(0) #sleep(1) retval, image = vidcap.read() vidcap.release() return self.predict_from_image(image, reshape, N)
  • 25. 머신러닝 예측 수행 코드 def predict_from_image(self, cvimage, reshape=(224, 224), N=5): topN = [] # Switch RGB to BGR format (which ImageNet networks take) img = cv2.cvtColor(cvimage, cv2.COLOR_BGR2RGB) if img is None: return topN # Resize image to fit network input img = cv2.resize(img, reshape) img = np.swapaxes(img, 0, 2) img = np.swapaxes(img, 1, 2) img = img[np.newaxis, :] # Run forward on the image self.mod.forward(Batch([mx.nd.array(img)])) prob = self.mod.get_outputs()[0].asnumpy() prob = np.squeeze(prob) # Extract the top N predictions from the softmax output a = np.argsort(prob)[::-1] for i in a[0:N]: topN.append((prob[i], self.synsets[i])) return topN 이미지에 대한 예측 수행 탐지된 객체 상위 N 개 추출
  • 26. Greengrass 예측 수행 데모 – Lambda 로그
  • 27. Greengrass 예측 수행 데모 – IoT 메시지 ’hello/world’ IoT 토픽으로 전송된 이미지에 대한 예측 수행 결과
  • 28. AWS DeepLens Community Project https://aws.amazon.com/deeplens/community-projects/
  • 29. DeepLens Project 정의 DeepLens 샘플 모델 – 객체 분류 모델 모델을 로딩하고, 예측을 수행할 Lambda 함수
  • 31. DeepLens Project – 대상 디바이스 선택
  • 32. DeepLens Project – 배포 리뷰
  • 33. DeepLens Project – 배포 수행
  • 36. 이미지 기반의 실시간 영상 분석 솔루션 구성 https://github.com/aws-samples/amazon-rekognition-video-analyzer
  • 37. 어떤 개선이 필요할까요? • 카메라 디바이스가 여러가지 종류라면? • 프레임 단위가 아닌 영상으로 저장하고 싶다면? • 이미지 기반으로 할 수 없는 예측은?
  • 38. 영상 스트림 입수 및 분석을 위한 서비스 실시간 비디오 스트림 Amazon Kinesis Video Streams 딥러닝 기반 영상 분석 Amazon Rekognition Video
  • 39. 활용 예 – 실시간 위험 인물 탐지
  • 40. Kinesis Video Streams – 구성 요소 • Producer • Kinesis Video Streams Producer 라이브러리 활용 • 비디오 및 다른 데이터(오디오, 이미지, RADAR)를 Kinesis Video Streams로 보내는 역할 • C++, Java, Android • Consumer • Kinesis Video Streams Parser 라이브러리 사용 • 데이터를 읽고, 처리하고, 분석하는 역할을 하는 Kinesis Video Streams 어플리케이션 • Java
  • 41. Amazon Rekognition Video 기능 객체 및 행동 탐지 사람 추적 얼굴 인식 실시간 라이브 스트림 안전하지 않은 비디오 탐지 유명인 인식
  • 42. 실시간 인물 검색을 구성해보면 … Consumer Producer
  • 43. Kinesis Video Streams 생성하기
  • 44. Kinesis Video Streams 생성하기 - 설정
  • 45. Raspberry Pi를 Producer로 만들기 • Amazon Kinesis Video Streams Raspberry Pi 가이드 • https://aws.amazon.com/kinesis/video-streams/raspberry-pi- tutorial/ • Step-by-Step 가이드 (AWS re:Invent 2017) • http://amzn.to/video-streams-workshop • https://www.slideshare.net/AmazonWebServices/new-launch- stream-video-from-edge-devices-to-aws-for-playback-storage- and-processing-using-amazon-kinesis-video-streams-abd340- reinvent-2017
  • 46. Producer 시작 및 스트리밍 확인 $ AWS_ACCESS_KEY_ID=<your aws_access_key_id> AWS_SECRET_ACCESS_KEY=<your aws_secret_access_key> ./kinesis_video_gstreamer_sample_app <stream_name>
  • 47. Rekognition Video 연결은 어떻게 … • Kinesis Video Streams의 Consumer에서 다음 과정을 수행합니다. 1) Rekognition이 어떤 분석을 할지 정하는 StreamProcessorSetting 생성 2) 이 설정을 적용한 Stream Processor를 생성하고, 3) 원하는 시점에 Stream Processor를 시작, 중지, 삭제합니다. • Rekognition Video 결과는, Kinesis Data Streams으로 전송
  • 48. Consumer – Kinesis Video + Rekognition 얼굴 검색을 위한 StreamProcessorSettings 정의
  • 49. Consumer – Kinesis Video + Rekognition 위에서 정의된 Processor 설정을 적용한, StreamProcessor 생성
  • 50. Consumer – Kinesis Video + Rekognition StreamProcessor 시작, 중지, 삭제
  • 52. Kinesis Data Stream 값 확인
  • 53. 참고 자료 • 실시간 영상 분석 및 스트리밍 웹 서비스 • https://github.com/muhyun/rekognition-video-stream-server • Serverless Pipeline for Video Frame Analysis and Alerting • https://github.com/aws-samples/amazon-rekognition-video-analyzer • Amazon Kinesis Video Streams Producer • https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp • https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-java • DeepLens Community Projects • https://aws.amazon.com/deeplens/community-projects/
  • 55. 질문에 대한 답변 드립니다. 발표자료/녹화영상 제공합니다. http://bit.ly/awskr-webinar 더 나은 세미나를 위해 여러분의 의견을 남겨 주세요!