YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

import json import numpy as np import tensorflow as tf from huggingface_hub import hf_hub_download

model_path = hf_hub_download(repo_id="rahat-dev/airline-sentiment-lstm", filename="lstm_sentiment.keras") vocab_path = hf_hub_download(repo_id="rahat-dev/airline-sentiment-lstm", filename="vocab.json")

model = tf.keras.models.load_model(model_path) vocab = json.loads(open(vocab_path).read())

CLASS_NAMES = ["negative", "neutral", "positive"] MAX_LEN = vocab["max_sequence_length"] token_to_id = vocab["token_to_id"]

def encode(text: str) -> np.ndarray: tokens = text.lower().split() ids = [token_to_id.get(t, token_to_id[""]) for t in tokens][:MAX_LEN] ids += [token_to_id[""]] * (MAX_LEN - len(ids)) return np.array([ids])

text = "My flight was delayed 6 hours and nobody explained why." probs = model.predict(encode(text), verbose=0)[0] predicted = CLASS_NAMES[int(np.argmax(probs))] print(predicted, dict(zip(CLASS_NAMES, probs.round(3))))

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support