"""."""
from google.cloud import vision
from google.cloud.vision import types
import time

CLIENT = vision.ImageAnnotatorClient()

def vision(temp_file=None, f=None):
    """."""
    if temp_file is None:
        image = types.Image(content=f)
        response = CLIENT.text_detection(image=image)
        return response.text_annotations

    with open(temp_file.name, 'rb') as f:
        contents = f.read()
    image = types.Image(content=contents)
    response = CLIENT.text_detection(image=image)
    return response.text_annotations
