Spaces:
Sleeping
Sleeping
Leo Trieu
commited on
Commit
·
b0324cd
1
Parent(s):
568109a
Initialize app
Browse files- app.py +17 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
text_generator = pipeline(task="text-generation")
|
| 5 |
+
|
| 6 |
+
def generate_text(prompt):
|
| 7 |
+
output = text_generator(prompt, max_length=100, num_return_sequences=1)
|
| 8 |
+
return output[0]["generated_text"]
|
| 9 |
+
|
| 10 |
+
iface = gr.Interface(
|
| 11 |
+
fn=generate_text,
|
| 12 |
+
inputs="textbox",
|
| 13 |
+
outputs="label",
|
| 14 |
+
title="Text Generator"
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==4.27.0
|
| 2 |
+
transformers==4.40.0
|
| 3 |
+
torch==2.2.2
|