"""
Frame 0 Laboratory for MIA - Main Gradio Interface
FLUX Prompt Optimizer with clean, professional interface
"""
import gradio as gr
import logging
import warnings
import os
from typing import Tuple
from config import APP_CONFIG, ENVIRONMENT
from processor import process_image_simple, flux_optimizer
from utils import setup_logging, clean_memory
# Configure environment
warnings.filterwarnings("ignore", category=FutureWarning)
warnings.filterwarnings("ignore", category=UserWarning)
os.environ["TOKENIZERS_PARALLELISM"] = "false"
# Setup logging
setup_logging(ENVIRONMENT["log_level"])
logger = logging.getLogger(__name__)
def process_image_interface(image) -> Tuple[str, str, str]:
"""
Main interface function for image processing
Args:
image: Input image from Gradio interface
Returns:
Tuple of (prompt, analysis_report, score_html)
"""
try:
if image is None:
return (
"Please upload an image to analyze",
"No image provided for analysis.",
'
Frame 0 Laboratory for MIA
Advanced Image Analysis & FLUX Prompt Optimization
""")
# Main interface
with gr.Row():
# Left column - Input
with gr.Column(scale=1):
gr.Markdown("## Image Analysis")
image_input = gr.Image(
label="Upload Image for Analysis",
type="pil",
height=400
)
with gr.Row():
analyze_btn = gr.Button(
"🔍 Analyze Image",
variant="primary",
size="lg"
)
clear_btn = gr.Button(
"🗑️ Clear",
variant="secondary",
size="lg"
)
# Information panel
gr.Markdown("""
### How it works:
**1. Image Analysis:** Advanced AI models analyze your image to understand content, composition, and style.
**2. FLUX Optimization:** Applies proven rules for FLUX image generation including camera settings, lighting, and technical parameters.
**3. Quality Scoring:** Evaluates the optimized prompt across multiple dimensions for best results.
**Supported formats:** JPG, PNG, WebP up to 1024px
""")
# Statistics (collapsible)
with gr.Accordion("📊 Processing Stats", open=False):
stats_output = gr.Markdown(value="No processing completed yet.")
refresh_stats_btn = gr.Button("Refresh Stats", size="sm")
refresh_stats_btn.click(
fn=get_stats_info,
outputs=stats_output
)
# Right column - Output
with gr.Column(scale=1):
gr.Markdown("## Results")
# Score display
score_output = gr.HTML(
value='