lachine commited on
Commit
d335d6f
1 Parent(s): 5bd8055

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -2
app.py CHANGED
@@ -1,2 +1,16 @@
1
- from os import system
2
- system('pip install transformers')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()