Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -550,18 +550,38 @@ def create_search_url_ai(keyword):
|
|
550 |
base_url = "https://huggingface.co/spaces/awacke1/GraphicAINovel?q="
|
551 |
return base_url + keyword.replace(' ', '+')
|
552 |
|
|
|
553 |
@st.cache_resource
|
554 |
def display_videos_and_links():
|
555 |
video_files = [f for f in os.listdir('.') if f.endswith('.mp4')]
|
556 |
if not video_files:
|
557 |
st.write("No MP4 videos found in the current directory.")
|
558 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
|
560 |
-
|
|
|
|
|
|
|
|
|
|
|
561 |
video_files_sorted = sorted(video_files, key=lambda x: len(x.split('.')[0]))
|
562 |
-
# Calculate the grid size based on the sorted keywords
|
563 |
grid_sizes = [len(f.split('.')[0]) for f in video_files_sorted]
|
564 |
-
# Dynamically adjust column size based on keyword length
|
565 |
col_sizes = ['small' if size <= 4 else 'medium' if size <= 8 else 'large' for size in grid_sizes]
|
566 |
|
567 |
# Create a map for number of columns to use for each size
|
@@ -576,29 +596,10 @@ def display_videos_and_links():
|
|
576 |
|
577 |
with cols[col_index % current_grid_size]:
|
578 |
st.video(video_file, format='video/mp4', start_time=0)
|
579 |
-
|
580 |
-
# Display Wikipedia and Google search links
|
581 |
k = video_file.split('.')[0] # Assumes keyword is the file name without extension
|
582 |
display_glossary_entity(k)
|
583 |
-
|
584 |
-
|
585 |
-
#google_url = create_search_url_google(keyword)
|
586 |
-
#youtube_url = create_search_url_youtube(keyword)
|
587 |
-
#bing_url = create_search_url_bing(keyword)
|
588 |
-
#ai_url = create_search_url_ai(keyword)
|
589 |
-
#ai_url2 = create_search_url_ai(keyword + ' ' + PromptPrefix)
|
590 |
-
#ai_url3 = create_search_url_ai(keyword + ' ' + PromptPrefix2)
|
591 |
-
#links_md = f"""
|
592 |
-
#[Wikipedia]({wikipedia_url}) |
|
593 |
-
#[Google]({google_url}) |
|
594 |
-
#[YouTube]({youtube_url}) |
|
595 |
-
#[Bing]({bing_url}) |
|
596 |
-
#[AI]({ai_url})|
|
597 |
-
#[AI Novel]({ai_url2} )|
|
598 |
-
#[AI Novel App]({ai_url3})
|
599 |
-
#"""
|
600 |
-
#st.markdown(links_md)
|
601 |
-
#col_index += 1
|
602 |
|
603 |
@st.cache_resource
|
604 |
def display_images_and_wikipedia_summaries():
|
|
|
550 |
base_url = "https://huggingface.co/spaces/awacke1/GraphicAINovel?q="
|
551 |
return base_url + keyword.replace(' ', '+')
|
552 |
|
553 |
+
|
554 |
@st.cache_resource
|
555 |
def display_videos_and_links():
|
556 |
video_files = [f for f in os.listdir('.') if f.endswith('.mp4')]
|
557 |
if not video_files:
|
558 |
st.write("No MP4 videos found in the current directory.")
|
559 |
return
|
560 |
+
|
561 |
+
video_files_sorted = sorted(video_files, key=lambda x: len(x.split('.')[0]))
|
562 |
+
|
563 |
+
cols = st.columns(2) # Define 2 columns outside the loop
|
564 |
+
col_index = 0 # Initialize column index
|
565 |
+
|
566 |
+
for video_file in video_files_sorted:
|
567 |
+
with cols[col_index % 2]: # Use modulo 2 to alternate between the first and second column
|
568 |
+
# Embedding video with autoplay and loop using HTML
|
569 |
+
video_html = f("""<video width="100%" loop autoplay> <source src="{video_file}" type="video/mp4">Your browser does not support the video tag.</video>""")
|
570 |
+
st.markdown(video_html, unsafe_allow_html=True)
|
571 |
+
k = video_file.split('.')[0] # Assumes keyword is the file name without extension
|
572 |
+
display_glossary_entity(k) # Assuming this is defined elsewhere
|
573 |
+
col_index += 1 # Increment column index to place the next video in the next column
|
574 |
+
|
575 |
+
|
576 |
|
577 |
+
@st.cache_resource
|
578 |
+
def display_videos_and_links_old():
|
579 |
+
video_files = [f for f in os.listdir('.') if f.endswith('.mp4')]
|
580 |
+
if not video_files:
|
581 |
+
st.write("No MP4 videos found in the current directory.")
|
582 |
+
return
|
583 |
video_files_sorted = sorted(video_files, key=lambda x: len(x.split('.')[0]))
|
|
|
584 |
grid_sizes = [len(f.split('.')[0]) for f in video_files_sorted]
|
|
|
585 |
col_sizes = ['small' if size <= 4 else 'medium' if size <= 8 else 'large' for size in grid_sizes]
|
586 |
|
587 |
# Create a map for number of columns to use for each size
|
|
|
596 |
|
597 |
with cols[col_index % current_grid_size]:
|
598 |
st.video(video_file, format='video/mp4', start_time=0)
|
|
|
|
|
599 |
k = video_file.split('.')[0] # Assumes keyword is the file name without extension
|
600 |
display_glossary_entity(k)
|
601 |
+
|
602 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
603 |
|
604 |
@st.cache_resource
|
605 |
def display_images_and_wikipedia_summaries():
|