DEV Community

Cover image for AI APIs for Web Devs - Concrete applications
SamyMe
SamyMe

Posted on • Edited on • Originally published at Medium

AI APIs for Web Devs - Concrete applications

Have you ever wondered how you, as a web developer, can grasp the power of AI ?

But first, whatโ€™s AI ?

Artificial Intelligence is about allowing a machine to mimic human behavior. Computers were made to do that by the power of elaborated algorithms. Now, machine and deep learning make it possible to teach computers with data what we fail to describe in an algorithmic approach. This opens the way for computers to understand and manipulating non structured data :

  • ๐Ÿ“– Reading text and understanding concepts like : the topic of the text, the sentiment of the writer and the key concepts it talks about

  • ๐Ÿ—ฃ๏ธ Hearing your voice, understanding the words you say and responding to you (Siri and Alexa : speech to text and text to speech)

  • ๐ŸŽฅ Looking at an image or watching a video and understanding the big picture and the details of what it contains

But in order to achieve these objectives, you have to train large models with millions of labeled data.
Now, with AI as a Service, a lot of companies provide off-the-shelf trained models that you can access directly through an API. These companies are either the tech giants (Google, Microsoft , Amazon) or other smaller, more specialized companies, and there are hundreds of them. Some of the most known are : DeepL (translation), OpenAI (text and image analysis), AssemblyAI (speech analysis). If only there was one global API for accessing all these modelsโ€ฆ

Usecases :

The very easy access to this intelligence through simple APIs lead to the creation of tons of use cases :

  1. Automatically parse unstructured documents into a structured form : If your app handles scanned documents or pdfs (example: resumes, invoices, ID documents โ€ฆetc), you can parse them automatically to extract the data it contains and store it into a structured DB for easier manipulation.

Image description


import json
import requests

headers = {"Authorization": "Bearer ๐Ÿ”‘ Your_API_Key"}

url="https://api.edenai.run/v2/ocr/identity_parser"
data={"providers": "amazon,microsoft,mindee"}
files = {'file': open("๐Ÿ–ผ๏ธ path/to/your/image.png",'rb')}

response = requests.post(url, data=data, files=files, headers=headers)

result = json.loads(response.text)
print(result['amazon'])
print(result['mindee'])

Enter fullscreen mode Exit fullscreen mode
  1. Reaching out more people by automatically translating your contents : There are tons of great text translation and language detection apis. Their performance varies depending on the language pair you need.

Image description


import json
import requests

headers = {"Authorization": "Bearer ๐Ÿ”‘ Your_API_Key"}

url ="https://api.edenai.run/v2/translation/automatic_translation"
payload={"providers": "google,deepl", 
         "source_language":"en", 
         "target_language":"fr", 
         "text": "This is a new test."}

response = requests.post(url, json=payload, headers=headers)

result = json.loads(response.text)
print(result['google']['text'])
print(result['deepl']['text'])

Enter fullscreen mode Exit fullscreen mode
  1. Analyze users' feedback and concerns by (semantically) understanding textual content : text classification, extracting key concepts, and understanding the writerโ€™s sentiment . Natural language analysis can have tons of other applications.

Image description

import json
import requests

headers = {"Authorization": "Bearer ๐Ÿ”‘ Your_API_Key"}

url ="https://api.edenai.run/v2/text/sentiment_analysis"
payload={"providers": "emvista,microsoft", 
        'language': "en", 
        'text': "this is a great test"}

response = requests.post(url, json=payload, headers=headers)

result = json.loads(response.text)
print(result['emvista']['items'])
print(result['microsoft']['items'])


Enter fullscreen mode Exit fullscreen mode
  1. Images and videos tagging and classification : for easier storage and retrieval.

Image description


import json
import requests

headers = {"Authorization": "Bearer ๐Ÿ”‘ Your_API_Key"}

url = "https://api.edenai.run/v2/image/object_detection"                 
data={"providers": "clarifai,amazon"}
files = {'file': open("๐Ÿ–ผ๏ธ path/to/your/image.png",'rb')}

response = requests.post(url, data=data, files=files, headers=headers)
result = json.loads(response.text)
print(result['clarifai']['items'])
print(result['amazon']['items'])

Enter fullscreen mode Exit fullscreen mode
  1. Content moderation : You can detect explicit content present in an image or a video, detect racist messages or insults in a given text.

Image description

import json
import requests

headers = {"Authorization": "Bearer ๐Ÿ”‘ Your_API_Key"}

url=" https://api.edenai.run/v2/image/explicit_content"
data={"providers": "picpurify,microsoft"}
files = {'file': open("๐Ÿ–ผ๏ธ path/to/your/image.png",'rb')}

response = requests.post(url, data=data, files=files, headers=headers)

result = json.loads(response.text)
print(result['picpurify']['items'])
print(result['microsoft']['items'])

Enter fullscreen mode Exit fullscreen mode
  1. Data anonymization : You can remove Personally identifiable information (PII) information from a text before making it public. Same thing with an image by blurring faces and license plates for example.

Image description


import json
import requests

headers = {"Authorization": "Bearer ๐Ÿ”‘ Your_API_Key"}

url ="https://api.edenai.run/v2/text/anonymization"
payload={"providers": "openai", 
         "language": "en", "text": "My name is Jeremy and this is a test"}

response = requests.post(url, json=payload, headers=headers)

result = json.loads(response.text)
print(result['openai']['result'])

Enter fullscreen mode Exit fullscreen mode
  1. Work with audio content : You can easily transform an audio or a microphone input to a text and analyze it's content. The inverse would be text to speech which gives your app a voice to interact in new ways with your users.

Image description

Conclusion :

As said earlier, there are tons of companies producing new APIs each day. You can find a great variety of performances at different prices. So, at Eden AI, we want to give access to all the power of AI through one standardized API. One interface for you not to bother about how to access intelligence, and only focus on inventing great apps out of it !

Top comments (2)

Collapse
 
samyme profile image
SamyMe

I'm moving all my writing to medium : medium.com/@samy_89073/

Collapse
 
samyme profile image
SamyMe

My next article on OpenAI's GPT3 : dev.to/samyme/openai-gpt-for-webde...