Getting Started with the Roboflow Inference API

Roboflow · Beginner ·👁️ Computer Vision ·5y ago

Key Takeaways

The Roboflow Inference API is used for making inferences on test images, specifically object detection endpoints, and can be implemented in various programming languages such as Python, JavaScript, and Bash with curl.

Full Transcript

[Music] [Music] oh hey there i'm just using the roboflow inference api to make inferences on my test images this youtube is designed to kind of take apart the roboflow imprints api so you can use it to implement computer vision specifically object detection endpoints into your own application so today we're going to walk through the nuances of the roboflow infrareds api that is all the request parameters and how you can use the rover inference api in your own application so today we're going to be walking through a tutorial in python here but we're also going to talk about using the inference api through bash command with curl and we're also going to talk about using it in a javascript app and the good thing is that all the parameters that go into the api are all universal across these languages so no matter which language you're going to be using the inference api in this tutorial should be relevant to you so kind of diving in what exactly are we trying to do with difference api so when you train a computer vision model you get a model that can then make inference but this model can sometimes be heavy it can be difficult to port into the destinations you want to so you might just want to have it hosted on a cloud instance and be able to post your image up to a cloud instance receive the inferences back and then go do what you want with them in your application which app without having to build all kinds of uh heavy dependencies around your models in the application that you're developing so the rover inference api was built with this uh with this mission in mind so today i have a model that's been trained in a mushroom data set so here you can see this is a data set of mushrooms we have various mushrooms tagged here so we have chicken of the woods and we have chanterelles and these have all been labeled and then trained and this is how you train uh custom models is just by feeding custom data in and then printing a model based on the data that you fed it um so this is a mushroom's endpoint that we have here but this could be any use case that you want and perhaps by the time you've gotten to this video you've already trained a few models and you already have them ready for use so um let's kind of dive into the inference api documentation so this is that docsetrofl.com backslash inference and here you can see the different things you can do with the inference api so you can use a curl command or you can use these examples that we have here at the bottom for python javascript perl and then we also have other languages available at request so basically the api has a few parameters so it has the image which is obviously a key thing to be setting up and that's going to be a base64 encoded string and then we have the name the endpoint we have your um access token um which is the token that is going to go in um and will be um basically authenticated um to know that you have rights to access the api and then we have a few other parameters that we'll explore in the um use case here that are also things that you can do to affect the way the boxes are coming back and the way they look and and uh things like that so let's go and dive into our example here so this mushrooms data set i've ported it into our notebook here with a query string so these are just um these are just example images that we're going to be able to pass into the inference api so you put your token in here if you're using this example and then this is just python code to define the url that we're going to be passing to so uh you put the url where the um the inferred.roboflow.com is and then you put your endpoint and then you put an access token so the access token authenticates to the endpoint and then you can choose these parameters that i've defined here so format is either you can get an image back with a box drawn on it this is useful just for testing out uh the inference api but you can also put in a json so when you build into an application you're probably going to be put in format equals json and then you can also define confidence here so confidence is uh basically like lower confidence the more boxes you're going to get back and the higher the confidence the more of a threshold you're going to be putting on your model to basically be requiring it to have higher confidence in order to make predictions and then stroke is just the stroke side so if you put a higher stroke size the high the more width is going to be drawn around the box and then all those parameters are combined into a query string which is going to be the url that we're going to be posting to so let's take an example image here that we might want to use so this is a picture of a chanterelle and we're going to see if the model is able to identify chanterelle or if it's going to be able to tell where the chanterelle is in the image uh so in order to do so we can take that image here then we open it with pill and then we convert it into a base64 encoded string and we put that base64 encoded string up to a post request to the url that we've defined and then we'll get some content back and then in order to view it since we specified image up above we're going to get a base64 encoded string back so we're going to decode that and then we'll see the output here so at the beginning of the video you kind of saw me make this inference already so it's no surprise that it's going to work but you can see here that the inference api has correctly identified the mushroom so the other thing i want to show you guys here is what it looks like if you specify json here and we can go ahead and make the inference again except this time we're going to be rather than getting a basic sort encoded string back we're going to be getting um a json back so rather than doing r.content for response that content we're going to do response.json and we won't need this stuff since we won't be printing out the string anymore okay so there we go we have the json method but we actually need to call it as a method um so here you can see what happens when you get the json back is you'll rather you'll just get definitions of the coordinates so this is the x y and width height so the x y is the middle of the image and then you'll get the width and height of the image there and you'll get the class back so it correctly identified this image as chanterelle and then you also get a confidence value back here so that confidence is 0.6 so if we had specifies a confidence parameter that was higher than 0.6 we wouldn't have gotten anything back here for predictions but that's basically the ins and outs of the rebelflow inference api again here this is a python example but all the parameters are the same if you want to do a curl command here you can use this base64 encode your image and then just type that into the curl command to post the url and then javascript is going to look very similar and again all of those details are on the docs for on the docs.roboflow.com backslash inference if you're excited about using the inference api please let us know and thanks again for watching this video and we'll see you in the next video thanks

