DawnC commited on
Commit
9c51072
1 Parent(s): 689deea

Update breed_comparison.py

Browse files
Files changed (1) hide show
  1. breed_comparison.py +7 -4
breed_comparison.py CHANGED
@@ -6,6 +6,9 @@ from breed_health_info import breed_health_info
6
  from breed_noise_info import breed_noise_info
7
 
8
  def create_comparison_tab(dog_breeds, get_dog_description, breed_noise_info, breed_health_info):
 
 
 
9
  with gr.TabItem("Breed Comparison"):
10
  gr.HTML("""
11
  <div style='
@@ -32,14 +35,14 @@ def create_comparison_tab(dog_breeds, get_dog_description, breed_noise_info, bre
32
 
33
  with gr.Row():
34
  breed1_dropdown = gr.Dropdown(
35
- choices=dog_breeds,
36
  label="Select First Breed",
37
- value="Golden_Retriever"
38
  )
39
  breed2_dropdown = gr.Dropdown(
40
- choices=dog_breeds,
41
  label="Select Second Breed",
42
- value="Border_Collie"
43
  )
44
 
45
  compare_btn = gr.Button("Compare Breeds", elem_classes="custom-compare-button")
 
6
  from breed_noise_info import breed_noise_info
7
 
8
  def create_comparison_tab(dog_breeds, get_dog_description, breed_noise_info, breed_health_info):
9
+ # 每個選項是一個元組:(顯示值, 實際值)
10
+ # 對整個列表進行排序,基於顯示值(即沒有底線的品種名稱)
11
+ breed_choices = [(breed.replace('_', ' '), breed) for breed in sorted(dog_breeds)]
12
  with gr.TabItem("Breed Comparison"):
13
  gr.HTML("""
14
  <div style='
 
35
 
36
  with gr.Row():
37
  breed1_dropdown = gr.Dropdown(
38
+ choices=breed_choices,
39
  label="Select First Breed",
40
+ value=breed_choices[0][1] if breed_choices else None # 使用第一個品種的實際值作為預設值
41
  )
42
  breed2_dropdown = gr.Dropdown(
43
+ choices=breed_choices,
44
  label="Select Second Breed",
45
+ value=breed_choices[1][1] if len(breed_choices) > 1 else None # 使用第二個品種的實際值作為預設值
46
  )
47
 
48
  compare_btn = gr.Button("Compare Breeds", elem_classes="custom-compare-button")