def callbackSee(client, userdata, message): print "Topic=" + message.topic print "Message=" + message.payload image = camera.takePicture() if message.payload.startswith("mxnet"): # Detect image with MXNet mxnetimage = inception.load_image(image) prob = inception.predict(mxnetimage, model) topN = inception.get_top_categories(prob, synsets) print topN speech = inception.get_top1_message(topN) print speech PollyApi.speak(polly, speech) if message.payload.endswith("tweet"): tweet.tweet(image, speech) print "Tweet sent" elif message.payload.startswith("reko"): # Detect image with Rekognition awsUtils.copyLocalFileToS3(image) print "Picture uploaded" labels = RekognitionApi.detectLabels(reko, image) RekognitionUtils.printLabelsInformation(labels) faces = RekognitionApi.detectFaces(reko, image) celebs = RekognitionApi.detectCelebrities(reko, image) newImage, faceCounter = RekognitionUtils.generateOutputImage( image, faces) faceMessage, labelMessage = RekognitionUtils.generateMessages( faceCounter, celebs, labels) print "Face message: " + faceMessage #print "Label message: " + labelMessage PollyApi.speak(polly, faceMessage) #PollyApi.speak(polly, labelMessage) if message.payload.endswith("tweet"): tweet.tweet(newImage, faceMessage) print "Tweet sent" else: print "Wrong Command, Please Enter Again"
#!/usr/bin/env python import argparse import inception # Load model and categories at startup model, synsets = inception.load_inception_model() # Detect image with MXNet image = inception.load_image('images/image1.jpg') prob = inception.predict(image, model) topN = inception.get_top_categories(prob, synsets) #print(topN) top1_message = inception.get_top1_message(topN) print(top1_message) def main(): parser = argparse.ArgumentParser() parser.parse_args() if __name__ == "__main__": main()