×
1 Choose EITC/EITCA Certificates
2 Learn and take online exams
3 Get your IT skills certified

Confirm your IT skills and competencies under the European IT Certification framework from anywhere in the world fully online.

EITCA Academy

Digital skills attestation standard by the European IT Certification Institute aiming to support Digital Society development

LOG IN TO YOUR ACCOUNT

CREATE AN ACCOUNT FORGOT YOUR PASSWORD?

FORGOT YOUR PASSWORD?

AAH, WAIT, I REMEMBER NOW!

CREATE AN ACCOUNT

ALREADY HAVE AN ACCOUNT?
EUROPEAN INFORMATION TECHNOLOGIES CERTIFICATION ACADEMY - ATTESTING YOUR PROFESSIONAL DIGITAL SKILLS
  • SIGN UP
  • LOGIN
  • INFO

EITCA Academy

EITCA Academy

The European Information Technologies Certification Institute - EITCI ASBL

Certification Provider

EITCI Institute ASBL

Brussels, European Union

Governing European IT Certification (EITC) framework in support of the IT professionalism and Digital Society

  • CERTIFICATES
    • EITCA ACADEMIES
      • EITCA ACADEMIES CATALOGUE<
      • EITCA/CG COMPUTER GRAPHICS
      • EITCA/IS INFORMATION SECURITY
      • EITCA/BI BUSINESS INFORMATION
      • EITCA/KC KEY COMPETENCIES
      • EITCA/EG E-GOVERNMENT
      • EITCA/WD WEB DEVELOPMENT
      • EITCA/AI ARTIFICIAL INTELLIGENCE
    • EITC CERTIFICATES
      • EITC CERTIFICATES CATALOGUE<
      • COMPUTER GRAPHICS CERTIFICATES
      • WEB DESIGN CERTIFICATES
      • 3D DESIGN CERTIFICATES
      • OFFICE IT CERTIFICATES
      • BITCOIN BLOCKCHAIN CERTIFICATE
      • WORDPRESS CERTIFICATE
      • CLOUD PLATFORM CERTIFICATENEW
    • EITC CERTIFICATES
      • INTERNET CERTIFICATES
      • CRYPTOGRAPHY CERTIFICATES
      • BUSINESS IT CERTIFICATES
      • TELEWORK CERTIFICATES
      • PROGRAMMING CERTIFICATES
      • DIGITAL PORTRAIT CERTIFICATE
      • WEB DEVELOPMENT CERTIFICATES
      • DEEP LEARNING CERTIFICATESNEW
    • CERTIFICATES FOR
      • EU PUBLIC ADMINISTRATION
      • TEACHERS AND EDUCATORS
      • IT SECURITY PROFESSIONALS
      • GRAPHICS DESIGNERS & ARTISTS
      • BUSINESSMEN AND MANAGERS
      • BLOCKCHAIN DEVELOPERS
      • WEB DEVELOPERS
      • CLOUD AI EXPERTSNEW
  • FEATURED
  • SUBSIDY
  • HOW IT WORKS
  •   IT ID
  • ABOUT
  • CONTACT
  • MY ORDER
    Your current order is empty.
EITCIINSTITUTE
CERTIFIED

How can we obtain the safe search annotation using the Google Vision API in Python?

by EITCA Academy / Saturday, 30 December 2023 / Published in Artificial Intelligence, EITC/AI/GVAPI Google Vision API, Advanced images understanding, Explicit content detection (safe search feature), Examination review

To obtain the safe search annotation using the Google Vision API in Python, you can leverage the powerful features provided by the API to analyze and understand the explicit content within images. The safe search annotation allows you to determine whether an image contains any explicit or inappropriate content, which can be important in various applications such as content moderation, filtering, and parental controls.

To get started, you will need to have the Google Cloud SDK installed and set up on your local machine. Once you have that, you can proceed with the following steps to utilize the Google Vision API and obtain the safe search annotation:

1. Enable the Google Vision API: Visit the Google Cloud Console, create a new project or select an existing one, and enable the Vision API for that project.

2. Install the required libraries: Open your terminal or command prompt and install the `google-cloud-vision` library using the following command:

bash
pip install google-cloud-vision

3. Authenticate your application: Generate a service account key file from the Google Cloud Console, and set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path of the downloaded key file. This will allow your Python code to authenticate and access the Vision API.

4. Write the Python code: Create a new Python file and import the necessary modules:

python
from google.cloud import vision
from google.cloud.vision_v1 import types

5. Initialize the client: Create a new Vision API client instance:

python
client = vision.ImageAnnotatorClient()

6. Load the image: Read the image file and convert it to a byte array:

python
with open('path/to/your/image.jpg', 'rb') as image_file:
    content = image_file.read()
