5 More Deep Learning Applications a beginner can build in minutes (using Python)

Faizan Shaikh Last Updated : 19 Apr, 2023
7 min read

Introduction

Deep Learning is fundamentally changing everything around us. A lot of people think that you need to be an expert to use power of deep learning in your applications. However, that is not the case.

In my previous article, I discussed 6 deep learning applications which a beginner can build in minutes. It was heart-warming for me to see hundreds of readers getting motivated by it. So I thought of following up from my previous article with a few more applications of deep learning. If you missed out on my previous article, I would suggest you should go through it.

In this article, we will learn how to build applications like automatic image tagging, apparel recommendation, music generation using deep learning and many more. And you will be able to build any of these applications with in minutes!

P.S. The article assumes, you know the basics of Python. If not, just follow this tutorial and then you can start from here again.

 

Table of Contents

1. Applications using existing APIs

  1. Automatic Image Tagging with Clarifai API
  2. Apparels Recommender with Indico API

2. Open Sourced Applications

  1. Music Generation using Deep Learning
  2. Detecting “Not Safe For Work” Images
  3. Super Resolution

3. Other Notable Resources

 

1. Deep learning Applications using existing API

1.1 Automatic Image Tagging (Clarifai API)

Image tagging is one of the first applications of deep learning that showed breakthrough results. Unlike textual data, an image is a lot harder to comprehend for a machine. The machine requires a deeper understanding of the pixel data. Therefore we use image tagging to essentially summarize the image and tell us which categories the image and its underlying objects belong to.

That’s why we use image tagging to essentially summarize the image. This tells us which categories the image belongs to and what are its underlying objects.

Below is an example of predicted tags given to an image which was found through deep learning.

Now, let us look at how to build the above tagging feature for every image using an API provided by Clarifai.

Requirements and Specifications

  1. Python (2 or 3)
  2. Internet connection (for accessing API endpoint)

 

  • Step 1: Register on Clarifai website and get your own API key. You can then find your API credentials on the developer page

 

  • Step 2: Install Clarifai client for python by going to the terminal and typing
pip install clarifai

 

  • Step 3: Configure your system with Clarifai client
clarifai config

Here,  you will be asked to provide your Client ID and Client Secret respectively. You can find these on the developer page itself.

 

  • Step 4: Now create a file “application.py” and insert the code below to tag the image. Remember to replace <your_image> in the code with the path of the image you want to tag.
from clarifai.rest import ClarifaiApp

app = ClarifaiApp()
app.tag_files(['<your_image>.jpg'])

Then run the code by

python application.py

You will get an output as follows

