micole66 commited on
Commit
5fdc050
1 Parent(s): 5b948f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -28
app.py CHANGED
@@ -1,29 +1,12 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Importing Dependancies
4
-
5
  import gradio as gr
6
- from transformers import pipeline
7
-
8
- """# Loading Model Name"""
9
-
10
- model_name = "deepset/roberta-base-squad2"
11
-
12
- """# Get Predictions
13
- """
14
-
15
- nlu = pipeline('question-answering', model=model_name, tokenizer=model_name)
16
-
17
- def func(context, question):
18
- input = {
19
- 'question':question,
20
- 'context':context
21
- }
22
- res = nlu(input)
23
- return res["answer", "score"]
24
-
25
- descr = "This is a question and Answer Web app, you give it a context and ask it questions based on the context provided"
26
-
27
- app = gr.Interface(fn=func, inputs=[gr.inputs.Textbox(lines=3, placeholder="put in your context here..."),"text"], outputs="text", score=score, title="Question Answer App", description=descr)
28
-
29
- app.launch()
 
 
 
 
 
1
  import gradio as gr
2
+ description = "Question Answering Demo 🙌🏼"
3
+ title = "Question Answering with Keras"
4
+ context = "Keras is an API designed for human beings, not machines. Keras follows best practices for reducing cognitive load: it offers consistent & simple APIs, it minimizes the number of user actions required for common use cases, and it provides clear & actionable error messages. It also has extensive documentation and developer guides. See the model here: hf.co/keras-io/transformers-qa"
5
+ question = "What is Keras?"
6
+ interface = gr.Interface.load("huggingface/deepset/xlm-roberta-large-squad2",
7
+ description=description,
8
+ title = title,
9
+ theme = "grass",
10
+ examples = [[context, question]]
11
+ )
12
+ interface.launch()