import gradio as gr import os css = """ """ # @keyframes animatedGradient { # 0% { background-position: 0% 50%; } # 50% { background-position: 100% 50%; } # 100% { background-position: 0% 50%; } # } # .video-item { # /* ... other styles ... */ # background: linear-gradient(270deg, #6a6a6a, #373737, #2d2d2d, #373737); # background-size: 800% 800%; # animation: animatedGradient 15s ease infinite; # } # JavaScript function to load the motion backgrounds js = """ """ # def showcase(page_num): # videos_per_page = 3 # start_index = (page_num - 1) * videos_per_page # end_index = start_index + videos_per_page # video_html = "
" # Centering the content # for i in range(start_index, end_index): # video_name = f"{i:04d}.mp4" # caption_name = f"{i:04d}.txt" # video_html += "
" # for category in ['gen2', 'floor33', 'pika']: # video_url = f"http://localhost:8000/{category}/{video_name}" # caption_path = os.path.join('prompts', caption_name) # Path to the caption file # if os.path.exists(os.path.join('static', category, video_name)): # Check if video file exists # caption_text = "" # if os.path.exists(caption_path): # Check if caption file exists and read it # with open(caption_path, 'r') as file: # caption_text = file.read().strip() # video_html += f""" #
# #

{category}/{video_name}

#

{caption_text}

#
# """ # video_html += "
" # # video_html += "
" # return video_html import base64 def video_to_base64(video_path): with open(video_path, "rb") as video_file: return base64.b64encode(video_file.read()).decode('utf-8') def showcase(page_num): videos_per_page = 1 start_index = (page_num - 1) * videos_per_page end_index = start_index + videos_per_page video_html = "" return video_html # Description and Acknowledgements description_html = """

EvalCrafter Text-to-Video (ECTV) Gallery 馃帴馃搳

DatasetCodeProject PageLeaderboardPaper@ArXivPrompt list

Welcome to the ECTV Gallery! This repository contains around 10000 videos generated by various methods using the Prompt list. These videos have been evaluated using the innovative EvalCrafter framework, which assesses generative models across visual, content, and motion qualities using 17 objective metrics and subjective user opinions.

""" # def navigate(direction, page_num): # if direction == "Beginning": # page_num.value = 1 # elif direction == "Previous": # page_num.value = max(1, page_num.value - 1) # elif direction == "Next": # page_num.value = min(total_pages, page_num.value + 1) # elif direction == "End": # page_num.value = total_pages # # Assuming showcase is a function that returns HTML content based on page_num # output_html_content = showcase(page_num.value) # return page_num, output_html_content def navigate(direction, current_page): if direction == "Beginning": return 1 elif direction == "Previous": return max(1, current_page - 1) elif direction == "Next": return min(total_pages, current_page + 1) elif direction == "End": return total_pages else: # For direct navigation through the slider return current_page def navigate_to_page(page_num, page_slider): # Directly navigate to the selected page from the slider page_num.value = page_slider return page_num, showcase(page_num) # Define the total number of pages. total_videos = 700 videos_per_page = 1 total_pages = (total_videos + videos_per_page - 1) // videos_per_page with gr.Blocks(css=css) as app: gr.Markdown(description_html) gr.Markdown(js) page_num = gr.State(value=1) with gr.Row(): beginning_button = gr.Button("Beginning") previous_button = gr.Button("Previous") next_button = gr.Button("Next") end_button = gr.Button("End") page_slider = gr.Slider(minimum=1, maximum=total_pages, step=1, value=1, label="Go to page") output_html = gr.HTML() def update_output(direction): # new_page_num = navigate(direction, page_num.value) if isinstance(direction, int): new_page_num = direction else: new_page_num = navigate(direction, page_num.value) page_num.value = new_page_num content = showcase(new_page_num) return new_page_num, content def initialization(start): page_num.value = int(start) return page_num.value, showcase(page_num.value) app.load(fn=lambda: initialization('1'), inputs=None, outputs=[page_slider, output_html]) beginning_button.click(fn=lambda: update_output("Beginning"), inputs=None, outputs=[page_slider, output_html]) previous_button.click(fn=lambda: update_output("Previous"), inputs=None, outputs=[page_slider, output_html]) next_button.click(fn=lambda: update_output("Next"), inputs=None, outputs=[page_slider, output_html]) end_button.click(fn=lambda: update_output("End"), inputs=None, outputs=[page_slider, output_html]) page_slider.change(fn=lambda x: update_output(x), inputs=page_slider, outputs=[page_slider, output_html]) # Initialize the display for the first page content = showcase(page_num.value) app.launch(share=True)