Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained("distilgpt2")
|
| 6 |
+
model = AutoModelForCausalLM.from_pretrained("distilgpt2")
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
gen_pipeline = pipeline(task = "text-generation", model=model, tokenizer=tokenizer)
|
| 10 |
+
get_generated_text = lambda x: gen_pipeline(x)[0]['generated_text']
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
demo = gr.Interface(
|
| 14 |
+
inputs = gr.TextBox(label = 'Enter A series of Text and Generate more',lines = 2),
|
| 15 |
+
outputs = get_generated_text,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
demo.launch()
|