rekognizing patterns
play

Rekognizing patterns IN TRODUCTION TO AW S BOTO IN P YTH ON - PowerPoint PPT Presentation

Rekognizing patterns IN TRODUCTION TO AW S BOTO IN P YTH ON Maksim Pecherskiy Instructor Rekognition INTRODUCTION TO AWS BOTO IN PYTHON So what is Rekognition anyway? Detecting Objects in an image Extracting Text from Images INTRODUCTION


  1. Rekognizing patterns IN TRODUCTION TO AW S BOTO IN P YTH ON Maksim Pecherskiy Instructor

  2. Rekognition INTRODUCTION TO AWS BOTO IN PYTHON

  3. So what is Rekognition anyway? Detecting Objects in an image Extracting Text from Images INTRODUCTION TO AWS BOTO IN PYTHON

  4. Why not build our own? Use Rekognition if: Quick but good Keep code simple Recognize many things Build a model if: Custom requirements Security implications Large volumes INTRODUCTION TO AWS BOTO IN PYTHON

  5. I am not a computer vision expert INTRODUCTION TO AWS BOTO IN PYTHON

  6. INTRODUCTION TO AWS BOTO IN PYTHON

  7. INTRODUCTION TO AWS BOTO IN PYTHON

  8. INTRODUCTION TO AWS BOTO IN PYTHON

  9. INTRODUCTION TO AWS BOTO IN PYTHON

  10. Upload an image to S3 Initialize S3 Client s3 = boto3.client( 's3', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET ) Upload a �le s3.upload_file( Filename='report.jpg', Key='report.jpg', Bucket='datacamp-img') INTRODUCTION TO AWS BOTO IN PYTHON

  11. Object detection INITIATE THE CLIENT rekog = boto3.client( 'rekognition', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET) INTRODUCTION TO AWS BOTO IN PYTHON

  12. Object detection DETECT! response = rekog.detect_labels( Image={'S3Object': { 'Bucket': 'datacamp-img', 'Name': 'report.jpg' }, MaxLabels=10, MinConfidence=95 ) INTRODUCTION TO AWS BOTO IN PYTHON

  13. INTRODUCTION TO AWS BOTO IN PYTHON

  14. INTRODUCTION TO AWS BOTO IN PYTHON

  15. INTRODUCTION TO AWS BOTO IN PYTHON

  16. INTRODUCTION TO AWS BOTO IN PYTHON

  17. INTRODUCTION TO AWS BOTO IN PYTHON

  18. Text detection PERFORM DETECTION response = rekog.detect_text( Image={'S3Object': { 'Bucket': 'datacamp-img', 'Name': 'report.jpg' } } ) INTRODUCTION TO AWS BOTO IN PYTHON

  19. INTRODUCTION TO AWS BOTO IN PYTHON

  20. INTRODUCTION TO AWS BOTO IN PYTHON

  21. INTRODUCTION TO AWS BOTO IN PYTHON

  22. Summary Detect objects in an image Count instances Learn a new AWS Service .detect_labels() Recognize text in an image Word vs line detections When to build our own .detect_text() INTRODUCTION TO AWS BOTO IN PYTHON

  23. Let's do some computer vision! IN TRODUCTION TO AW S BOTO IN P YTH ON

  24. Comprehending text IN TRODUCTION TO AW S BOTO IN P YTH ON Maksim Pecherskiy Data engineer

  25. AWS Translate console INTRODUCTION TO AWS BOTO IN PYTHON

  26. Translating text Initialize client translate = boto3.client('translate', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET) Translate text response = translate.translate_text( Text='Hello, how are you?', SourceLanguageCode='auto', TargetLanguageCode='es') INTRODUCTION TO AWS BOTO IN PYTHON

  27. Translating text INTRODUCTION TO AWS BOTO IN PYTHON

  28. Translating text translated_text = translate.translate_text( Text='Hello, how are you?', SourceLanguageCode='auto', TargetLanguageCode='es')['TranslatedText'] INTRODUCTION TO AWS BOTO IN PYTHON

  29. Detecting language Initialize boto3 Comprehend client comprehend = boto3.client('comprehend', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET) Detect dominant language response = comprehend.detect_dominant_language( Text="Hay basura por todas partes a lo largo de la carretera.") INTRODUCTION TO AWS BOTO IN PYTHON

  30. Detecting language INTRODUCTION TO AWS BOTO IN PYTHON

  31. Understanding sentiment INTRODUCTION TO AWS BOTO IN PYTHON

  32. Understanding sentiment Detect text sentiment response = comprehend.detect_sentiment( Text="DataCamp students are amazing.", LanguageCode='en') INTRODUCTION TO AWS BOTO IN PYTHON

  33. Understanding sentiment INTRODUCTION TO AWS BOTO IN PYTHON

  34. Understanding sentiment sentiment = comprehend.detect_sentiment( Text='Maksim is amazing.', LanguageCode='en')['Sentiment'] INTRODUCTION TO AWS BOTO IN PYTHON

  35. Review Initialize client translate = boto3.client('translate', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET) Translate text response = translate.translate_text( Text='Hello, how are you?', SourceLanguageCode='auto', TargetLanguageCode='es') INTRODUCTION TO AWS BOTO IN PYTHON

  36. Review Initialize boto3 Comprehend client comprehend = boto3.client('comprehend', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET) Detect dominant language response = comprehend.detect_dominant_language( Text="Hay basura por todas partes a lo largo de la carretera.") INTRODUCTION TO AWS BOTO IN PYTHON

  37. Review Detect text sentiment response = comprehend.detect_sentiment( Text="Maksim is amazing.", LanguageCode='en') INTRODUCTION TO AWS BOTO IN PYTHON

  38. Let's practice! IN TRODUCTION TO AW S BOTO IN P YTH ON

  39. Case Study: Scooting Around! IN TRODUCTION TO AW S BOTO IN P YTH ON Maksim Pecherskiy Data Engineer

  40. The Quandary INTRODUCTION TO AWS BOTO IN PYTHON

  41. The Quandary INTRODUCTION TO AWS BOTO IN PYTHON

  42. The Data service_request_id image lat long public_description Hay un scooter 93494 report_113439.jpg 32.723138 -117.128237 electrico en sidewalk -117.1281408 This scooter helped me 101502 report_134938839.jpg 32.7077658 move a mattress! There is a scooter 101520 report_272819.jpg 32.77605567 -117.100004 blocking the sidewalk 32.68899358 -117.0584723 I tripped on a stupid 101576 report_3722938.jpg scooter INTRODUCTION TO AWS BOTO IN PYTHON

  43. Final Product INTRODUCTION TO AWS BOTO IN PYTHON

  44. Final Product INTRODUCTION TO AWS BOTO IN PYTHON

  45. Final Product INTRODUCTION TO AWS BOTO IN PYTHON

  46. Final Product INTRODUCTION TO AWS BOTO IN PYTHON

  47. Final Product INTRODUCTION TO AWS BOTO IN PYTHON

  48. Initialize boto3 service clients. Initialize rekognition client rekog = boto3.client('rekognition', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET) Initialize comprehend client comprehend = boto3.client('comprehend', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET) INTRODUCTION TO AWS BOTO IN PYTHON

  49. Initialize boto3 service clients Initialize translate client translate = boto3.client('translate', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET) INTRODUCTION TO AWS BOTO IN PYTHON

  50. Translate all descriptions to English for index, row in df.iterrows(): desc = df.loc[index, 'public_description'] if desc != '': resp = translate_fake.translate_text( Text=desc, SourceLanguageCode='auto', TargetLanguageCode='en') df.loc[index, 'public_description'] = resp['TranslatedText'] INTRODUCTION TO AWS BOTO IN PYTHON

  51. Translate all descriptions to English service_request_id image lat long public_description Electric scooter on 93494 report_113439.jpg 32.723138 -117.128237 sidewalk -117.1281408 This scooter helped me 101502 report_134938839.jpg 32.7077658 move a mattress! There is a scooter 101520 report_272819.jpg 32.77605567 -117.100004 blocking the sidewalk 32.68899358 -117.0584723 I tripped on a stupid 101576 report_3722938.jpg scooter INTRODUCTION TO AWS BOTO IN PYTHON

  52. Detect text sentiment for index, row in df.iterrows(): desc = df.loc[index, 'public_description'] if desc != '': resp = comprehend.detect_sentiment( Text=desc, LanguageCode='en') df.loc[index, 'sentiment'] = resp['Sentiment'] INTRODUCTION TO AWS BOTO IN PYTHON

  53. Detect text sentiment service_request_id image lat long sentiment public_desc NEGATIVE Electric scoo 93494 report_113439.jpg 32.723138 -117.128237 sidewalk This scooter 101502 report_134938839.jpg 32.7077658 -117.1281408 POSITIVE helped me m mattress! There is a sc 101520 report_272819.jpg 32.77605567 -117.100004 NEGATIVE blocking the sidewalk 32 68899358 -117 0584723 NEGATIVE I tripped on 101576 report 3722938 jpg INTRODUCTION TO AWS BOTO IN PYTHON

  54. Detect scooter in image df['img_scooter'] = 0 for index, row in df.iterrows(): image = df.loc[index, 'image'] response = rekog.detect_labels( # Specify the image as an S3Object Image={'S3Object': {'Bucket': 'gid-images', 'Name': image}} ) for label in response['Labels']: if label['Name'] == 'Scooter': df.loc[index, 'img_scooter'] = 1 break INTRODUCTION TO AWS BOTO IN PYTHON

  55. Detect scooter in image service_request_id image img_scooter sentiment lat long 93494 report_113439.jpg 1 NEGATIVE 32.723138 -117.128237 101502 report_134938839.jpg 1 POSITIVE 32.7077658 -117.1281408 101520 report_272819.jpg 0 NEGATIVE 32.77605567 -117.100004 101576 report 3722938 jpg 1 NEGATIVE 32 68899358 -117 0584723 INTRODUCTION TO AWS BOTO IN PYTHON

  56. Final count! Select only rows where there was a scooter image and that have negative sentiment pickups = df[((df.img_scooter == 1) & (df.sentiment == 'NEGATIVE'))] num_pickups = len(pickups) 332 Scooters! INTRODUCTION TO AWS BOTO IN PYTHON

  57. Let's practice! IN TRODUCTION TO AW S BOTO IN P YTH ON

  58. Wrap up IN TRODUCTION TO AW S BOTO IN P YTH ON Maksim Pecherskiy Data Engineer

  59. AWS Services INTRODUCTION TO AWS BOTO IN PYTHON

Recommend


More recommend