Spaces:
Sleeping
Sleeping
| 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() |