King-8's picture
Update app.py
db616c4 verified
import gradio as gr
from transformers import pipeline
# Load your model from the Hub
classifier = pipeline("text-classification", model="King-8/soulprint-classifier", tokenizer="King-8/soulprint-classifier")
# Map labels to Soulprint archetype names
label_map = {
"LABEL_0": "Ayo",
"LABEL_1": "Bisa",
"LABEL_2": "Griot",
"LABEL_3": "Imani",
"LABEL_4": "Jali",
"LABEL_5": "Kinara",
"LABEL_6": "Kuumba",
"LABEL_7": "Maji",
"LABEL_8": "Nzinga",
"LABEL_9": "Sankofa",
"LABEL_10": "Shujaa",
"LABEL_11": "Tamu",
"LABEL_12": "Ubuntu",
"LABEL_13": "Ujamaa",
"LABEL_14": "Zamani"
}
# Archetype descriptions
archetype_descriptions = {
"Ayo": "๐ŸŸก **The Joybringer** โ€” Radiates optimism, joy, and emotional resilience. Ayo uplifts others with positive energy.",
"Bisa": "๐Ÿ’š **The Healer** โ€” Restores balance through compassion and emotional awareness.",
"Griot": "๐Ÿ—ฃ๏ธ **The Storykeeper** โ€” Preserves memory through stories and spoken word. A keeper of ancestral wisdom.",
"Imani": "๐Ÿ•Š๏ธ **The Believer** โ€” Holds firm faith and inspires hope, even in the face of doubt.",
"Jali": "๐ŸŽถ **The Messenger** โ€” Expresses rhythm, movement, and creativity. A voice of cultural transmission.",
"Kinara": "๐Ÿ”ฅ **The Torchbearer** โ€” Illuminates truth and guides others with insight and inner light.",
"Kuumba": "๐ŸŽจ **The Creator** โ€” Fueled by imagination and the desire to build, beautify, and innovate.",
"Maji": "๐Ÿ’ง **The Flowfinder** โ€” Brings peace and spiritual depth through fluidity and calm adaptability.",
"Nzinga": "๐Ÿ›ก๏ธ **The Strategist** โ€” Balances fierce leadership and justice with thoughtful planning.",
"Sankofa": "๐Ÿ”„ **The Returner** โ€” Looks back to move forward, reclaiming wisdom and honoring legacy.",
"Shujaa": "โš”๏ธ **The Warrior** โ€” Stands for courage, strength, and protecting what matters most.",
"Tamu": "๐Ÿฏ **The Nurturer** โ€” Offers sweetness, comfort, and care. Tamu nourishes others emotionally.",
"Ubuntu": "๐ŸŒ **The Unifier** โ€” Believes in our collective humanity. 'I am because we are.'",
"Ujamaa": "๐Ÿ—๏ธ **The Builder** โ€” Supports community through cooperation, equity, and shared progress.",
"Zamani": "โณ **The Timeless One** โ€” Bridges past and future, embracing eternal wisdom and long-range vision."
}
# Prediction function
def predict_soulprint(age, message):
input_text = f"{age} years old: {message}"
output = classifier(input_text)[0]
label = label_map.get(output["label"], output["label"])
score = round(output["score"] * 100, 2)
description = archetype_descriptions.get(label, "_No description available._")
return f"### ๐Ÿงญ {label} ({score}%)\n\n{description}"
# Gradio Interface
iface = gr.Interface(
fn=predict_soulprint,
inputs=[
gr.Number(label="Age"),
gr.Textbox(label="What would this person say?", lines=3, placeholder="Example: I feel called to lead my community with creativity and care.")
],
outputs=gr.Markdown(),
title="Soulprint Archetype Classifier ๐Ÿ”ฎ",
description="Enter a person's age and something they might say. This model will predict their Soulprint archetype based on their message."
)
iface.launch()