Update app.py
Browse files
app.py
CHANGED
@@ -50,6 +50,33 @@ if "blur_enabled" not in st.session_state:
|
|
50 |
# blur_enabledの値を取得
|
51 |
blur_enabled = st.session_state.blur_enabled
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
# タグ付け関数
|
54 |
def predict_tags(image: Image.Image, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
|
55 |
_, height, width, _ = model.input_shape
|
@@ -208,6 +235,12 @@ def main():
|
|
208 |
elif selected_sort == "名前 降順":
|
209 |
current_page = current_page.sort_values(by="File Name", ascending=False)
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
# ページに写真を表示
|
212 |
display_photos(current_page)
|
213 |
|
|
|
50 |
# blur_enabledの値を取得
|
51 |
blur_enabled = st.session_state.blur_enabled
|
52 |
|
53 |
+
# タグ検索用のテキスト入力
|
54 |
+
tag_search_input = st.sidebar.text_input("タグ検索 (カンマでセパレート)", "")
|
55 |
+
|
56 |
+
# タグ検索があればフィルタリング
|
57 |
+
if tag_search_input:
|
58 |
+
tags_to_search = [tag.strip() for tag in tag_search_input.split(',')]
|
59 |
+
current_page = current_page[current_page["Tags"].apply(lambda x: all(tag in x.split(', ') for tag in tags_to_search))]
|
60 |
+
|
61 |
+
# 並び替えのための選択肢
|
62 |
+
selected_sort = st.sidebar.selectbox("写真の並び替え", ["TimeStamp 昇順", "TimeStamp 降順", "名前 昇順", "名前 降順"])
|
63 |
+
|
64 |
+
# 並び替え
|
65 |
+
if selected_sort == "TimeStamp 昇順":
|
66 |
+
current_page = current_page.sort_values(by="Timestamp", ascending=True)
|
67 |
+
elif selected_sort == "TimeStamp 降順":
|
68 |
+
current_page = current_page.sort_values(by="Timestamp", ascending=False)
|
69 |
+
elif selected_sort == "名前 昇順":
|
70 |
+
current_page = current_page.sort_values(by="File Name", ascending=True)
|
71 |
+
elif selected_sort == "名前 降順":
|
72 |
+
current_page = current_page.sort_values(by="File Name", ascending=False)
|
73 |
+
|
74 |
+
# タグ検索があれば結果を表示
|
75 |
+
if tag_search_input:
|
76 |
+
st.sidebar.subheader("タグ検索結果")
|
77 |
+
st.sidebar.write(f"検索したタグ: {', '.join(tags_to_search)}")
|
78 |
+
st.sidebar.write(f"結果数: {len(current_page)}")
|
79 |
+
|
80 |
# タグ付け関数
|
81 |
def predict_tags(image: Image.Image, score_threshold: float) -> tuple[dict[str, float], dict[str, float], str]:
|
82 |
_, height, width, _ = model.input_shape
|
|
|
235 |
elif selected_sort == "名前 降順":
|
236 |
current_page = current_page.sort_values(by="File Name", ascending=False)
|
237 |
|
238 |
+
# タグ検索があれば結果を表示
|
239 |
+
if tag_search_input:
|
240 |
+
st.sidebar.subheader("タグ検索結果")
|
241 |
+
st.sidebar.write(f"検索したタグ: {', '.join(tags_to_search)}")
|
242 |
+
st.sidebar.write(f"結果数: {len(current_page)}")
|
243 |
+
|
244 |
# ページに写真を表示
|
245 |
display_photos(current_page)
|
246 |
|