Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-2-capstone-design1
/
HEN_project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이민규
2020-11-29 17:11:09 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
940f7930e1ccd6762280637ea816cf2e87ac4989
940f7930
1 parent
d2f9efe2
Update lambda_yoga_project.py
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
Code/lambda_yoga_project.py
Code/lambda_yoga_project.py
View file @
940f793
...
...
@@ -6,6 +6,14 @@
#*****************************************************
""" A sample lambda for bird detection"""
from
threading
import
Thread
,
Event
#*****************************************************
# *
# Copyright 2018 Amazon.com, Inc. or its affiliates. *
# All Rights Reserved. *
# *
#*****************************************************
from
threading
import
Thread
,
Event
import
os
import
json
import
numpy
as
np
...
...
@@ -94,9 +102,9 @@ def infinite_infer_run():
model_name
=
"image-classification"
ret
,
model_path
=
mo
.
optimize
(
model_name
,
input_width
,
input_height
,
aux_inputs
=
{
'--epoch'
:
5
,
'--precision'
:
'FP16'
})
# Load the model onto the GPU.
client
.
publish
(
topic
=
iot_topic
,
payload
=
'Loading
bird detection
model'
)
client
.
publish
(
topic
=
iot_topic
,
payload
=
'Loading model'
)
model
=
awscam
.
Model
(
model_path
,
{
'GPU'
:
1
})
client
.
publish
(
topic
=
iot_topic
,
payload
=
'
Bird detection
loaded'
)
client
.
publish
(
topic
=
iot_topic
,
payload
=
' loaded'
)
# The number of top results to stream to IoT.
num_top_k
=
3
# Define the detection region size.
...
...
@@ -159,6 +167,6 @@ def infinite_infer_run():
cloud_output
[
output_map
[
obj
[
'label'
]]]
=
obj
[
'prob'
]
client
.
publish
(
topic
=
iot_topic
,
payload
=
json
.
dumps
(
cloud_output
))
except
Exception
as
ex
:
client
.
publish
(
topic
=
iot_topic
,
payload
=
'Error
in bird detection lambda
: {}'
.
format
(
ex
))
client
.
publish
(
topic
=
iot_topic
,
payload
=
'Error : {}'
.
format
(
ex
))
infinite_infer_run
()
...
...
Please
register
or
login
to post a comment