Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -909,30 +909,31 @@ class VideoGeneratorUI:
|
|
| 909 |
try:
|
| 910 |
# Get categorized images
|
| 911 |
image_categories = self.generator.image_scraper.get_images(prompt)
|
| 912 |
-
|
| 913 |
-
if
|
| 914 |
# Display primary matches
|
| 915 |
-
if image_categories['primary']:
|
| 916 |
st.subheader("Most Relevant Images")
|
| 917 |
self.display_image_grid(image_categories['primary'])
|
| 918 |
|
| 919 |
# Display secondary matches
|
| 920 |
-
if image_categories['secondary']:
|
| 921 |
st.subheader("Related Images")
|
| 922 |
self.display_image_grid(image_categories['secondary'])
|
| 923 |
|
| 924 |
# Display general/fallback images
|
| 925 |
-
if image_categories['general']:
|
| 926 |
st.subheader("Additional Suggested Images")
|
| 927 |
self.display_image_grid(image_categories['general'])
|
| 928 |
|
| 929 |
# Collect selected images
|
| 930 |
selected_images = []
|
| 931 |
for category in image_categories.values():
|
| 932 |
-
|
| 933 |
-
|
| 934 |
-
|
| 935 |
-
|
|
|
|
| 936 |
|
| 937 |
# Video generation section
|
| 938 |
if selected_images:
|
|
@@ -943,7 +944,7 @@ class VideoGeneratorUI:
|
|
| 943 |
except Exception as e:
|
| 944 |
st.error(f"An error occurred: {str(e)}")
|
| 945 |
print(f"Error in UI: {str(e)}")
|
| 946 |
-
|
| 947 |
def display_image_grid(self, images: List[Dict[str, str]], cols: int = 3):
|
| 948 |
"""Display images in a grid with metadata"""
|
| 949 |
for i in range(0, len(images), cols):
|
|
|
|
| 909 |
try:
|
| 910 |
# Get categorized images
|
| 911 |
image_categories = self.generator.image_scraper.get_images(prompt)
|
| 912 |
+
|
| 913 |
+
if image_categories and isinstance(image_categories, dict): # Check if it's a dictionary
|
| 914 |
# Display primary matches
|
| 915 |
+
if 'primary' in image_categories and image_categories['primary']:
|
| 916 |
st.subheader("Most Relevant Images")
|
| 917 |
self.display_image_grid(image_categories['primary'])
|
| 918 |
|
| 919 |
# Display secondary matches
|
| 920 |
+
if 'secondary' in image_categories and image_categories['secondary']:
|
| 921 |
st.subheader("Related Images")
|
| 922 |
self.display_image_grid(image_categories['secondary'])
|
| 923 |
|
| 924 |
# Display general/fallback images
|
| 925 |
+
if 'general' in image_categories and image_categories['general']:
|
| 926 |
st.subheader("Additional Suggested Images")
|
| 927 |
self.display_image_grid(image_categories['general'])
|
| 928 |
|
| 929 |
# Collect selected images
|
| 930 |
selected_images = []
|
| 931 |
for category in image_categories.values():
|
| 932 |
+
if isinstance(category, list): # Ensure category is a list
|
| 933 |
+
for img in category:
|
| 934 |
+
key = f"img_{img['url']}"
|
| 935 |
+
if st.session_state.get(key, False):
|
| 936 |
+
selected_images.append(img['url'])
|
| 937 |
|
| 938 |
# Video generation section
|
| 939 |
if selected_images:
|
|
|
|
| 944 |
except Exception as e:
|
| 945 |
st.error(f"An error occurred: {str(e)}")
|
| 946 |
print(f"Error in UI: {str(e)}")
|
| 947 |
+
|
| 948 |
def display_image_grid(self, images: List[Dict[str, str]], cols: int = 3):
|
| 949 |
"""Display images in a grid with metadata"""
|
| 950 |
for i in range(0, len(images), cols):
|