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