Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -508,6 +508,52 @@ def create_search_url_ai(keyword):
|
|
508 |
base_url = "https://huggingface.co/spaces/awacke1/GraphicAINovel?q="
|
509 |
return base_url + keyword.replace(' ', '+')
|
510 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
511 |
|
512 |
|
513 |
def display_images_and_wikipedia_summaries():
|
@@ -558,35 +604,6 @@ def display_images_and_wikipedia_summaries():
|
|
558 |
st.markdown(links_md)
|
559 |
col_index += 1
|
560 |
|
561 |
-
def display_images_and_wikipedia_summaries_deprecated():
|
562 |
-
image_files = [f for f in os.listdir('.') if f.endswith('.png')]
|
563 |
-
if not image_files:
|
564 |
-
st.write("No PNG images found in the current directory.")
|
565 |
-
return
|
566 |
-
|
567 |
-
for image_file in image_files:
|
568 |
-
image = Image.open(image_file)
|
569 |
-
st.image(image, caption=image_file, use_column_width=True)
|
570 |
-
|
571 |
-
keyword = image_file.split('.')[0] # Assumes keyword is the file name without extension
|
572 |
-
|
573 |
-
# Display Wikipedia and Google search links
|
574 |
-
wikipedia_url = create_search_url_wikipedia(keyword)
|
575 |
-
google_url = create_search_url_google(keyword)
|
576 |
-
youtube_url = create_search_url_youtube(keyword)
|
577 |
-
bing_url = create_search_url_bing(keyword)
|
578 |
-
ai_url = create_search_url_ai(keyword)
|
579 |
-
|
580 |
-
|
581 |
-
links_md = f"""
|
582 |
-
[Wikipedia]({wikipedia_url}) |
|
583 |
-
[Google]({google_url}) |
|
584 |
-
[YouTube]({youtube_url}) |
|
585 |
-
[Bing]({bing_url}) |
|
586 |
-
[AI]({ai_url})
|
587 |
-
"""
|
588 |
-
st.markdown(links_md)
|
589 |
-
|
590 |
|
591 |
def get_all_query_params(key):
|
592 |
return st.query_params().get(key, [])
|
@@ -1297,6 +1314,7 @@ def main():
|
|
1297 |
|
1298 |
# Display the glossary grid
|
1299 |
st.markdown("### 🎲🗺️ Graphic Novel Gallery")
|
|
|
1300 |
display_images_and_wikipedia_summaries()
|
1301 |
display_glossary_grid(roleplaying_glossary)
|
1302 |
st.markdown("## Explore the vast universe of Graphic Novels including card and board games with fascinating readable content and semantic rules where language is fun!.🌠")
|
|
|
508 |
base_url = "https://huggingface.co/spaces/awacke1/GraphicAINovel?q="
|
509 |
return base_url + keyword.replace(' ', '+')
|
510 |
|
511 |
+
def display_videos_and_links():
|
512 |
+
video_files = [f for f in os.listdir('.') if f.endswith('.mp4')]
|
513 |
+
if not video_files:
|
514 |
+
st.write("No MP4 videos found in the current directory.")
|
515 |
+
return
|
516 |
+
|
517 |
+
# Sort video_files based on the length of the keyword to create a visually consistent grid
|
518 |
+
video_files_sorted = sorted(video_files, key=lambda x: len(x.split('.')[0]))
|
519 |
+
# Calculate the grid size based on the sorted keywords
|
520 |
+
grid_sizes = [len(f.split('.')[0]) for f in video_files_sorted]
|
521 |
+
# Dynamically adjust column size based on keyword length
|
522 |
+
col_sizes = ['small' if size <= 4 else 'medium' if size <= 8 else 'large' for size in grid_sizes]
|
523 |
+
|
524 |
+
# Create a map for number of columns to use for each size
|
525 |
+
num_columns_map = {"small": 4, "medium": 3, "large": 2}
|
526 |
+
current_grid_size = 0
|
527 |
+
|
528 |
+
for video_file, col_size in zip(video_files_sorted, col_sizes):
|
529 |
+
if current_grid_size != num_columns_map[col_size]:
|
530 |
+
cols = st.columns(num_columns_map[col_size])
|
531 |
+
current_grid_size = num_columns_map[col_size]
|
532 |
+
col_index = 0
|
533 |
+
|
534 |
+
with cols[col_index % current_grid_size]:
|
535 |
+
st.video(video_file, format='video/mp4', start_time=0)
|
536 |
+
|
537 |
+
# Display Wikipedia and Google search links
|
538 |
+
keyword = video_file.split('.')[0] # Assumes keyword is the file name without extension
|
539 |
+
wikipedia_url = create_search_url_wikipedia(keyword)
|
540 |
+
google_url = create_search_url_google(keyword)
|
541 |
+
youtube_url = create_search_url_youtube(keyword)
|
542 |
+
bing_url = create_search_url_bing(keyword)
|
543 |
+
ai_url = create_search_url_ai(keyword)
|
544 |
+
ai_url2 = create_search_url_ai(keyword + ' ' + PromptPrefix)
|
545 |
+
ai_url3 = create_search_url_ai(keyword + ' ' + PromptPrefix2)
|
546 |
+
links_md = f"""
|
547 |
+
[Wikipedia]({wikipedia_url}) |
|
548 |
+
[Google]({google_url}) |
|
549 |
+
[YouTube]({youtube_url}) |
|
550 |
+
[Bing]({bing_url}) |
|
551 |
+
[AI]({ai_url})|
|
552 |
+
[AI Novel]({ai_url2} )|
|
553 |
+
[AI Novel App]({ai_url3})
|
554 |
+
"""
|
555 |
+
st.markdown(links_md)
|
556 |
+
col_index += 1
|
557 |
|
558 |
|
559 |
def display_images_and_wikipedia_summaries():
|
|
|
604 |
st.markdown(links_md)
|
605 |
col_index += 1
|
606 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
607 |
|
608 |
def get_all_query_params(key):
|
609 |
return st.query_params().get(key, [])
|
|
|
1314 |
|
1315 |
# Display the glossary grid
|
1316 |
st.markdown("### 🎲🗺️ Graphic Novel Gallery")
|
1317 |
+
display_video_summaries()
|
1318 |
display_images_and_wikipedia_summaries()
|
1319 |
display_glossary_grid(roleplaying_glossary)
|
1320 |
st.markdown("## Explore the vast universe of Graphic Novels including card and board games with fascinating readable content and semantic rules where language is fun!.🌠")
|