Original Description

An example of leveraging cloud inference to host your object detection models. Docs: https://docs.roboflow.com/inference Notebook: https://colab.research.google.com/drive/1C81qr1ejBRIG6lVKOg9z6EXJ_lkjyIxJ
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Roboflow · Roboflow · 59 of 60

1 YOLOv3 PyTorch Notebook Tutorial
YOLOv3 PyTorch Notebook Tutorial
Roboflow
2 How to Train YOLOv4 on a Custom Dataset (PyTorch)
How to Train YOLOv4 on a Custom Dataset (PyTorch)
Roboflow
3 How to Train YOLOv5 on a Custom Dataset
How to Train YOLOv5 on a Custom Dataset
Roboflow
4 How to Use the Roboflow Dataset Health Check
How to Use the Roboflow Dataset Health Check
Roboflow
5 What is Mean Average Precision (mAP)?
What is Mean Average Precision (mAP)?
Roboflow
6 How to Use the Roboflow Model Library
How to Use the Roboflow Model Library
Roboflow
7 How to Train EfficientDet in TensorFlow 2 Object Detection
How to Train EfficientDet in TensorFlow 2 Object Detection
Roboflow
8 How to Train YOLO v4 Tiny (Darknet) on a Custom Dataset
How to Train YOLO v4 Tiny (Darknet) on a Custom Dataset
Roboflow
9 Ask the Roboflow Team Anything - Episode 1
Ask the Roboflow Team Anything - Episode 1
Roboflow
10 Exploring The COCO Dataset
Exploring The COCO Dataset
Roboflow
11 Community Spotlight: Improving Uno with Computer Vision
Community Spotlight: Improving Uno with Computer Vision
Roboflow
12 Mosaic Data Augmentation - Deep Dive
Mosaic Data Augmentation - Deep Dive
Roboflow
13 Hands on with the OAK-1
Hands on with the OAK-1
Roboflow
14 Glenn Jocher: What is New in YOLO v5?
Glenn Jocher: What is New in YOLO v5?
Roboflow
15 How to Use Amazon Rekognition Custom Labels and Roboflow to Build an Object Detection Model
How to Use Amazon Rekognition Custom Labels and Roboflow to Build an Object Detection Model
Roboflow
16 An Interview with Brandon Gilles, Luxonis Founder and OAK Chief Architect
An Interview with Brandon Gilles, Luxonis Founder and OAK Chief Architect
Roboflow
17 How to Train a Custom Mobile Object Detection Model (with YOLOv4 Tiny and TensorFlow Lite)
How to Train a Custom Mobile Object Detection Model (with YOLOv4 Tiny and TensorFlow Lite)
Roboflow
18 Tackling the Small Object Problem in Object Detection
Tackling the Small Object Problem in Object Detection
Roboflow
19 Fast.ai v2 Released - What's New?
Fast.ai v2 Released - What's New?
Roboflow
20 Teaser: Roboflow Train (1-Click Computer Vision AutoML)
Teaser: Roboflow Train (1-Click Computer Vision AutoML)
Roboflow
21 How to Train a Custom Resnet34 Image Classification Model
How to Train a Custom Resnet34 Image Classification Model
Roboflow
22 How to Label Images for Object Detection with CVAT
How to Label Images for Object Detection with CVAT
Roboflow
23 Deploy YOLOv5 to Jetson Xavier NX at 30 FPS
Deploy YOLOv5 to Jetson Xavier NX at 30 FPS
Roboflow
24 Elisha Odemakinde Hosts Roboflow ML Engineer, Jacob Solawetz
Elisha Odemakinde Hosts Roboflow ML Engineer, Jacob Solawetz
Roboflow
25 Getting Started with VoTT - Computer Vision Annotation
Getting Started with VoTT - Computer Vision Annotation
Roboflow
26 How to Manage Classes in Object Detection (Rename, Combine, Balance)
How to Manage Classes in Object Detection (Rename, Combine, Balance)
Roboflow
27 How to Train YOLOv4 on a Custom Dataset in Darknet
How to Train YOLOv4 on a Custom Dataset in Darknet
Roboflow
28 Is Grayscale a Preprocessing or Augmentation Step in Computer Vision?
Is Grayscale a Preprocessing or Augmentation Step in Computer Vision?
Roboflow
29 Getting Started with Image Data Augmentation
Getting Started with Image Data Augmentation
Roboflow
30 Glenn Jocher: Image Augmentation in YOLO v5 and Beyond
Glenn Jocher: Image Augmentation in YOLO v5 and Beyond
Roboflow
31 GA Hosts Roboflow - Healthcare and AI
GA Hosts Roboflow - Healthcare and AI
Roboflow
32 How do self driving cars know when to stop?
How do self driving cars know when to stop?
Roboflow
33 What is PASCAL VOC XML?
What is PASCAL VOC XML?
Roboflow
34 AutoML Showdown: Google vs Amazon vs Microsoft
AutoML Showdown: Google vs Amazon vs Microsoft
Roboflow
35 How is computer vision changing manufacturing?
How is computer vision changing manufacturing?
Roboflow
36 The Alphabet in American Sign Language
The Alphabet in American Sign Language
Roboflow
37 Luxonis OAK-D: Computer Vision on Device
Luxonis OAK-D: Computer Vision on Device
Roboflow
38 How to Train a Custom Faster R-CNN Model with Facebook AI's Detectron2 | Use Your Own Dataset
How to Train a Custom Faster R-CNN Model with Facebook AI's Detectron2 | Use Your Own Dataset
Roboflow
39 TensorFlow vs PyTorch: Fireside
TensorFlow vs PyTorch: Fireside
Roboflow
40 Occlusion Techniques in Computer Vision
Occlusion Techniques in Computer Vision
Roboflow
41 A Customizable Web Application for Your Computer Vision Model
A Customizable Web Application for Your Computer Vision Model
Roboflow
42 Model Tradeoffs and the Future of Computer Vision
Model Tradeoffs and the Future of Computer Vision
Roboflow
43 Designing an Augmented Reality Board Game App
Designing an Augmented Reality Board Game App
Roboflow
44 YOLOv4 - Advanced Tactics
YOLOv4 - Advanced Tactics
Roboflow
45 How to Use CreateML and Build a Computer Vision iPhone App | AR Object Detection
How to Use CreateML and Build a Computer Vision iPhone App | AR Object Detection
Roboflow
46 Fireside Chat: Computer Vision in Agriculture
Fireside Chat: Computer Vision in Agriculture
Roboflow
47 Scaled-YOLOv4 Tops EfficientDet: Research Rundown
Scaled-YOLOv4 Tops EfficientDet: Research Rundown
Roboflow
48 What is Image Preprocessing?
What is Image Preprocessing?
Roboflow
49 Building a Community of Creators with BlkArthouse and Von Deon
Building a Community of Creators with BlkArthouse and Von Deon
Roboflow
50 How to Train Scaled-YOLOv4 to Detect Custom Objects
How to Train Scaled-YOLOv4 to Detect Custom Objects
Roboflow
51 Intro to Computer Vision: Fireside
Intro to Computer Vision: Fireside
Roboflow
52 The Best Way to Annotate Images for Object Detection
The Best Way to Annotate Images for Object Detection
Roboflow
53 The Computer Vision Process: Fireside
The Computer Vision Process: Fireside
Roboflow
54 How to Annotate Images with Your Team Using Roboflow
How to Annotate Images with Your Team Using Roboflow
Roboflow
55 Introducing the Roboflow Object Count Histogram
Introducing the Roboflow Object Count Histogram
Roboflow
56 How Fast is the M1 at Machine Learning? Benchmarking Apple's M1 and Intel's Chips
How Fast is the M1 at Machine Learning? Benchmarking Apple's M1 and Intel's Chips
Roboflow
57 CLIP: OpenAI's amazing new zero-shot image classifier
CLIP: OpenAI's amazing new zero-shot image classifier
Roboflow
58 How I hacked my Nest camera to run custom models
How I hacked my Nest camera to run custom models
Roboflow
Getting Started with the Roboflow Inference API
Getting Started with the Roboflow Inference API
Roboflow
60 Transfer Learning in Computer Vision | What, How, Why
Transfer Learning in Computer Vision | What, How, Why
Roboflow

