Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Data Science
  • Data Science Projects
  • Data Analysis
  • Data Visualization
  • Machine Learning
  • ML Projects
  • Deep Learning
  • NLP
  • Computer Vision
  • Artificial Intelligence
Open In App
Next Article:
Visualize the Flower Dataset using Tensorflow - Python
Next article icon

Visualize the Flower Dataset using Tensorflow - Python

Last Updated : 28 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The Tensorflow flower dataset is a large dataset that consists of flower images. In this article, we are going to learn how we can visualize the flower dataset in python. For the purposes of this article, we will use tensorflow_datasets and Matplotlib library.

Prerequisites

If you don't have any of the libraries mentioned below, you can install them using the pip command, for example, to install the tensorflow_datasets library you need to write the following command:

pip install tensorflow-datasets

Matplotlib is a plotting library for Python. It allows the user with functionalities to visualize and plot complex graphs in python yet provides extensive customization capabilities. To install Matplotlib, just as before you can use the pip command:

pip install matplotlib

Importing Libraries

tensorflow_datasets is a library of public datasets ready to use with TensorFlow and MatplotLib is one of the handy tools used by machine learning practitioners to build visualization on different kinds of datasets.

Python3
import tensorflow_datasets as tfds import matplotlib.pyplot as plt 

Loading Flower Dataset

Let's start by importing the dataset. We will utilize the tfds.load() function to import the flower dataset. It is used to load the specified dataset into a tf.data.Dataset, which is supplied via the name argument. The flower dataset is called tf_flowers.

Python3
dataset, info = tfds.load(     'tf_flowers',     with_info=True,     as_supervised=True, ) get_image_label = info.features['label'].int2str 
 

Let's check how many images we have in the dataset.

Python3
print(len(dataset['train'])) 

Output:

3670

Now it's time to visualize the images. The following piece of code shows the first four images in the dataset.

Python3
num = 1 fig = plt.figure(figsize=(20, 14)) for image, label in iter(dataset['train']):     if num > 4:         break     img = image.numpy()     fig.add_subplot(2, 2, num)     plt.imshow(img)     plt.axis('off')     plt.title(get_image_label(label))     num += 1 plt.tight_layout() plt.show() 

Output:

Visualizing some images from the flower dataset
Visualizing some images from the flower dataset

We can also apply data augmentation on it using one of the very handy libraries that are Albumentation.

Python3
import albumentations as A  augmenter = A.VerticalFlip(p=1) image, label = next(iter(dataset['train'])) plt.subplot(1, 2, 1) _ = plt.imshow(image) _ = plt.title(get_image_label(label))  plt.subplot(1, 2, 2) image = augmenter(image=image)['image'] _ = plt.imshow(image) _ = plt.title(get_image_label(label)) 

Output:

Original image and the augmented image
Original image and the augmented image

Next Article
Visualize the Flower Dataset using Tensorflow - Python

A

aayushmohansinha
Improve
Article Tags :
  • Technical Scripter
  • Data Visualization
  • AI-ML-DS
  • Technical Scripter 2022
  • Python-Tensorflow
  • AI-ML-DS With Python

Similar Reads

    Data Visualization using Turicreate in Python
    In Machine Learning, Data Visualization is a very important phase. In order to correctly understand the behavior and features of your data one needs to visualize it perfectly. So here I am with my post on how to efficiently and at the same time easily visualize your data to extract most out of it. B
    3 min read
    Build the Model for Fashion MNIST dataset Using TensorFlow in Python
    The primary objective will be to build a classification model which will be able to identify the different categories of the fashion industry from the Fashion MNIST dataset using Tensorflow and Keras To complete our objective, we will create a CNN model to identify the image categories and train it
    5 min read
    How can Tensorflow be used to pre-process the flower training dataset?
    The flower dataset present in TensorFlow large catalog of datasets is an extensive collection of images of flowers. There are five classes of flowers present in the dataset namely: DaisyDandelionRosesSunflowersTulips Here in this article, we will study how to preprocess the dataset. After the comple
    3 min read
    How can Tensorflow be used to split the flower dataset into training and validation?
    The Tensorflow flower dataset is a large dataset that consists of flower images. In this article, we are going to see how we can split the flower dataset into training and validation sets. For the purposes of this article, we will use tensorflow_datasets to load the dataset.  It is a library of publ
    3 min read
    Python Bokeh – Visualizing the Iris Dataset
    Bokeh is a Python interactive data visualization. It renders its plots using HTML and JavaScript. It targets modern web browsers for presentation providing elegant, concise construction of novel graphics with high-performance interactivity. Bokeh can be used to visualize the Iris flower dataset. Vis
    8 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences