Spaces:
Sleeping
Sleeping
arjunascagnetto
commited on
Commit
•
920c384
1
Parent(s):
f85e23b
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,18 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
|
5 |
-
model = GPT2LMHeadModel.from_pretrained("gpt2")
|
6 |
|
7 |
-
def generate_text(
|
8 |
-
|
9 |
-
|
|
|
10 |
|
11 |
-
|
12 |
-
return generated_text
|
13 |
|
14 |
-
|
15 |
-
iface.launch()
|
|
|
1 |
+
|
2 |
+
|
3 |
import gradio as gr
|
4 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
5 |
+
|
6 |
+
|
7 |
+
model = AutoModelForSequenceClassification.from_pretrained("bert-base-uncased")
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
|
9 |
|
|
|
|
|
10 |
|
11 |
+
def generate_text(input_text):
|
12 |
+
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
13 |
+
output = model.generate(input_ids)
|
14 |
+
return tokenizer.decode(output[0], skip_special_tokens=True)
|
15 |
|
16 |
+
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
|
|
17 |
|
18 |
+
interface.launch()
|
|