Update app.py
Browse files
app.py
CHANGED
@@ -85,32 +85,32 @@ def caption_question_interface(image):
|
|
85 |
words = caption.split()
|
86 |
# Generate questions for the first word
|
87 |
if len(words) > 0:
|
88 |
-
|
89 |
-
question = generate_questions(caption,
|
90 |
-
|
91 |
# Generate questions for the second word
|
92 |
if len(words) > 1:
|
93 |
-
|
94 |
-
question = generate_questions(caption,
|
95 |
-
|
96 |
# Generate questions for the second word + first word
|
97 |
if len(words) > 1:
|
98 |
-
|
99 |
-
question = generate_questions(caption,
|
100 |
-
|
101 |
# Generate questions for the third word
|
102 |
if len(words) > 2:
|
103 |
-
|
104 |
-
question = generate_questions(caption,
|
105 |
-
|
106 |
# Generate questions for the fourth word
|
107 |
if len(words) > 3:
|
108 |
-
|
109 |
-
question = generate_questions(caption,
|
110 |
-
questions_with_answers.extend([(q,
|
111 |
|
112 |
# Format questions with answers
|
113 |
-
formatted_questions = [f"Question: {q}\nKeyword: {a}" for q, a in
|
114 |
formatted_questions = "\n".join(formatted_questions)
|
115 |
|
116 |
# Return the generated captions and formatted questions with answers
|
@@ -124,7 +124,7 @@ gr_interface = gr.Interface(
|
|
124 |
gr.Textbox(label="Generated Questions")
|
125 |
],
|
126 |
title="Visual Question Generator",
|
127 |
-
description="Generate captions and questions for images using
|
128 |
theme=seafoam,
|
129 |
)
|
130 |
|
|
|
85 |
words = caption.split()
|
86 |
# Generate questions for the first word
|
87 |
if len(words) > 0:
|
88 |
+
answer = words[0]
|
89 |
+
question = generate_questions(caption, answer)
|
90 |
+
questions_with_answers.extend([(q, answer) for q in question])
|
91 |
# Generate questions for the second word
|
92 |
if len(words) > 1:
|
93 |
+
answer = words[1]
|
94 |
+
question = generate_questions(caption, answer)
|
95 |
+
questions_with_answers.extend([(q, answer) for q in question])
|
96 |
# Generate questions for the second word + first word
|
97 |
if len(words) > 1:
|
98 |
+
answer = " ".join(words[:2])
|
99 |
+
question = generate_questions(caption, answer)
|
100 |
+
questions_with_answers.extend([(q, answer) for q in question])
|
101 |
# Generate questions for the third word
|
102 |
if len(words) > 2:
|
103 |
+
answer = words[2]
|
104 |
+
question = generate_questions(caption, answer)
|
105 |
+
questions_with_answers.extend([(q, answer) for q in question])
|
106 |
# Generate questions for the fourth word
|
107 |
if len(words) > 3:
|
108 |
+
answer = words[3]
|
109 |
+
question = generate_questions(caption, answer)
|
110 |
+
questions_with_answers.extend([(q, answer) for q in question])
|
111 |
|
112 |
# Format questions with answers
|
113 |
+
formatted_questions = [f"Question: {q}\nKeyword: {a}" for q, a in questions_with_answers]
|
114 |
formatted_questions = "\n".join(formatted_questions)
|
115 |
|
116 |
# Return the generated captions and formatted questions with answers
|
|
|
124 |
gr.Textbox(label="Generated Questions")
|
125 |
],
|
126 |
title="Visual Question Generator",
|
127 |
+
description="Generate captions and questions for images using Arabic image captioning model and question generation model",
|
128 |
theme=seafoam,
|
129 |
)
|
130 |
|