The Roboflow Inference API is a cloud-based API for making inferences on object detection models, and can be used in various programming languages. This video tutorial walks through the nuances of the API, including request parameters and implementation in Python, JavaScript, and Bash with curl.

Key Takeaways
  1. Train an object detection model using a custom dataset
  2. Convert an image to a base64 encoded string
  3. Make a POST request to the Roboflow Inference API with the image and access token
  4. Specify parameters such as format, confidence, and stroke size
  5. Parse the response from the API, either as an image or JSON
💡 The Roboflow Inference API provides a cloud-based solution for making inferences on object detection models, allowing developers to easily integrate computer vision capabilities into their applications without having to manage heavy dependencies.

Related AI Lessons

Cloud-Optimized OpenCV + A Special Surprise Announcement on OpenCV Live
Learn about Cloud-Optimized OpenCV for faster computer vision computations and a special announcement on OpenCV Live
OpenCV Blog
When the Camera Becomes an Exam Proctor: Building an AI-Powered Exam Monitoring System with…
Learn how to build an AI-powered exam monitoring system using Computer Vision and DeepFace to assist professional certification exams
Medium · Python
When the Camera Becomes an Exam Proctor: Building an AI-Powered Exam Monitoring System with…
Build an AI-powered exam monitoring system using Computer Vision and Deep Learning to enhance professional certification exams
Medium · Deep Learning
When the Camera Becomes an Exam Proctor: Building an AI-Powered Exam Monitoring System with…
Build an AI-powered exam monitoring system using Computer Vision and Deep Learning to enhance exam security and integrity
Medium · Cybersecurity
Up next
Marketing management for ugc net| Important topics of marketing management ugc net commerce dec 2023
Bhoomi Learning Centre~Dr. Muskan
Watch →