Spaces:
Build error
Build error
Commit
·
6ada24f
1
Parent(s):
ade1e2f
Fixes: UserWarning: gr.Intrerface.load() will be deprecated.
Browse files
app.py
CHANGED
@@ -1,17 +1,29 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
# Load the
|
4 |
-
question_gen = gr.
|
5 |
|
6 |
-
# Define
|
7 |
-
text =
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
#
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
output = question_gen.predict(text)
|
14 |
-
questions.append(output["generated_text"])
|
15 |
|
16 |
-
#
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|