Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
from diffusers import DiffusionPipeline
|
| 4 |
|
| 5 |
-
# Load model
|
| 6 |
-
|
| 7 |
-
"stabilityai/stable-diffusion-xl-base-1.0",
|
| 8 |
-
torch_dtype=torch.float16,
|
| 9 |
-
variant="fp16",
|
| 10 |
-
use_safetensors=True
|
| 11 |
-
).to("cuda")
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
description="This demo uses Stable Diffusion XL with custom LoRA weights to generate images from your prompts."
|
| 28 |
)
|
| 29 |
|
| 30 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
|
|
|
| 3 |
|
| 4 |
+
# Load the model from the hub
|
| 5 |
+
generator = pipeline("text2text-generation", model="DetectiveShadow/inspiration-message-generator")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
def generate_message(age, profession, archetype):
|
| 8 |
+
prompt = f"Age: {age} | Profession: {profession} | Archetype: {archetype}"
|
| 9 |
+
result = generator(prompt, max_new_tokens=100)[0]["generated_text"]
|
| 10 |
+
return result
|
| 11 |
|
| 12 |
+
# Gradio interface
|
| 13 |
+
iface = gr.Interface(
|
| 14 |
+
fn=generate_message,
|
| 15 |
+
inputs=[
|
| 16 |
+
gr.Textbox(label="Age"),
|
| 17 |
+
gr.Textbox(label="Profession"),
|
| 18 |
+
gr.Textbox(label="Archetype")
|
| 19 |
+
],
|
| 20 |
+
outputs="text",
|
| 21 |
+
title="Inspiration Message Generator",
|
| 22 |
+
description="Enter age, profession, and archetype to get a personalized inspirational message."
|
|
|
|
| 23 |
)
|
| 24 |
|
| 25 |
+
iface.launch()
|