Spaces:
Running
Running
| """ | |
| NAIA-WEB Output Panel Component | |
| Image display and generation info | |
| """ | |
| import gradio as gr | |
| def create_output_panel(): | |
| """ | |
| Create output display with image and metadata. | |
| Returns: | |
| Dict with output components: | |
| - image, download_btn | |
| """ | |
| # Container for image with overlay download button | |
| with gr.Group(elem_classes=["output-image-container"]): | |
| output_image = gr.Image( | |
| label="Generated Image", | |
| type="pil", | |
| interactive=False, | |
| show_label=False, | |
| elem_id="naia-output-image", | |
| elem_classes=["output-image"] | |
| ) | |
| # Download button overlaid on image (bottom-right) | |
| download_btn = gr.DownloadButton( | |
| "⬇ Download", | |
| visible=False, | |
| size="sm", | |
| elem_id="naia-download-btn", | |
| elem_classes=["download-overlay-btn"] | |
| ) | |
| return { | |
| "image": output_image, | |
| "download_btn": download_btn | |
| } | |
| def create_generation_info_panel(): | |
| """ | |
| Create collapsible generation info panel. | |
| Shows API parameters sent to server. | |
| Returns: | |
| Dict with info components | |
| """ | |
| with gr.Accordion("Generation Info", open=False, elem_id="naia-gen-info-accordion"): | |
| output_info = gr.Textbox( | |
| label="API Parameters", | |
| interactive=False, | |
| lines=8, | |
| elem_id="naia-output-info" | |
| ) | |
| # Processed prompt display | |
| processed_prompt = gr.Textbox( | |
| label="Final Positive Prompt", | |
| interactive=False, | |
| lines=3, | |
| elem_id="naia-processed-prompt" | |
| ) | |
| processed_negative = gr.Textbox( | |
| label="Final Negative Prompt (UC)", | |
| interactive=False, | |
| lines=2, | |
| elem_id="naia-processed-negative" | |
| ) | |
| # Useful external links | |
| gr.Markdown(""" | |
| * If you need parameters inspection, visit: [novelai.net/inspect](https://novelai.net/inspect) | |
| * If you need tags wiki, visit: [danbooru.donmai.us/wiki_pages/tag_groups](https://danbooru.donmai.us/wiki_pages/tag_groups) | |
| * If you need image to danbooru tags, visit: [SmilingWolf/wd-tagger](https://huggingface.co/spaces/SmilingWolf/wd-tagger) | |
| """, elem_id="naia-gen-info-links") | |
| return { | |
| "info": output_info, | |
| "processed_prompt": processed_prompt, | |
| "processed_negative": processed_negative | |
| } | |