DawnC commited on
Commit
af560f3
·
1 Parent(s): f4ab048

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -550,7 +550,7 @@ async def predict(image):
550
  for breed in topk_breeds[:3]:
551
  button_id = f"Dog {i+1}: More about {breed}"
552
  html_output += f'<button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
553
- #buttons.append(button_id)
554
  html_output += '</div>'
555
 
556
  else:
@@ -577,7 +577,8 @@ async def predict(image):
577
  "show_back": True,
578
  "image": annotated_image,
579
  "is_multi_dog": len(dogs) > 1,
580
- "dogs_info": html_output
 
581
  }
582
  return html_output, annotated_image, gr.update(visible=True, choices=buttons), initial_state
583
  else:
@@ -642,7 +643,8 @@ def format_description_html(description, breed):
642
  def go_back(state):
643
  buttons = state.get("buttons", [])
644
  return (
645
- state["dogs_info"], # 這裡應該是完整的 HTML 內容
 
646
  state["image"],
647
  gr.update(visible=True, choices=buttons),
648
  gr.update(visible=False),
 
550
  for breed in topk_breeds[:3]:
551
  button_id = f"Dog {i+1}: More about {breed}"
552
  html_output += f'<button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
553
+ buttons.append(button_id)
554
  html_output += '</div>'
555
 
556
  else:
 
577
  "show_back": True,
578
  "image": annotated_image,
579
  "is_multi_dog": len(dogs) > 1,
580
+ "dogs_info": html_output,
581
+ "original_html": html_output # 新增這行
582
  }
583
  return html_output, annotated_image, gr.update(visible=True, choices=buttons), initial_state
584
  else:
 
643
  def go_back(state):
644
  buttons = state.get("buttons", [])
645
  return (
646
+ #state["dogs_info"], # 這裡應該是完整的 HTML 內容
647
+ state["original_html"],
648
  state["image"],
649
  gr.update(visible=True, choices=buttons),
650
  gr.update(visible=False),