Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
from transformers import AutoModel, AutoTokenizer
|
4 |
+
from transformers import TextGenerationPipeline
|
5 |
+
|
6 |
+
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained("Sigurdur/icebreaker")
|
8 |
+
model = AutoModel.from_pretrained("Sigurdur/icebreaker")
|
9 |
+
pipeline = TextGenerationPipeline(model=model, tokenizer=tokenizer)
|
10 |
+
|
11 |
+
def generate_text(inp):
|
12 |
+
generated_text = pipeline(inp)
|
13 |
+
|
14 |
+
output = generated_text[0]["generated_text"]
|
15 |
+
return output
|
16 |
+
|
17 |
+
output_text = gr.outputs.Textbox()
|
18 |
+
gr.Interface(generate_text,"textbox",output_text,title="Text Generation machine ",description="Ask any question. Note: It can take 20-60 seconds to generate output based on your internet connection.").launch()
|