Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
|
|
3 |
|
4 |
-
pipe = pipeline(
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
-
return {
|
11 |
-
len(dot_split) < len(n_split): dot_split,
|
12 |
-
len(n_split) > len(dot_split): n_split,
|
13 |
-
len(n_split) == len(dot_split): dot_split
|
14 |
-
}[True]
|
15 |
|
16 |
-
def
|
17 |
-
|
18 |
-
return valid_prompt
|
19 |
|
20 |
iface = gr.Interface(
|
21 |
-
fn=
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
)
|
27 |
|
28 |
-
iface.launch()
|
|
|
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="GPT-2 650k Stable Diffusion Prompt Generator",
|
27 |
+
description="GPT-2 650k Stable Diffusion Prompt Generator",
|
28 |
+
api_name="predict"
|
29 |
)
|
30 |
|
31 |
+
iface.launch(show_api=True)
|