Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ out=grad.Textbox(lines=1, label="Generated Tensors")
|
|
47 |
grad.Interface(generate, inputs=txt, outputs=out).launch()
|
48 |
'''
|
49 |
|
50 |
-
|
51 |
from transformers import GPT2LMHeadModel,GPT2Tokenizer
|
52 |
import gradio as grad
|
53 |
|
@@ -67,3 +67,27 @@ def generate(starting_text):
|
|
67 |
txt=grad.Textbox(lines=1, label="English", placeholder="English Text here")
|
68 |
out=grad.Textbox(lines=1, label="Generated Tensors")
|
69 |
grad.Interface(generate, inputs=txt, outputs=out).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
grad.Interface(generate, inputs=txt, outputs=out).launch()
|
48 |
'''
|
49 |
|
50 |
+
'''5.12
|
51 |
from transformers import GPT2LMHeadModel,GPT2Tokenizer
|
52 |
import gradio as grad
|
53 |
|
|
|
67 |
txt=grad.Textbox(lines=1, label="English", placeholder="English Text here")
|
68 |
out=grad.Textbox(lines=1, label="Generated Tensors")
|
69 |
grad.Interface(generate, inputs=txt, outputs=out).launch()
|
70 |
+
'''
|
71 |
+
|
72 |
+
#5.20
|
73 |
+
from transformers import AutoModelWithLMHead, AutoTokenizer
|
74 |
+
import gradio as grad
|
75 |
+
|
76 |
+
text2text_tkn = AutoTokenizer.from_pretrained("mrm8488/t5-base-finetuned-question-generation-ap")
|
77 |
+
mdl = AutoModelWithLMHead.from_pretrained("mrm8488/t5-base-finetuned-question-generation-ap")
|
78 |
+
|
79 |
+
def text2text(context,answer):
|
80 |
+
input_text = "answer: %s context: %s </s>" % (answer, context)
|
81 |
+
features = text2text_tkn ([input_text], return_tensors='pt')
|
82 |
+
|
83 |
+
output = mdl.generate(input_ids=features['input_ids'],
|
84 |
+
attention_mask=features['attention_mask'],
|
85 |
+
max_length=64)
|
86 |
+
|
87 |
+
response=text2text_tkn.decode(output[0])
|
88 |
+
return response
|
89 |
+
|
90 |
+
context=grad.Textbox(lines=10, label="English", placeholder="Context")
|
91 |
+
ans=grad.Textbox(lines=1, label="Answer")
|
92 |
+
out=grad.Textbox(lines=1, label="Genereated Question")
|
93 |
+
grad.Interface(text2text, inputs=[context,ans], outputs=out).launch()
|