{
    "status": {
      "code": 10000,
      "description": "Ok"
    },
    "outputs": [
      {
        "id": "ea68cac87c304b28a8046557062f34a0",
        "status": {
          "code": 10000,
          "description": "Ok"
        },
        "input": {
          "id": "ea68cac87c304b28a8046557062f34a0",
          "data": {
            "image": {
              "url": "https://samples.clarifai.com/metro-north.jpg"
            }
          }
        },
        "data": {
          "concepts": [
            {
              "id": "ai_HLmqFqBf",
              "name": "train",
              "app_id": null,
              "value": 0.9989112
            },
...

This is a json output showing a response of the prediction. Here, you can find the relevant tags in outputs->data-> concept->name .

 

1.2 Apparels Recommender (Indico API)

Recommendation systems are becoming a great asset day by day. As the number of products is increasing, intelligently targeting specific consumers who would be willing to buy the product is essential. Deep Learning can help us in this genre too!

I am not a fashion buff, but I have seen people “waste” so much time choosing which clothes to wear. How great would it be if we could have an artificial agent know our preferences and suggest us the perfect outfit!

Fortunately, with deep learning this is possible.

You can find a demo of this application here.

The official article describes this in more detail. Now let’s find out how can you build this recommender system at your end.

Requirements and Specifications

  1. Python 2
  2. Internet connection (for accessing API endpoint)

 

 

  • Step 2: Install Indicoio client for python by going to command prompt and typing
pip install indicoio

 

  • Step 3: Download the repository from Github (here’s the link), extract it and go to “matching_clothes” folder.

 

  • Step 4: Now in the “main.py” file, insert the code below. Remember to replace YOUR_API_KEY with your own which you got in step 1.
import indicoio
from indicoio.custom import Collection

indicoio.config.api_key = 'YOUR_API_KEY'

And at the end, replace the part ‘if __name__ == “__main__”‘ with below code

if __name__ == "__main__":    
    train = generate_training_data("clothes_match_labeled_data_1.txt")
    collection = Collection("clothes_collection_1")

    for sample in tqdm(train):
        print sample 
        collection.add_data(sample)
    collection.train()
    collection.wait()

And run this code by

python main.py

You will get an output like this

{u'label1': 0.0183739774, u'label2': 0.8100245667, u'label3': 0.1102390038, u'label4': 0.060105865800000005, u'label5': 0.0012565863}

which shows the probability of match as shown in the example above.

 

2. Open Source Deep Learning Applications

2.1 Music Generation using Deep Learning

Music generation is one of the coolest applications of deep learning. If this application is used meticulously, it can bring breakthroughs in the industry.

Music, just like most of the things in nature, is harmonic. It has patterns which our mind catches and makes sense of. These patterns of music can be taught to a computer and then can be used to create new music rhythms. This is the formula behind music generation.

This open source application was built keeping in mind this concept. Below is an example of what it could generate.

Now let’s look at how we can replicate the results!

Requirements:

  1. Python (2 or 3)

 

  • Step 1: Install the dependencies

First, install Theano. Note that you have to install the bleeding edge version of Theano, which is required for this. You can find the installation instructions here.

Then install Keras by the below code

pip install keras

You would have to change backend of Keras from tensorflow to Theano. Follow the instructions given here.

The final dependency is of Music21. For installation, refer this link.

 

  • Step 2: Now create music by running the below command
python generator.py 128

 

2.2 Detecting “Not Safe For Work” Images

Although censorship is indeed a controversial topic, it is still a vital component for filtering out offensive adult content from the viewers. The inventors of this application focused on filtering out one of the main type of NFSW content, identification of pornographic images. A score is returned, which shows the intensity of NFSW, which can be used to filter out images above a certain threshold.

Below shows the images and their corresponding NFSW score as given by the application.

Let’s look at how to build one such application

Requirements:

  1. Python 2

 

  • Step 1: Install docker in your system and build an image using command below
docker build -t caffe:cpu https://raw.githubusercontent.com/BVLC/caffe/master/docker/standalone/cpu/Dockerfile

 

  • Step 2: Download repository from Github and extract it (here’s the link)

 

  • Step 3: Go to your downloaded folder and run the below command in terminal. Give path of the image you want to analyze.
docker run --volume=$(pwd):/workspace caffe:cpu python ./classify_nsfw.py --model_def nsfw_model/deploy.prototxt --pretrained_model nsfw_model/resnet_50_1by2_nsfw.caffemodel <your_image>.jpg

 

2.3 Super Resolution

We often see in movies that when you zoom in to an image, you can view even the finest detail which can be used to catch a criminal or get a crucial evidence.

In reality, this is not the case.When you zoom in, the image often gets blurry and not much can be seen. To cope up with this (and to make the dream a reality), we can use deep learning to increase the resolution of an image, which can help us to get clarity on zooming in.

This application is the depiction of the same. Here is its sample output.

Now let’s look at how to build this

 

Requirements

  1. Python 3

 

  • Step 1: Install docker in your system.

 

  • Step 2: Open the .bashrc file and write the below line of code
alias enhance='function ne() { docker run --rm -v "$(pwd)/`dirname ${@:$#}`":/ne/input -it alexjc/neural-enhance ${@:1:$#-1} "input/`basename ${@:$#}`"; }; ne'

 

  • Step 3: Now to enhance your image, just insert the name of your image in the below code
enhance --zoom=1 --model=repair <your_image>.jpg

 

3. Other Notable Resources

Deep learning constantly amazes me. With countless applications in the making, the race for making use of this technology is becoming rampant in the industry. Before signing off, I would like to mention some of the resources which might be inspirational to you.

You can also look at the video below for some use cases where deep learning can be used to enrich our lives. Enjoy!

 

End Notes

I hope you enjoyed reading this article. Deep Learning continues to fascinate everyone including top data scientists across the globe.  These are few of the interesting applications I wanted to share with you. If you happen to know any other deep learning application, do share it with me in the comments section.

If you come across any queries while building these applications at your end. Post your questions below & I’ll be happy to answer them.

Learn, compete, hack and get hired!

Faizan is a Data Science enthusiast and a Deep learning rookie. A recent Comp. Sc. undergrad, he aims to utilize his skills to push the boundaries of AI research.

Responses From Readers

Clear

Mike
Mike

Awesome article. Python is a great language to get started coding with and anyone can get started with all the free resources and ebooks available everywhere

Saurabh Mathur
Saurabh Mathur

Its was a awesome article i get a lot of knowledge about Python..

abiya
abiya

Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

We use cookies essential for this site to function well. Please click to help us improve its usefulness with additional cookies. Learn about our use of cookies in our Privacy Policy & Cookies Policy.

Show details