Upload app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,30 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
pipe = pipeline(
|
5 |
+
"text-generation",
|
6 |
+
model="Ar4ikov/gpt2-650k-stable-diffusion-prompt-generator",
|
7 |
+
tokenizer="gpt2"
|
8 |
+
)
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
def generate_text(prompt):
|
13 |
+
return pipe(prompt, max_length=77)[0]["generated_text"]
|
14 |
+
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=generate_text,
|
17 |
+
|
18 |
+
#input is a text box
|
19 |
+
inputs=gr.Textbox(lines=5, label="Prompt"),
|
20 |
+
|
21 |
+
|
22 |
+
# output is a text box with copy button
|
23 |
+
outputs=gr.Textbox(label="Output", show_copy_button=True),
|
24 |
+
|
25 |
+
title="GPT-2 650k Stable Diffusion Prompt Generator",
|
26 |
+
description="GPT-2 650k Stable Diffusion Prompt Generator",
|
27 |
+
api_name="predict"
|
28 |
+
)
|
29 |
+
|
30 |
+
iface.launch(show_api=True)
|