Validation Accuracy
62.8%
View Model Graphs

Samples from Test Set

Upload Image

Drop file here or

Paste Image URL

Try On My Machine
0
fps
0
objects detected

Confidence Threshold: 50

0%

100%

Getting Prediction...
Copy
Copied
Roboflow Inference

Inference is Roboflow's open source deployment package for developer-friendly vision inference.

How to Deploy the face emotion1 Classification API

Using Roboflow, you can deploy your classification model to a range of environments, including:

  • Raspberry Pi
  • NVIDIA Jetson
  • A Docker container
  • A web page
  • A Python script using the Roboflow SDK.

Below, we have instructions on how to use our deployment options.

Code Snippets

Hosted API
Python
Javascript
Swift

Infer on Local and Hosted Images

To install dependencies, pip install inference-sdk.

Then, add the following code snippet to a Python script:

from inference_sdk import InferenceHTTPClient

CLIENT = InferenceHTTPClient(
    api_url="https://classify.roboflow.com",
    api_key="API_KEY"
)

result = CLIENT.infer(your_image.jpg, model_id="face-emotion1/1")

See the inference-sdk docs

Node.js

We're using axios to perform the POST request in this example so first run npm install axios to install the dependency.

Inferring on a Local Image

const axios = require("axios");
const fs = require("fs");

const image = fs.readFileSync("YOUR_IMAGE.jpg", {
    encoding: "base64"
});

axios({
    method: "POST",
    url: "https://classify.roboflow.com/face-emotion1/1",
    params: {
        api_key: "API_KEY"
    },
    data: image,
    headers: {
        "Content-Type": "application/x-www-form-urlencoded"
    }
})
    .then(function (response) {
        console.log(response.data);
    })
    .catch(function (error) {
        console.log(error.message);
    });

Uploading a Local Image Using base64

import UIKit

// Load Image and Convert to Base64
let image = UIImage(named: "your-image-path") // path to image to upload ex: image.jpg
let imageData = image?.jpegData(compressionQuality: 1)
let fileContent = imageData?.base64EncodedString()
let postData = fileContent!.data(using: .utf8)

// Initialize Inference Server Request with API_KEY, Model, and Model Version
var request = URLRequest(url: URL(string: "https://classify.roboflow.com/face-emotion1/1?api_key=API_KEY&name=YOUR_IMAGE.jpg")!,timeoutInterval: Double.infinity)
request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData

// Execute Post Request
URLSession.shared.dataTask(with: request, completionHandler: { data, response, error in

    // Parse Response to String
    guard let data = data else {
        print(String(describing: error))
        return
    }

    // Convert Response String to Dictionary
    do {
        let dict = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
    } catch {
        print(error.localizedDescription)
    }

    // Print String Response
    print(String(data: data, encoding: .utf8)!)
}).resume()

Similar Projects

See More
5.1k images 1 model
5.3k images