Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,23 +21,15 @@ st.markdown("""
|
|
| 21 |
</style>
|
| 22 |
""", unsafe_allow_html=True)
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
for image_name, image_info in images_data.items():
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
if image_attribute_value not in selected_values:
|
| 34 |
-
matches_all = False
|
| 35 |
-
break # Break the loop if any attribute does not match
|
| 36 |
-
|
| 37 |
-
if matches_all:
|
| 38 |
-
filtered_images.append(image_name)
|
| 39 |
-
|
| 40 |
-
return filtered_images
|
| 41 |
|
| 42 |
|
| 43 |
|
|
@@ -65,12 +57,11 @@ def main_page(furniture_data):
|
|
| 65 |
selected_options[attribute] = st.multiselect(f'Choose {attribute}', options, key=key)
|
| 66 |
|
| 67 |
if st.button('Show Filtered Images'):
|
| 68 |
-
|
| 69 |
-
print(images_data)
|
| 70 |
# Assuming images_data is loaded from your JSON file
|
| 71 |
images_data = load_images() # Make sure this function is defined and loads your images data
|
| 72 |
|
| 73 |
-
filtered_images = filter_images(images_data, selected_options)
|
| 74 |
|
| 75 |
if filtered_images:
|
| 76 |
for image in filtered_images:
|
|
@@ -89,7 +80,7 @@ def tiktok_video_page():
|
|
| 89 |
|
| 90 |
# Main app logic
|
| 91 |
furniture_data = load_furniture_data()
|
| 92 |
-
|
| 93 |
if 'page' not in st.session_state:
|
| 94 |
st.session_state.page = 'main'
|
| 95 |
|
|
|
|
| 21 |
</style>
|
| 22 |
""", unsafe_allow_html=True)
|
| 23 |
|
| 24 |
+
# Function to filter images based on selected options and category
|
| 25 |
+
def filter_images(images_data, selected_options, category):
|
| 26 |
+
matched_images = []
|
| 27 |
for image_name, image_info in images_data.items():
|
| 28 |
+
if image_info['category'] == category:
|
| 29 |
+
if all(image_info['attributes'][attribute] in options
|
| 30 |
+
for attribute, options in selected_options.items()):
|
| 31 |
+
matched_images.append(image_name)
|
| 32 |
+
return matched_images
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
|
|
|
|
| 57 |
selected_options[attribute] = st.multiselect(f'Choose {attribute}', options, key=key)
|
| 58 |
|
| 59 |
if st.button('Show Filtered Images'):
|
| 60 |
+
images_data = load_images()
|
|
|
|
| 61 |
# Assuming images_data is loaded from your JSON file
|
| 62 |
images_data = load_images() # Make sure this function is defined and loads your images data
|
| 63 |
|
| 64 |
+
filtered_images = filter_images(images_data, selected_options, selected_category)
|
| 65 |
|
| 66 |
if filtered_images:
|
| 67 |
for image in filtered_images:
|
|
|
|
| 80 |
|
| 81 |
# Main app logic
|
| 82 |
furniture_data = load_furniture_data()
|
| 83 |
+
|
| 84 |
if 'page' not in st.session_state:
|
| 85 |
st.session_state.page = 'main'
|
| 86 |
|