zoharzaig's picture
updated emoji dataset to be more rich in emojis
6b631cb
import gradio as gr
from model import EmojiPredictor
import os
# Get the base directory (this file's folder)
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
# Relative paths to model + emoji data
MODEL_PATH = "zoharzaig/emoji-prediction-model"
EMOJI_DATA_PATH = os.path.join(BASE_DIR, "generated_emoji_training_data.json")
# Initialize the emoji predictor with relative paths
emoji_predictor = EmojiPredictor(
model_path=MODEL_PATH,
emoji_data_path=EMOJI_DATA_PATH
)
def predict_emoji(text):
"""
Predict emoji for given text
"""
if not text or text.strip() == "":
return "⚠️ Please enter some text"
try:
emoji = emoji_predictor.predict(text.strip())
return emoji
except Exception as e:
return f"❌ Error: {str(e)}"
# Create Gradio interface
iface = gr.Interface(
fn=predict_emoji,
inputs=gr.Textbox(
label="Enter your text",
placeholder="Type something to get emoji predictions...",
lines=3
),
outputs=gr.Textbox(
label="Predicted Emoji",
show_copy_button=True
),
title="🎯 Emoji Predictor",
description="Enter any text and get relevant emoji predictions using AI!",
examples=[
["I'm so happy today!"],
["This weather is terrible"],
["I love pizza and ice cream"],
["Working late again tonight"],
["Can't wait for the weekend"]
],
theme=gr.themes.Soft(),
allow_flagging="never"
)
iface.launch()