"""
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
""")
with gr.Row():
with gr.Column(scale=1):
gr.Markdown("## Image Analysis")
image_input = gr.Image(
label="Upload image for analysis",
type="pil",
height=500
)
analyze_btn = gr.Button(
"🔍 Analyze Image",
variant="primary",
size="lg"
)
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
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")
with gr.Column(scale=1):
gr.Markdown("## Results")
score_output = gr.HTML(
value='