image = types.Image(content=content)

7. Make the API request: Use the client to perform the explicit content detection and obtain the safe search annotation:

python
response = client.safe_search_detection(image=image)
safe_search = response.safe_search_annotation

8. Access the safe search results: You can now access various attributes of the safe search annotation to determine the explicit content present in the image. Here are some of the attributes you can check:

python
print('Adult:', safe_search.adult)
print('Spoof:', safe_search.spoof)
print('Medical:', safe_search.medical)
print('Violence:', safe_search.violence)
print('Racy:', safe_search.racy)

The above code will print the likelihood of each category being present in the image. The likelihood values can be one of the following: UNKNOWN, VERY_UNLIKELY, UNLIKELY, POSSIBLE, LIKELY, or VERY_LIKELY.

By following these steps, you can easily obtain the safe search annotation using the Google Vision API in Python. Remember to handle any exceptions that may occur during the API request and ensure that you have proper error handling in your code.

Other recent questions and answers regarding Advanced images understanding:

  • What are some predefined categories for object recognition in Google Vision API?
  • What is the recommended approach for using the safe search detection feature in combination with other moderation techniques?
  • How can we access and display the likelihood values for each category in the safe search annotation?
  • What are the five categories included in the safe search detection feature?
  • How does the Google Vision API's safe search feature detect explicit content within images?
  • How can we visually identify and highlight the detected objects in an image using the pillow library?
  • How can we organize the extracted object information in a tabular format using the pandas data frame?
  • How can we extract all the object annotations from the API's response?
  • What libraries and programming language are used to demonstrate the functionality of the Google Vision API?
  • How does the Google Vision API perform object detection and localization in images?

View more questions and answers in Advanced images understanding

More questions and answers:

  • Field: Artificial Intelligence
  • Programme: EITC/AI/GVAPI Google Vision API (go to the certification programme)
  • Lesson: Advanced images understanding (go to related lesson)
  • Topic: Explicit content detection (safe search feature) (go to related topic)
  • Examination review
Tagged under: Artificial Intelligence, Explicit Content Detection, Google Cloud SDK, Google Vision API, Python, Safe Search Annotation
Home » Advanced images understanding / Artificial Intelligence / EITC/AI/GVAPI Google Vision API / Examination review / Explicit content detection (safe search feature) » How can we obtain the safe search annotation using the Google Vision API in Python?

Certification Center

USER MENU

  • My Account

CERTIFICATE CATEGORY

  • EITC Certification (105)
  • EITCA Certification (9)

What are you looking for?

  • Introduction
  • How it works?
  • EITCA Academies
  • EITCI DSJC Subsidy
  • Full EITC catalogue
  • Your order
  • Featured
  •   IT ID
  • EITCA reviews (Medium publ.)
  • About
  • Contact

EITCA Academy is a part of the European IT Certification framework

The European IT Certification framework has been established in 2008 as a Europe based and vendor independent standard in widely accessible online certification of digital skills and competencies in many areas of professional digital specializations. The EITC framework is governed by the European IT Certification Institute (EITCI), a non-profit certification authority supporting information society growth and bridging the digital skills gap in the EU.

Eligibility for EITCA Academy 80% EITCI DSJC Subsidy support

80% of EITCA Academy fees subsidized in enrolment by

    EITCA Academy Secretary Office

    European IT Certification Institute ASBL
    Brussels, Belgium, European Union

    EITC / EITCA Certification Framework Operator
    Governing European IT Certification Standard
    Access contact form or call +32 25887351

    Follow EITCI on X
    Visit EITCA Academy on Facebook
    Engage with EITCA Academy on LinkedIn
    Check out EITCI and EITCA videos on YouTube

    Funded by the European Union

    Funded by the European Regional Development Fund (ERDF) and the European Social Fund (ESF) in series of projects since 2007, currently governed by the European IT Certification Institute (EITCI) since 2008

    Information Security Policy | DSRRM and GDPR Policy | Data Protection Policy | Record of Processing Activities | HSE Policy | Anti-Corruption Policy | Modern Slavery Policy

    Automatically translate to your language

    Terms and Conditions | Privacy Policy
    EITCA Academy
    • EITCA Academy on social media
    EITCA Academy


    © 2008-2025  European IT Certification Institute
    Brussels, Belgium, European Union

    TOP
    Chat with Support
    Chat with Support
    Questions, doubts, issues? We are here to help you!
    End chat
    Connecting...
    Do you have any questions?
    Do you have any questions?
    :
    :
    :
    Send
    Do you have any questions?
    :
    :
    Start Chat
    The chat session has ended. Thank you!
    Please rate the support you've received.
    Good Bad