Code Monkey home page Code Monkey logo

Comments (1)

ohmayr avatar ohmayr commented on June 13, 2024

Hi @nwaughachukwuma, thanks for reaching out. I tried the sample provided in the link and it seems to work as expected.

Code:

# Imports the Google Cloud client library
from google.cloud import vision



def run_quickstart() -> vision.EntityAnnotation:
    """Provides a quick start example for Cloud Vision."""

    # Instantiates a client
    client = vision.ImageAnnotatorClient()

    # The URI of the image file to annotate
    file_uri = "gs://cloud-samples-data/vision/label/wakeupcat.jpg"

    image = vision.Image()
    image.source.image_uri = file_uri

    # Performs label detection on the image file
    response = client.label_detection(image=image)
    print("response: ", response)
    labels = response.label_annotations

    print("Labels:")
    for label in labels:
        print(label.description)

    return labels

run_quickstart()

Output:

response:  label_annotations {
  mid: "/m/01yrx"
  description: "Cat"
  score: 0.956459463
  topicality: 0.956459463
}
label_annotations {
  mid: "/m/0d4v4"
  description: "Window"
  score: 0.938840091
  topicality: 0.938840091
}
label_annotations {
  mid: "/m/0307l"
  description: "Felidae"
  score: 0.89566052
  topicality: 0.89566052
}
label_annotations {
  mid: "/m/01lrl"
  description: "Carnivore"
  score: 0.885138333
  topicality: 0.885138333
}
label_annotations {
  mid: "/m/01k9lj"
  description: "Jaw"
  score: 0.880326807
  topicality: 0.880326807
}
label_annotations {
  mid: "/m/07k6w8"
  description: "Small to medium-sized cats"
  score: 0.863107383
  topicality: 0.863107383
}
label_annotations {
  mid: "/m/0244x1"
  description: "Gesture"
  score: 0.852604866
  topicality: 0.852604866
}
label_annotations {
  mid: "/m/01l7qd"
  description: "Whiskers"
  score: 0.84995687
  topicality: 0.84995687
}
label_annotations {
  mid: "/m/031b6r"
  description: "Window blind"
  score: 0.834581673
  topicality: 0.834581673
}
label_annotations {
  mid: "/m/0276krm"
  description: "Fawn"
  score: 0.816135049
  topicality: 0.816135049
}

Labels:
Cat
Window
Felidae
Carnivore
Jaw
Small to medium-sized cats
Gesture
Whiskers
Window blind
Fawn

Feel free to reach out if you have any questions related to the Python client. For any API specific questions, kindly submit feedback on this link.

from google-cloud-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.