| | import gradio as gr |
| | import os |
| | import glob |
| | from pathlib import Path |
| |
|
| | def create_flux_krea_gallery(): |
| | """Create the FLUX.1-Krea-dev image gallery""" |
| | |
| | image_files = [] |
| | for i in range(1384, 1485): |
| | |
| | filename = f"flux_krea_{i:05d}_.png" |
| | image_files.append((f"images/{filename}", f"FLUX.1-Krea-dev Image {i}")) |
| | |
| | return image_files |
| |
|
| | def get_comfyui_workflow_image(): |
| | """Get the ComfyUI workflow screenshot""" |
| | return "workflows/Screenshot 2025-11-20 at 3.34.47โฏPM.png" |
| |
|
| | def load_comfyui_log(): |
| | """Load and display the ComfyUI log content""" |
| | try: |
| | with open("logs/comfyui_8000.log", "r", encoding="utf-8") as file: |
| | log_content = file.read() |
| | return log_content |
| | except FileNotFoundError: |
| | return "Log file 'logs/comfyui_8000.log' not found. Please ensure the log file exists in the logs directory." |
| | except Exception as e: |
| | return f"Error reading log file: {str(e)}" |
| |
|
| | def create_demo(): |
| | """Create the main Gradio demo""" |
| | |
| | with gr.Blocks( |
| | title="FLUX.1-Krea-dev & ComfyUI Showcase", |
| | theme=gr.themes.Soft( |
| | primary_hue="blue", |
| | secondary_hue="purple", |
| | ) |
| | ) as demo: |
| | |
| | |
| | gr.Markdown( |
| | """ |
| | # ๐จ FLUX.1-Krea-dev & ComfyUI Showcase |
| | *Advanced AI Image Generation Workflow Demonstration* |
| | """ |
| | ) |
| | |
| | |
| | with gr.Tabs(): |
| | |
| | |
| | with gr.TabItem("๐ผ๏ธ FLUX.1-Krea-dev Images"): |
| | gr.Markdown( |
| | """ |
| | ## FLUX.1-Krea-dev Generated Images |
| | *Showing all 101 generated images from flux_krea_01384_.png to flux_krea_01485_.png* |
| | """ |
| | ) |
| | |
| | |
| | gallery = gr.Gallery( |
| | label="FLUX.1-Krea-dev Image Collection", |
| | elem_id="gallery", |
| | columns=5, |
| | rows=5, |
| | height="auto", |
| | object_fit="contain" |
| | ) |
| | |
| | |
| | with gr.Row(): |
| | load_gallery_btn = gr.Button("๐ Load FLUX.1-Krea-dev Gallery", variant="primary") |
| | clear_gallery_btn = gr.Button("๐๏ธ Clear Gallery", variant="secondary") |
| | |
| | |
| | with gr.Row(): |
| | gr.Markdown("**Gallery Controls:** Use the arrows to navigate, click on images to view them in full size.") |
| | |
| | |
| | with gr.TabItem("โ๏ธ ComfyUI Workflow"): |
| | gr.Markdown( |
| | """ |
| | ## ComfyUI Workflow Configuration |
| | *Workflow screenshot: `Screenshot 2025-11-20 at 3.34.47โฏPM.png`* |
| | """ |
| | ) |
| | |
| | |
| | workflow_image = gr.Image( |
| | label="ComfyUI Workflow", |
| | elem_id="workflow-image", |
| | height=600, |
| | interactive=False |
| | ) |
| | |
| | |
| | gr.Markdown( |
| | """ |
| | ### Workflow Description |
| | This ComfyUI workflow demonstrates the FLUX.1-Krea-dev model configuration with: |
| | - **Load Checkpoint**: FLUX.1-Krea-dev model |
| | - **CLIP Text Encode**: Positive and negative prompts |
| | - **KSampler**: Euler, 20 steps |
| | - **VAE Decode**: Convert latent to image |
| | - **Save Image**: Output to specified directory |
| | """ |
| | ) |
| | |
| | |
| | with gr.TabItem("๐ ComfyUI Log"): |
| | gr.Markdown( |
| | """ |
| | ## ComfyUI Generation Log |
| | *Log file: `comfyui_8000.log` - Complete image generation process* |
| | """ |
| | ) |
| | |
| | |
| | log_display = gr.Textbox( |
| | label="ComfyUI Log Content", |
| | elem_id="log-display", |
| | lines=25, |
| | max_lines=50, |
| | show_copy_button=True, |
| | autoscroll=False |
| | ) |
| | |
| | |
| | with gr.Row(): |
| | load_log_btn = gr.Button("๐ Load ComfyUI Log", variant="primary") |
| | clear_log_btn = gr.Button("๐๏ธ Clear Log", variant="secondary") |
| | |
| | |
| | load_gallery_btn.click( |
| | fn=create_flux_krea_gallery, |
| | outputs=gallery |
| | ) |
| | |
| | clear_gallery_btn.click( |
| | fn=lambda: [], |
| | outputs=gallery |
| | ) |
| | |
| | load_log_btn.click( |
| | fn=load_comfyui_log, |
| | outputs=log_display |
| | ) |
| | |
| | clear_log_btn.click( |
| | fn=lambda: "", |
| | outputs=log_display |
| | ) |
| | |
| | |
| | demo.load( |
| | fn=create_flux_krea_gallery, |
| | outputs=gallery |
| | ) |
| | |
| | demo.load( |
| | fn=load_comfyui_log, |
| | outputs=log_display |
| | ) |
| | |
| | |
| | demo.css = """ |
| | #gallery { |
| | min-height: 600px; |
| | } |
| | #workflow-image { |
| | border: 2px solid #e2e8f0; |
| | border-radius: 10px; |
| | } |
| | #log-display { |
| | font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; |
| | font-size: 12px; |
| | } |
| | .tab-nav { |
| | background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
| | } |
| | """ |
| | |
| | return demo |
| |
|
| | def create_advanced_demo(): |
| | """Create an enhanced version with more features""" |
| | |
| | with gr.Blocks( |
| | title="FLUX.1-Krea-dev Advanced Showcase", |
| | theme=gr.themes.Glass( |
| | primary_hue="purple", |
| | secondary_hue="blue", |
| | ) |
| | ) as demo: |
| | |
| | |
| | demo.css = """ |
| | .header-banner { |
| | background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); |
| | padding: 2rem; |
| | border-radius: 15px; |
| | color: white; |
| | margin-bottom: 2rem; |
| | } |
| | .stat-card { |
| | background: white; |
| | padding: 1rem; |
| | border-radius: 10px; |
| | box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); |
| | margin: 0.5rem; |
| | } |
| | """ |
| | |
| | |
| | gr.HTML(""" |
| | <div class="header-banner"> |
| | <h1 style="margin: 0; font-size: 2.5em;">๐จ FLUX.1-Krea-dev & ComfyUI</h1> |
| | <p style="margin: 0; font-size: 1.2em; opacity: 0.9;">Advanced AI Image Generation Workflow Showcase</p> |
| | </div> |
| | """) |
| | |
| | |
| | with gr.Row(): |
| | with gr.Column(): |
| | gr.HTML(""" |
| | <div class="stat-card"> |
| | <h3>๐ Statistics</h3> |
| | <p><strong>Total Images:</strong> 101</p> |
| | <p><strong>Model:</strong> FLUX.1-Krea-dev</p> |
| | <p><strong>Workflow:</strong> ComfyUI</p> |
| | </div> |
| | """) |
| | |
| | with gr.Column(): |
| | gr.HTML(""" |
| | <div class="stat-card"> |
| | <h3>โ๏ธ Technical Details</h3> |
| | <p><strong>Log File:</strong> comfyui_8000.log</p> |
| | <p><strong>Workflow Screenshot:</strong>Screenshot 2025-11-20 at 3.34.47โฏPM.png</p> |
| | <p><strong>Image Range:</strong> flux_krea_01384_.png to flux_krea_01485_.png</p> |
| | </div> |
| | """) |
| | |
| | |
| | with gr.Tabs(): |
| | |
| | |
| | with gr.TabItem("๐ผ๏ธ Image Gallery"): |
| | gr.Markdown("### FLUX.1-Krea-dev Generated Images (101 Total)") |
| | |
| | with gr.Row(): |
| | gallery = gr.Gallery( |
| | value=create_flux_krea_gallery(), |
| | label="FLUX.1-Krea-dev Image Collection", |
| | columns=4, |
| | rows=4, |
| | height="auto", |
| | object_fit="cover", |
| | show_label=True |
| | ) |
| | |
| | with gr.Row(): |
| | gr.Button("Refresh Gallery", variant="primary") |
| | gr.Button("Export Gallery", variant="secondary") |
| | |
| | |
| | with gr.TabItem("๐ง Workflow"): |
| | gr.Markdown("### ComfyUI Workflow Configuration") |
| | |
| | with gr.Row(): |
| | with gr.Column(): |
| | gr.Image( |
| | value=get_comfyui_workflow_image(), |
| | label="Workflow Screenshot", |
| | height=500 |
| | ) |
| | |
| | with gr.Column(): |
| | gr.Markdown(""" |
| | #### Workflow Components |
| | |
| | **1. Model Loading** |
| | - Checkpoint: flux1-krea-dev_fp32.safetensors |
| | - VAE: ae.safetensors |
| | |
| | **2. Text Encoding** |
| | - CLIP Text Encode (Positive) |
| | - ConditioningZeroOut (Conditioning) |
| | |
| | **3. Sampling** |
| | - Sampler Name: Euler |
| | - Steps: 20 |
| | - CFG: 1.0 |
| | |
| | **4. Output** |
| | - VAE Decode |
| | - Save Image |
| | """) |
| | |
| | |
| | with gr.TabItem("๐ Generation Log"): |
| | gr.Markdown("### ComfyUI Execution Log") |
| | |
| | log_content = gr.Textbox( |
| | value=load_comfyui_log(), |
| | label="comfyui_8000.log", |
| | lines=30, |
| | max_lines=100, |
| | show_copy_button=True |
| | ) |
| | |
| | with gr.Row(): |
| | load_log_btn = gr.Button("๐ Reload Log", variant="primary") |
| | clear_log_btn = gr.Button("๐๏ธ Clear Log", variant="secondary") |
| | download_log_btn = gr.Button("๐พ Download Log", variant="secondary") |
| | |
| | |
| | gr.Markdown("---") |
| | gr.Markdown( |
| | """ |
| | <div style="text-align: center; color: #666;"> |
| | <p>FLUX.1-Krea-dev & ComfyUI Showcase Demo | Created with Gradio</p> |
| | </div> |
| | """ |
| | ) |
| | |
| | |
| | load_log_btn.click( |
| | fn=load_comfyui_log, |
| | outputs=log_content |
| | ) |
| | |
| | clear_log_btn.click( |
| | fn=lambda: "", |
| | outputs=log_content |
| | ) |
| | |
| | return demo |
| |
|
| | |
| | if __name__ == "__main__": |
| | |
| | os.makedirs("images", exist_ok=True) |
| | os.makedirs("workflows", exist_ok=True) |
| | os.makedirs("logs", exist_ok=True) |
| | |
| | |
| | log_file_path = "logs/comfyui_8000.log" |
| | if not os.path.exists(log_file_path): |
| | with open(log_file_path, "w", encoding="utf-8") as f: |
| | f.write("# ComfyUI log file will appear here once generation starts\n") |
| | f.write("# Please ensure your ComfyUI is generating logs to this file\n") |
| | |
| | |
| | demo = create_advanced_demo() |
| | demo.launch( |
| | server_name="0.0.0.0", |
| | server_port=7860, |
| | share=True, |
| | show_error=True |
| | ) |