Spaces:
Runtime error
Runtime error
Update app.py
Browse files327 unmodified lines328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437327 unmodified lines<p style='margin: 10px 0 0 0; font-size: 1.2em; opacity: 0.9;'>Compact interface for advanced document structure detection</p></div>""")# Controls Sectionwith gr.Group(elem_classes=["controls-container"]):# 1. Image Upload (First)gr.HTML("<h3 style='margin-top: 0;'>📄 Upload Document</h3>")input_img = gr.Image(label="Document Image",type="pil",height=300,interactive=True)# Dividergr.HTML("<div class='section-divider'></div>")# 2. Model Selection (Second)gr.HTML("<h3>🤖 Model Selection</h3>")model_dropdown = gr.Dropdown(choices=list(MODELS.keys()),value="Egret XLarge",label="AI Model",info="Model will load automatically when analyzing",interactive=True)# Dividergr.HTML("<div class='section-divider'></div>")# 3. Detection Parameters (Third)gr.HTML("<h3>⚙️ Detection Settings</h3>")with gr.Row():conf_threshold = gr.Slider(minimum=0.0,maximum=1.0,value=0.6,step=0.05,label="Confidence Threshold",info="Minimum confidence for detections")iou_threshold = gr.Slider(minimum=0.0,maximum=1.0,value=0.5,step=0.05,label="NMS IoU Threshold",info="Non-maximum suppression threshold")with gr.Row():nms_method = gr.Radio(choices=["Custom IoMin", "Standard IoU"],value="Custom IoMin",label="NMS Algorithm",info="Choose suppression method")alpha_slider = gr.Slider(minimum=0.0,maximum=1.0,value=0.3,step=0.1,label="Overlay Transparency",info="Transparency of detection overlays")show_labels_checkbox = gr.Checkbox(value=True,label="Show Class Labels and Confidence Scores",info="Display detection labels on the output image",interactive=True)# Dividergr.HTML("<div class='section-divider'></div>")# 4. Analyze Button (Last)detect_btn = gr.Button("🔍 Analyze Document",variant="primary",size="lg",elem_classes=["analyze-btn"])# Results Sectionwith gr.Group(elem_classes=["results-container"]):gr.HTML("<h3 style='margin-top: 0;'>🎯 Analysis Results</h3>")output_img = gr.Image(label="Analyzed Document",type="numpy",height=600,interactive=False)detection_info = gr.Textbox(label="Detection Summary",value="Ready for analysis. Upload an image and click 'Analyze Document'.",interactive=False,lines=2,show_copy_button=True)# Event Handlerdetect_btn.click(fn=process_image,327 unmodified lines328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443327 unmodified lines<p style='margin: 10px 0 0 0; font-size: 1.2em; opacity: 0.9;'>Compact interface for advanced document structure detection</p></div>""")# LEFT COLUMN - Controls and Inputwith gr.Column(scale=1):# Controls Sectionwith gr.Group(elem_classes=["controls-container"]):# 1. Image Upload (First)gr.HTML("<h3 style='margin-top: 0;'>📄 Upload Document</h3>")input_img = gr.Image(label="Document Image",type="pil",height=300,interactive=True)# Dividergr.HTML("<div class='section-divider'></div>")# 2. Model Selection (Second)gr.HTML("<h3>🤖 Model Selection</h3>")model_dropdown = gr.Dropdown(choices=list(MODELS.keys()),value="Egret XLarge",label="AI Model",info="Model will load automatically when analyzing",interactive=True)# Dividergr.HTML("<div class='section-divider'></div>")# 3. Detection Parameters (Third)gr.HTML("<h3>⚙️ Detection Settings</h3>")with gr.Row():conf_threshold = gr.Slider(minimum=0.0,maximum=1.0,value=0.6,step=0.05,label="Confidence Threshold",info="Minimum confidence for detections")iou_threshold = gr.Slider(minimum=0.0,maximum=1.0,value=0.5,step=0.05,label="NMS IoU Threshold",info="Non-maximum suppression threshold")with gr.Row():nms_method = gr.Radio(choices=["Custom IoMin", "Standard IoU"],value="Custom IoMin",label="NMS Algorithm",info="Choose suppression method")alpha_slider = gr.Slider(minimum=0.0,maximum=1.0,value=0.3,step=0.1,label="Overlay Transparency",info="Transparency of detection overlays")show_labels_checkbox = gr.Checkbox(value=True,label="Show Class Labels and Confidence Scores",info="Display detection labels on the output image",interactive=True)# Dividergr.HTML("<div class='section-divider'></div>")# 4. Analyze Button (Last)detect_btn = gr.Button("🔍 Analyze Document",variant="primary",size="lg",elem_classes=["analyze-btn"])# RIGHT COLUMN - Results and Outputwith gr.Column(scale=1):# Results Sectionwith gr.Group(elem_classes=["results-container"]):gr.HTML("<h3 style='margin-top: 0;'>🎯 Analysis Results</h3>")output_img = gr.Image(label="Analyzed Document",type="numpy",height=600,interactive=False)detection_info = gr.Textbox(label="Detection Summary",value="Ready for analysis. Upload an image and click 'Analyze Document'.",interactive=False,lines=2,show_copy_button=True)# Event Handlerdetect_btn.click(fn=process_image,
app.py+101-95