Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Image filenames
|
4 |
+
wordcloud_images = ["wordcloud_intro.png", "wordcloud_body.png", "wordcloud_conclusion.png"]
|
5 |
+
scrambled_images = ["image1.png", "image2.png", "image3.png", "image4.png", "image5.png", "image6.png"]
|
6 |
+
correct_order = ["image1.png", "image2.png", "image3.png", "image4.png", "image5.png", "image6.png"]
|
7 |
+
|
8 |
+
# Function to check the order of images
|
9 |
+
attempts = 3
|
10 |
+
def check_sequence(*images):
|
11 |
+
global attempts
|
12 |
+
if list(images) == correct_order:
|
13 |
+
attempts = 3
|
14 |
+
return "Wow! Good job! :)"
|
15 |
+
else:
|
16 |
+
attempts -= 1
|
17 |
+
if attempts > 0:
|
18 |
+
return f"Oops! Would you try again? You have {attempts} attempts left."
|
19 |
+
else:
|
20 |
+
attempts = 3
|
21 |
+
return "Oops! No more attempts left. Please try again."
|
22 |
+
|
23 |
+
# Gradio interface
|
24 |
+
with gr.Blocks() as demo:
|
25 |
+
gr.Markdown("## Pre-reading Activity: Image Sequencing")
|
26 |
+
|
27 |
+
gr.Markdown("### Look at the Wordcloud images below:")
|
28 |
+
with gr.Row():
|
29 |
+
for img in wordcloud_images:
|
30 |
+
gr.Image(img, label=img.split('.')[0])
|
31 |
+
|
32 |
+
gr.Markdown("### Unscramble the images below:")
|
33 |
+
with gr.Row():
|
34 |
+
for img in scrambled_images:
|
35 |
+
gr.Image(img, label=img.split('/')[-1])
|
36 |
+
|
37 |
+
gr.Markdown("### Select the images in the correct order:")
|
38 |
+
image_inputs = [gr.Dropdown(choices=scrambled_images, label=f"Image {i+1}") for i in range(6)]
|
39 |
+
|
40 |
+
result = gr.Textbox(label="Feedback", interactive=False)
|
41 |
+
|
42 |
+
check_button = gr.Button("Check Order")
|
43 |
+
check_button.click(check_sequence, inputs=image_inputs, outputs=result)
|
44 |
+
|
45 |
+
demo.launch()
|