Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,30 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
|
|
3 |
import os
|
4 |
os.system("pip install -r requirements.txt")
|
5 |
|
|
|
6 |
pipe = pipeline(
|
7 |
"text-generation",
|
8 |
model="Ar4ikov/gpt2-650k-stable-diffusion-prompt-generator",
|
9 |
tokenizer="gpt2"
|
10 |
)
|
11 |
|
12 |
-
|
13 |
def generate_text(prompt):
|
14 |
return pipe(prompt, max_length=77)[0]["generated_text"]
|
15 |
|
|
|
16 |
iface = gr.Interface(
|
17 |
fn=generate_text,
|
18 |
-
|
19 |
-
#input is a text box
|
20 |
inputs=gr.Textbox(lines=5, label="Prompt"),
|
21 |
-
|
22 |
-
|
23 |
-
# output is a text box with copy button
|
24 |
outputs=gr.Textbox(label="Output", show_copy_button=True),
|
25 |
-
|
26 |
-
title="AI Art Prompt Generator",
|
27 |
description="Art Prompt Generator is a user-friendly interface designed to optimize input for AI Art Generator or Creator. For faster generation speeds, it's recommended to load the model locally with GPUs, as the online demo at Hugging Face Spaces utilizes CPU, resulting in slower processing times.",
|
28 |
api_name="predict"
|
29 |
)
|
30 |
|
31 |
-
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
+
|
4 |
+
# Install required packages
|
5 |
import os
|
6 |
os.system("pip install -r requirements.txt")
|
7 |
|
8 |
+
# Load the pipeline for text generation
|
9 |
pipe = pipeline(
|
10 |
"text-generation",
|
11 |
model="Ar4ikov/gpt2-650k-stable-diffusion-prompt-generator",
|
12 |
tokenizer="gpt2"
|
13 |
)
|
14 |
|
15 |
+
# Function to generate text based on input prompt
|
16 |
def generate_text(prompt):
|
17 |
return pipe(prompt, max_length=77)[0]["generated_text"]
|
18 |
|
19 |
+
# Create a Gradio interface
|
20 |
iface = gr.Interface(
|
21 |
fn=generate_text,
|
|
|
|
|
22 |
inputs=gr.Textbox(lines=5, label="Prompt"),
|
|
|
|
|
|
|
23 |
outputs=gr.Textbox(label="Output", show_copy_button=True),
|
24 |
+
title="<span style='background-image: linear-gradient(to right, #ff7e5f, #feb47b, #ffdb93, #fffbac); -webkit-background-clip: text; -webkit-text-fill-color: transparent;'><center>AI Art Prompt Generator</center></span>",
|
|
|
25 |
description="Art Prompt Generator is a user-friendly interface designed to optimize input for AI Art Generator or Creator. For faster generation speeds, it's recommended to load the model locally with GPUs, as the online demo at Hugging Face Spaces utilizes CPU, resulting in slower processing times.",
|
26 |
api_name="predict"
|
27 |
)
|
28 |
|
29 |
+
# Launch the interface
|
30 |
+
iface.launch(show_api=True)
|