currentlyexhausted commited on
Commit
6ada24f
·
1 Parent(s): ade1e2f

Fixes: UserWarning: gr.Intrerface.load() will be deprecated.

Browse files
Files changed (1) hide show
  1. app.py +24 -12
app.py CHANGED
@@ -1,17 +1,29 @@
1
  import gradio as gr
2
 
3
- # Load the interface
4
- question_gen = gr.Interface.load("models/allenai/t5-small-squad2-question-generation")
5
 
6
- # Define the input text
7
- text = "The quick brown fox jumps over the lazy dog."
 
 
 
 
 
8
 
9
- # Generate multiple questions
10
- num_questions = 5
11
- questions = []
12
- for i in range(num_questions):
13
- output = question_gen.predict(text)
14
- questions.append(output["generated_text"])
15
 
16
- # Print the questions
17
- print(questions)
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ # Load the question generation model
4
+ question_gen = gr.load("models/allenai/t5-small-squad2-question-generation")
5
 
6
+ # Define a function to generate questions
7
+ def generate_questions(text, num_questions=5):
8
+ questions = []
9
+ for i in range(num_questions):
10
+ output = question_gen.predict(text)
11
+ questions.append(output["generated_text"])
12
+ return questions
13
 
14
+ # Define the input and output interfaces
15
+ input_text = gr.inputs.Textbox(label="Enter some text:")
16
+ num_questions = gr.inputs.Number(default=5, label="Number of questions to generate:")
17
+ output_text = gr.outputs.Textbox(label="Generated questions:")
 
 
18
 
19
+ # Create the interface
20
+ iface = gr.Interface(
21
+ generate_questions,
22
+ inputs=[input_text, num_questions],
23
+ outputs=output_text,
24
+ title="Question Generator",
25
+ description="Generate questions from text using the T5-SQuAD2 model.",
26
+ )
27
+
28
+ # Launch the interface
29
+ iface.launch()