Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,27 @@
|
|
1 |
-
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import gradio as grad
|
3 |
-
|
4 |
-
|
5 |
-
mdl_name = "distilbert-base-cased-distilled-squad"
|
6 |
-
my_pipeline = pipeline('question-answering', model=mdl_name, tokenizer=mdl_name)
|
7 |
|
8 |
-
def
|
9 |
-
text= "{"+"'question': '"+question+"','context': '"+context+"'}"
|
10 |
|
11 |
-
|
12 |
-
response = my_pipeline(di)
|
13 |
return response
|
14 |
-
grad.Interface(
|
15 |
-
|
16 |
|
17 |
|
|
|
1 |
+
# from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
|
2 |
+
# import gradio as grad
|
3 |
+
# import ast
|
4 |
+
# # mdl_name = "deepset/roberta-base-squad2"
|
5 |
+
# mdl_name = "distilbert-base-cased-distilled-squad"
|
6 |
+
# my_pipeline = pipeline('question-answering', model=mdl_name, tokenizer=mdl_name)
|
7 |
+
|
8 |
+
# def answer_question(question,context):
|
9 |
+
# text= "{"+"'question': '"+question+"','context': '"+context+"'}"
|
10 |
+
|
11 |
+
# di=ast.literal_eval(text)
|
12 |
+
# response = my_pipeline(di)
|
13 |
+
# return response
|
14 |
+
# grad.Interface(answer_question, inputs=["text","text"], outputs="text").launch()
|
15 |
+
|
16 |
+
from transformers import pipeline
|
17 |
import gradio as grad
|
18 |
+
mdl_name = "Helsinki-NLP/opus-mt-en-de"
|
19 |
+
opus_translator = pipeline("translation", model=mdl_name)
|
|
|
|
|
20 |
|
21 |
+
def translate(text):
|
|
|
22 |
|
23 |
+
response = opus_translator(text)
|
|
|
24 |
return response
|
25 |
+
grad.Interface(translate, inputs=["text",], outputs="text").launch()
|
|
|
26 |
|
27 |
|