Spaces:
Runtime error
Runtime error
| # import gradio as gr | |
| # from caption_store import get_all_collections | |
| # def render_search(): | |
| # with gr.Column(visible=False) as page: | |
| # gr.Markdown("# π AI Search") | |
| # with gr.Row(): | |
| # search_query = gr.Textbox( | |
| # placeholder="Describe what you're looking for... (e.g. 'moody forest portrait')", | |
| # label="Search Query", scale=4 | |
| # ) | |
| # search_col_filter = gr.Dropdown( | |
| # choices=["All"] + get_all_collections(), value="All", label="Filter by Collection", scale=1 | |
| # ) | |
| # search_btn = gr.Button("Search", variant="primary", scale=1) | |
| # search_status_msg = gr.Markdown("Enter a query to start searching.") | |
| # search_gallery = gr.Gallery(label="Search Results", columns=4, height="auto") | |
| # return page, search_query, search_col_filter, search_btn, search_status_msg, search_gallery | |
| import gradio as gr | |
| from caption_store import get_all_collections | |
| def render_search(): | |
| # Selection and path tracking states for search | |
| selected_paths = gr.State([]) | |
| loaded_original_paths = gr.State([]) | |
| with gr.Column(visible=False, elem_classes="page-container") as page: | |
| gr.HTML(""" | |
| <div style='margin-bottom: 20px;'> | |
| <h1 style='font-size: 2rem; font-weight: 700; color: #f8fafc;'>π AI Search</h1> | |
| <p style='color: #94a3b8;'>Search your archive using natural language, select results, and bulk download.</p> | |
| </div> | |
| """) | |
| with gr.Row(): | |
| search_query = gr.Textbox( | |
| placeholder="Describe what you're looking for... (e.g. 'moody forest portrait')", | |
| label="Search Query", scale=4 | |
| ) | |
| search_col_filter = gr.Dropdown( | |
| choices=["All"] + get_all_collections(), value="All", label="Filter by Collection", scale=1 | |
| ) | |
| search_btn = gr.Button("Search", variant="primary", scale=1) | |
| search_status_msg = gr.Markdown("Enter a query to start searching.") | |
| # Full-width panel for selected files output | |
| selection_status = gr.Markdown( | |
| value="**0** image(s) selected for download packaging.\n\n*No files currently selected.*", | |
| elem_classes="selection-status-box" | |
| ) | |
| # Standalone row for action buttons | |
| with gr.Row(elem_classes="selection-buttons-row"): | |
| select_all_btn = gr.Button("β Select All Results", size="sm", variant="secondary") | |
| clear_selection_btn = gr.Button("π§Ή Clear Selection", size="sm", variant="secondary") | |
| download_btn = gr.Button("π¦ Zip & Download Selected", variant="primary", size="sm") | |
| # Hidden file output for compilation download | |
| download_file = gr.File(label="Source Quality ZIP Archive", visible=False) | |
| search_gallery = gr.Gallery( | |
| label="Search Results", | |
| columns=4, | |
| height="auto", | |
| elem_classes="custom-gallery", | |
| allow_preview=False | |
| ) | |
| return ( | |
| page, search_query, search_col_filter, search_btn, search_status_msg, search_gallery, | |
| selected_paths, loaded_original_paths, selection_status, download_btn, | |
| download_file, clear_selection_btn, select_all_btn | |
| ) |