OzoneAsai commited on
Commit
73dc5d0
1 Parent(s): b78b341

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -52,8 +52,10 @@ blur_enabled = st.session_state.blur_enabled
52
 
53
  # タグ検索用のテキスト入力
54
  tag_search_input = st.sidebar.text_input("タグ検索 (カンマでセパレート)", "", key="tag_search")
 
55
  # インデックスを初期化
56
  photo_df = pd.DataFrame(columns=["File Name", "Timestamp", "Tags"])
 
57
  # ページングのための変数
58
  page_num = st.sidebar.number_input("ページ番号", value=1, min_value=1, max_value=(len(photo_df) // PAGE_SIZE) + 1, key="page_num")
59
 
@@ -61,9 +63,6 @@ page_num = st.sidebar.number_input("ページ番号", value=1, min_value=1, max_
61
  sort_options = ["TimeStamp 昇順", "TimeStamp 降順", "名前 昇順", "名前 降順"]
62
  selected_sort = st.sidebar.selectbox("写真の並び替え", sort_options, key="selected_sort")
63
 
64
-
65
-
66
-
67
  # タグ検索があればフィルタリング
68
  if tag_search_input:
69
  tags_to_search = [tag.strip() for tag in tag_search_input.split(',')]
@@ -71,25 +70,20 @@ if tag_search_input:
71
  else:
72
  current_page = photo_df.copy()
73
 
74
- # 並び替えのための選択肢
75
- selected_sort = st.sidebar.selectbox("写真の並び替え", ["TimeStamp 昇順", "TimeStamp 降順", "名前 昇順", "名前 降順"])
76
-
77
  # 並び替え
78
- if selected_sort == "TimeStamp 昇順":
79
  current_page = current_page.sort_values(by="Timestamp", ascending=True)
80
- elif selected_sort == "TimeStamp 降順":
81
  current_page = current_page.sort_values(by="Timestamp", ascending=False)
82
- elif selected_sort == "名前 昇順":
83
  current_page = current_page.sort_values(by="File Name", ascending=True)
84
- elif selected_sort == "名前 降順":
85
  current_page = current_page.sort_values(by="File Name", ascending=False)
86
 
87
- # タグ検索があれば結果を表示
88
  if tag_search_input:
89
  st.sidebar.subheader("タグ検索結果")
90
  st.sidebar.write(f"検索したタグ: {', '.join(tags_to_search)}")
91
  st.sidebar.write(f"結果数: {len(current_page)}")
92
-
93
  # タグ付け関数
94
  def predict_tags(image: Image.Image, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
95
  _, height, width, _ = model.input_shape
 
52
 
53
  # タグ検索用のテキスト入力
54
  tag_search_input = st.sidebar.text_input("タグ検索 (カンマでセパレート)", "", key="tag_search")
55
+
56
  # インデックスを初期化
57
  photo_df = pd.DataFrame(columns=["File Name", "Timestamp", "Tags"])
58
+
59
  # ページングのための変数
60
  page_num = st.sidebar.number_input("ページ番号", value=1, min_value=1, max_value=(len(photo_df) // PAGE_SIZE) + 1, key="page_num")
61
 
 
63
  sort_options = ["TimeStamp 昇順", "TimeStamp 降順", "名前 昇順", "名前 降順"]
64
  selected_sort = st.sidebar.selectbox("写真の並び替え", sort_options, key="selected_sort")
65
 
 
 
 
66
  # タグ検索があればフィルタリング
67
  if tag_search_input:
68
  tags_to_search = [tag.strip() for tag in tag_search_input.split(',')]
 
70
  else:
71
  current_page = photo_df.copy()
72
 
 
 
 
73
  # 並び替え
74
+ if "TimeStamp 昇順" in selected_sort:
75
  current_page = current_page.sort_values(by="Timestamp", ascending=True)
76
+ elif "TimeStamp 降順" in selected_sort:
77
  current_page = current_page.sort_values(by="Timestamp", ascending=False)
78
+ elif "名前 昇順" in selected_sort:
79
  current_page = current_page.sort_values(by="File Name", ascending=True)
80
+ elif "名前 降順" in selected_sort:
81
  current_page = current_page.sort_values(by="File Name", ascending=False)
82
 
 
83
  if tag_search_input:
84
  st.sidebar.subheader("タグ検索結果")
85
  st.sidebar.write(f"検索したタグ: {', '.join(tags_to_search)}")
86
  st.sidebar.write(f"結果数: {len(current_page)}")
 
87
  # タグ付け関数
88
  def predict_tags(image: Image.Image, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
89
  _, height, width, _ = model.input_shape