Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -455,8 +455,11 @@ def show_details(choice, previous_output, initial_state):
|
|
455 |
breed = choice.split("More about ")[-1]
|
456 |
description = get_dog_description(breed)
|
457 |
formatted_description = format_description(description, breed)
|
458 |
-
|
459 |
-
|
|
|
|
|
|
|
460 |
return formatted_description, gr.update(visible=True), initial_state
|
461 |
except Exception as e:
|
462 |
error_msg = f"An error occurred while showing details: {e}"
|
@@ -464,29 +467,16 @@ def show_details(choice, previous_output, initial_state):
|
|
464 |
return error_msg, gr.update(visible=True), initial_state
|
465 |
|
466 |
def go_back(state):
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
state
|
478 |
-
)
|
479 |
-
else:
|
480 |
-
# ๅฎ็ๆ
ๅข๏ผไธ้่ฆ็นๆฎ่็
|
481 |
-
return (
|
482 |
-
state["explanation"],
|
483 |
-
state["image"],
|
484 |
-
gr.update(visible=False),
|
485 |
-
gr.update(visible=False),
|
486 |
-
gr.update(visible=False),
|
487 |
-
gr.update(visible=False),
|
488 |
-
state
|
489 |
-
)
|
490 |
|
491 |
with gr.Blocks() as iface:
|
492 |
gr.HTML("<h1 style='text-align: center;'>๐ถ Dog Breed Classifier ๐</h1>")
|
|
|
455 |
breed = choice.split("More about ")[-1]
|
456 |
description = get_dog_description(breed)
|
457 |
formatted_description = format_description(description, breed)
|
458 |
+
|
459 |
+
# ไฟๅญ็ถๅๆ่ฟฐๅๅๅงๆ้็ๆ
|
460 |
+
initial_state["current_description"] = formatted_description
|
461 |
+
initial_state["original_buttons"] = initial_state.get("buttons", [])
|
462 |
+
|
463 |
return formatted_description, gr.update(visible=True), initial_state
|
464 |
except Exception as e:
|
465 |
error_msg = f"An error occurred while showing details: {e}"
|
|
|
467 |
return error_msg, gr.update(visible=True), initial_state
|
468 |
|
469 |
def go_back(state):
|
470 |
+
buttons = state.get("buttons", [])
|
471 |
+
return (
|
472 |
+
state["explanation"],
|
473 |
+
state["image"],
|
474 |
+
buttons[0] if len(buttons) > 0 else gr.update(visible=False),
|
475 |
+
buttons[1] if len(buttons) > 1 else gr.update(visible=False),
|
476 |
+
buttons[2] if len(buttons) > 2 else gr.update(visible=False),
|
477 |
+
gr.update(visible=False), # ้ฑ่ back ๆ้
|
478 |
+
state
|
479 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
|
481 |
with gr.Blocks() as iface:
|
482 |
gr.HTML("<h1 style='text-align: center;'>๐ถ Dog Breed Classifier ๐</h1>")
|