Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -81,29 +81,23 @@ model = load_model(MODEL_PATH)
|
|
81 |
|
82 |
# Create Gradio Interface
|
83 |
with gr.Blocks(css="""
|
84 |
-
.container {
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
}
|
90 |
-
.
|
91 |
-
|
92 |
-
|
93 |
-
align-items: center;
|
94 |
padding: 5px;
|
95 |
border: 1px solid #ddd;
|
96 |
border-radius: 8px;
|
97 |
-
transition: all 0.3s ease;
|
98 |
-
}
|
99 |
-
img.card-image {
|
100 |
-
width: 80px !important;
|
101 |
-
height: 80px !important;
|
102 |
-
object-fit: contain;
|
103 |
}
|
104 |
-
.
|
105 |
-
|
106 |
-
|
|
|
107 |
}
|
108 |
""") as interface:
|
109 |
gr.Markdown("## Clash Royale Prediction")
|
@@ -124,20 +118,24 @@ with gr.Blocks(css="""
|
|
124 |
return current_deck, f"Selected cards: {len(current_deck)}/8"
|
125 |
|
126 |
# Create card grid using rows and columns
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
)
|
|
|
|
|
|
|
|
|
141 |
|
142 |
with gr.Row():
|
143 |
result = gr.Textbox(label="Prediction Result:", interactive=False)
|
|
|
81 |
|
82 |
# Create Gradio Interface
|
83 |
with gr.Blocks(css="""
|
84 |
+
.image-container img {
|
85 |
+
width: 80px !important;
|
86 |
+
height: 80px !important;
|
87 |
+
object-fit: contain;
|
88 |
+
cursor: pointer;
|
89 |
}
|
90 |
+
.image-container {
|
91 |
+
text-align: center;
|
92 |
+
margin: 5px;
|
|
|
93 |
padding: 5px;
|
94 |
border: 1px solid #ddd;
|
95 |
border-radius: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
+
.card-label {
|
98 |
+
font-size: 12px;
|
99 |
+
margin-top: 5px;
|
100 |
+
text-align: center;
|
101 |
}
|
102 |
""") as interface:
|
103 |
gr.Markdown("## Clash Royale Prediction")
|
|
|
118 |
return current_deck, f"Selected cards: {len(current_deck)}/8"
|
119 |
|
120 |
# Create card grid using rows and columns
|
121 |
+
cards_per_row = 8
|
122 |
+
cards_list = list(valid_card_images.items())
|
123 |
+
|
124 |
+
for i in range(0, len(cards_list), cards_per_row):
|
125 |
+
with gr.Row():
|
126 |
+
for card, url in cards_list[i:i + cards_per_row]:
|
127 |
+
with gr.Column(elem_classes="image-container"):
|
128 |
+
img = gr.Image(value=url, interactive=False, show_label=False)
|
129 |
+
gr.Markdown(card, elem_classes="card-label")
|
130 |
+
# Create a hidden button for click handling
|
131 |
+
click_btn = gr.Button(visible=False)
|
132 |
+
click_btn.click(
|
133 |
+
toggle_card,
|
134 |
+
inputs=[gr.Textbox(value=card, visible=False), selected_deck],
|
135 |
+
outputs=[selected_deck, selected_cards_display]
|
136 |
+
)
|
137 |
+
# Trigger the hidden button when the image is clicked
|
138 |
+
img.click(lambda: None, None, click_btn.click)
|
139 |
|
140 |
with gr.Row():
|
141 |
result = gr.Textbox(label="Prediction Result:", interactive=False)
|