Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,2 +1,16 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
text_generator = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
|
| 4 |
+
|
| 5 |
+
def generate_text(prompt, quality):
|
| 6 |
+
length_dict = {"Low": 25, "Medium (Default)": 50, "High": 100}
|
| 7 |
+
length = length_dict[quality]
|
| 8 |
+
return text_generator(prompt, max_length=length, do_sample=True)[0]['generated_text']
|
| 9 |
+
|
| 10 |
+
iface = gr.Interface(
|
| 11 |
+
fn=generate_text,
|
| 12 |
+
inputs=["textbox", gr.inputs.Dropdown(["Low", "Medium (Default)", "High"], label="Quality")],
|
| 13 |
+
outputs=gr.outputs.Image(label="Generated image:")
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
iface.launch()
|