Karim-Gamal's picture
Update app.py
a75bec5
import gradio as gr
import requests
API_URL = "https://api-inference.huggingface.co/models/Karim-Gamal/switch-base-8-finetuned-SemEval-2018-emojis-cen-2"
headers = {"Authorization": "Bearer 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"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
def sketch_recognition(text):
output_temp = query({
"inputs": text,
})
text_to_emoji = {'red' : '❀', 'face': '😍', 'joy':'πŸ˜‚', 'love':'πŸ’•', 'fire':'πŸ”₯', 'smile':'😊', 'sunglasses':'😎', 'sparkle':'✨', 'blue':'πŸ’™', 'kiss':'😘', 'camera':'πŸ“·', 'USA':'πŸ‡ΊπŸ‡Έ', 'sun':'β˜€' , 'purple':'πŸ’œ', 'blink':'πŸ˜‰', 'hundred':'πŸ’―', 'beam':'😁', 'tree':'πŸŽ„', 'flash':'πŸ“Έ', 'tongue':'😜'}
# Extract the dictionary from the list
d = output_temp[0]
# Extract the text from the 'generated_text' key
text = d['generated_text']
return text_to_emoji[text.split(' ')[0]]
# Split the text into individual words
# pass# Implement your sketch recognition model here...
gr.Interface(fn=sketch_recognition, inputs="text", outputs="text").launch()
# gr.Interface.load("models/Karim-Gamal/switch-base-8-finetuned-SemEval-2018-emojis-cen-1").launch()