Downloads · 30 days
27
19% of all-time downloads
Bombek1/emotion-english-distilroberta-base-litert
emotion-english-distilroberta-base-litert is a machine learning model from Bombek1. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for litert. The card lists the license as apache-2.0.
This is a LiteRT (formerly TensorFlow Lite) export of j-hartmann/emotion-english-distilroberta-base.
Downloads · 30 days
27
19% of all-time downloads
All-time downloads
142
Public
Repo size
329 MB
Likes
0
Public
Click a slice to open those files.
.tflite329 MB · 100%
From the Hugging Face model README
This is a LiteRT (formerly TensorFlow Lite) export of j-hartmann/emotion-english-distilroberta-base.
It is optimized for mobile and edge inference (Android/iOS/Embedded).
| Attribute | Value |
|---|---|
| Task | Emotion Detection |
| Format | .tflite (Float32) |
| File Size | 313.6 MB |
| Input Length | 128 tokens |
| Output Dim | 7 |
import numpy as np
from ai_edge_litert.interpreter import Interpreter
from transformers import AutoTokenizer
model_path = "j-hartmann_emotion-english-distilroberta-base.tflite"
interpreter = Interpreter(model_path=model_path)
interpreter.allocate_tensors()
tokenizer = AutoTokenizer.from_pretrained("j-hartmann/emotion-english-distilroberta-base")
labels = ["anger", "disgust", "fear", "joy", "neutral", "sadness", "surprise"]
def predict(text):
# Tokenize
inputs = tokenizer(text, max_length=128, padding="max_length", truncation=True, return_tensors="np")
# Set inputs
input_details = interpreter.get_input_details()
interpreter.set_tensor(input_details[0]['index'], inputs['input_ids'].astype(np.int64))
interpreter.set_tensor(input_details[1]['index'], inputs['attention_mask'].astype(np.int64))
# Run inference
interpreter.invoke()
# Get output (Logits)
output_details = interpreter.get_output_details()
logits = interpreter.get_tensor(output_details[0]['index'])[0]
# Softmax to get probabilities
probs = np.exp(logits) / np.sum(np.exp(logits))
# Get top label
top_idx = np.argmax(probs)
return labels[top_idx], probs[top_idx]
label, confidence = predict("This is amazing!")
print(f"Result: {label} ({confidence:.2f})")
Converted by Bombek1 using litert-torch