AWS DeepLens Guia página 112

Tabla de contenido

Publicidad

self.update_coords(frame, velocity,
elif label == 2:
self.update_coords(frame, velocity, -1*velocity, label)
elif label == 3:
self.update_coords(frame, self.adjust_x_vel(velocity, pct_of_center),
elif label == 4:
self.update_coords(frame, self.adjust_x_vel(velocity, pct_of_center),
elif label == 5:
self.update_coords(frame, self.adjust_x_vel(velocity, pct_of_center),
elif label == 6:
self.update_coords(frame, -1*velocity, velocity, label)
elif label == 7:
self.update_coords(frame, -1*velocity, self.adjust_y_vel(velocity,
pct_of_center),
elif label == 8:
self.update_coords(frame, -1*velocity, -1*velocity, label)
def get_results(self, parsed_results, output_map):
""" Method converts the user entered number of top inference
labels and associated probabilities to json format.
parsed_results - A dictionary containing the inference results.
output_map - A dictionary that maps the numerical labels returned
the inference engine to human readable labels.
"""
if self.quadrants <= 0 or self.quadrants > len(parsed_results):
return json.dumps({"Error" : "Invalid"})
top_result = parsed_results[0:self.quadrants]
cloud_output = {}
for obj in top_result:
cloud_output[output_map[obj['label']]] = obj['prob']
return json.dumps(cloud_output)
def head_detection():
""" This method serves as the main entry point of our lambda.
"""
# Creating a client to send messages via IoT MQTT to the cloud
client = greengrasssdk.client('iot-data')
# This is the topic where we will publish our messages too
iot_topic = '$aws/things/{}/infer'.format(os.environ['AWS_IOT_THING_NAME'])
try:
# define model prefix and the amount to down sample the image by.
input_height = 84
input_width = 84
model_name="frozen_model"
# Send message to IoT via MQTT
client.publish(topic=iot_topic, payload="Optimizing model")
ret, model_path = mo.optimize(model_name, input_width, input_height, platform='tf')
# Send message to IoT via MQTT
client.publish(topic=iot_topic, payload="Model optimization complete")
if ret is not 0:
raise Exception("Model optimization failed, error code: {}".format(ret))
# Send message to IoT via MQTT
client.publish(topic=iot_topic, payload="Loading model")
# Load the model into cl-dnn
model = awscam.Model(model_path, {"GPU": 1})
# Send message to IoT via MQTT
client.publish(topic=iot_topic, payload="Model loaded")
# We need to sample a frame so that we can determine where the center of
# the image is located. We assume that
AWS DeepLens Guía para desarrolladores
Crear y ejecutar el proyecto de
detección de posición de cabeza
self.adjust_y_vel(velocity, pct_of_center), label)
velocity, label)
self.adjust_y_vel(velocity, pct_of_center),
label)
-1*velocity, label)
label)
108

Publicidad

Tabla de contenido
loading

Tabla de contenido