Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Load your model from
|
| 5 |
-
generator = pipeline(
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
#
|
| 8 |
def generate_inspiration(age, profession, archetype):
|
| 9 |
prompt = f"Age: {age} | Profession: {profession} | Archetype: {archetype}"
|
| 10 |
-
result = generator(prompt, max_new_tokens=100)
|
| 11 |
-
return result
|
| 12 |
|
| 13 |
-
# Gradio interface
|
| 14 |
iface = gr.Interface(
|
| 15 |
fn=generate_inspiration,
|
| 16 |
inputs=[
|
|
@@ -20,9 +23,8 @@ iface = gr.Interface(
|
|
| 20 |
],
|
| 21 |
outputs=gr.Textbox(label="Inspirational Message"),
|
| 22 |
title="Inspiration Message Generator",
|
| 23 |
-
description="
|
| 24 |
)
|
| 25 |
|
| 26 |
-
# Run the app
|
| 27 |
iface.launch()
|
| 28 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load your fine-tuned model from Hugging Face Hub
|
| 5 |
+
generator = pipeline(
|
| 6 |
+
"text2text-generation",
|
| 7 |
+
model="DetectiveShadow/inspiration-message-generator" # ← your model name
|
| 8 |
+
)
|
| 9 |
|
| 10 |
+
# Function to create the input prompt and get the message
|
| 11 |
def generate_inspiration(age, profession, archetype):
|
| 12 |
prompt = f"Age: {age} | Profession: {profession} | Archetype: {archetype}"
|
| 13 |
+
result = generator(prompt, max_new_tokens=100)
|
| 14 |
+
return result[0]["generated_text"]
|
| 15 |
|
| 16 |
+
# Gradio interface
|
| 17 |
iface = gr.Interface(
|
| 18 |
fn=generate_inspiration,
|
| 19 |
inputs=[
|
|
|
|
| 23 |
],
|
| 24 |
outputs=gr.Textbox(label="Inspirational Message"),
|
| 25 |
title="Inspiration Message Generator",
|
| 26 |
+
description="Get a personalized motivational message based on your age, profession, and life archetype."
|
| 27 |
)
|
| 28 |
|
|
|
|
| 29 |
iface.launch()
|
| 30 |
|