Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,13 @@
|
|
| 1 |
-
from
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
file1 = client.predict(fn_index=6)
|
| 9 |
-
# Send a "start" message to begin the conversation
|
| 10 |
-
result = client.predict("start", file1, fn_index=0)
|
| 11 |
-
conversation_id = result[1]
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
message = input("You: ")
|
| 16 |
-
result = client.predict(message, conversation_id, fn_index=2)
|
| 17 |
-
print("Bot:", open(result[1],'r').read())
|
|
|
|
| 1 |
+
from transformers import GPT2Tokenizer, GPT2Model
|
| 2 |
+
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
|
| 3 |
+
model = GPT2Model.from_pretrained('gpt2')
|
| 4 |
+
import gradio as gr
|
| 5 |
|
| 6 |
+
def gpt2(string):
|
| 7 |
+
text = string
|
| 8 |
+
encoded_input = tokenizer(text, return_tensors='pt')
|
| 9 |
+
output = model(**encoded_input)
|
| 10 |
+
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
iface = gr.Interface(fn=gpt2, inputs="text", outputs="text")
|
| 13 |
+
iface.launch()
|
|
|
|
|
|
|
|
|