Arts >> Magic >> Magic Shows

What is the code to get mystery part?

```python

from __future__ import print_function

from google.cloud.vision import ImageAnnotatorClient

import os

Gets a Mystery part from the Vision API.

def get_mystery_part(path):

"""Returns mystery part from the input image. Path is the path to

the image."""

# Google Vision API client

client = ImageAnnotatorClient()

# Load image from file into memory

with io.open(path, 'rb') as image_file:

content = image_file.read()

# Build image object for Vision to interpret

image = types.Image(content=content)

# Perform part detection on the image file

response = client.web_detection(image)

annotations = response.web_detection

# List out the Mystery Part if found

if annotations.best_guess_labels:

for label in annotations.best_guess_labels:

print("Mystery: {}".format(label.label))

```

Magic Shows

Related Categories