Image captioning is a very classical and challenging problem coming to Deep Learning domain, in which we generate the textual description of image using its property, but we will not use Deep learning here. In this article, we will simply learn how can we simply caption the images using PIL.
Preprocessing on images is a great utility provided by Python PIL library. Not only we can change size, mode, orientation but we can draw on images, write text over it as well.
Install the required libraries:
urllib requests PIL glob shutil
Steps to follow first –
- Download the
font.ttffile (before running the code) using this link.
- Make folder with name as “CaptionedImages” beforehand where the output captioned images will be stored.
Below is the stepwise implementation using Python:
Sorting the output files in accordance to last modified time so that they do not get placed in alphabetical or any other mismanaged order.
- Getting started with Scikit-image: image processing in Python
- Converting an image to ASCII image in Python
- Image Processing in Java | Set 3 (Colored image to greyscale image conversion)
- Image Processing in Java | Set 4 (Colored image to Negative image conversion)
- Image Processing in Java | Set 6 (Colored image to Sepia image conversion)
- Python PIL | Image.new() method
- Python | Add image on a Tkinter button
- Image Resizing using OpenCV | Python
- Reading an image in OpenCV using Python
- Cartooning an Image using OpenCV - Python
- Image based Steganography using Python
- Image Processing without OpenCV | Python
- Python PIL | Image.crop() method
- Python | Image blurring using OpenCV
- Python | Image Classification using keras
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.