Yiming-M commited on
Commit
8994c36
Β·
1 Parent(s): 3b32643

2025-07-31 23:04 πŸš€

Browse files
Files changed (1) hide show
  1. app.py +19 -16
app.py CHANGED
@@ -665,16 +665,18 @@ select option[value*="━━━━━━"] {
665
  with gr.Blocks(css=css, theme=gr.themes.Soft(), title="ZIP Crowd Counting") as demo:
666
  gr.Markdown("""
667
  # 🎯 Crowd Counting by ZIP
668
- ### Upload an image and get precise crowd density predictions with advanced zero-inflated models
669
  """)
670
 
671
  # 添加俑息青板
672
- with gr.Accordion("ℹ️ About ZIP Models", open=False):
673
  gr.Markdown("""
674
- **ZIP (Zero-Inflated Poisson)** models are designed to handle crowd counting with:
675
- - **Structural Zeros**: Areas where people cannot exist (walls, sky, etc.)
676
- - **Sampling Zeros**: Areas where people could exist but don't
677
- - **Advanced Metrics**: MAE (Mean Absolute Error) and NAE (Normalized Absolute Error)
 
 
678
 
679
  Choose from different model variants: **ZIP-B** (Base), **ZIP-S** (Small), **ZIP-T** (Tiny), **ZIP-N** (Nano), **ZIP-P** (Pico)
680
  """)
@@ -785,7 +787,7 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(), title="ZIP Crowd Counting") as d
785
  gr.Markdown("""
786
  ### Step-by-step Guide:
787
 
788
- 1. **πŸŽ›οΈ Select Model**: Choose your preferred model variant, dataset, and metric from the dropdown
789
  2. **πŸ“Έ Upload Image**: Click the image area to upload your crowd photo or use clipboard
790
  3. **πŸš€ Analyze**: Click the "Analyze Crowd" button to start processing
791
  4. **πŸ“Š View Results**: Examine the density maps and crowd count in the output panels
@@ -793,16 +795,16 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(), title="ZIP Crowd Counting") as d
793
  ### Understanding the Outputs:
794
 
795
  **πŸ“Š Main Results:**
796
- - **🎯 Density Map**: Shows where people are located with color intensity
797
  - **οΏ½ Predicted Count**: Total number of people detected in the image
798
 
799
  **πŸ” Zero Analysis:**
800
- - **πŸ—οΈ Structural Zero Map**: Areas where people cannot exist (buildings, sky, walls)
801
- - **πŸ“Š Sampling Zero Map**: Areas where people could be but aren't currently present
802
- - **🎯 Complete Zero Map**: Combined zero probability map showing all non-crowd areas
803
 
804
  **🎯 Hotspots:**
805
- - **πŸ“ˆ Lambda Map**: Highlights crowd density hotspots and expected count per pixel
806
  """)
807
 
808
  # ζ·»εŠ ζŠ€ζœ―δΏ‘ζ―
@@ -810,15 +812,16 @@ with gr.Blocks(css=css, theme=gr.themes.Soft(), title="ZIP Crowd Counting") as d
810
  gr.Markdown("""
811
  ### Model Variants:
812
  - **ZIP-B**: Base model with best performance
813
- - **ZIP-S**: Smaller model for faster inference
814
  - **ZIP-T**: Tiny model for resource-constrained environments
815
  - **ZIP-N**: Nano model for mobile applications
816
  - **ZIP-P**: Pico model for edge devices
817
 
818
  ### Datasets:
819
- - **ShanghaiTech A/B**: Dense crowd scenes
820
- - **UCF-QNRF**: Ultra high-resolution crowd images
821
- - **NWPU-Crowd**: Large-scale crowd counting dataset
 
822
 
823
  ### Metrics:
824
  - **MAE**: Mean Absolute Error - average counting error
 
665
  with gr.Blocks(css=css, theme=gr.themes.Soft(), title="ZIP Crowd Counting") as demo:
666
  gr.Markdown("""
667
  # 🎯 Crowd Counting by ZIP
668
+ ### Upload an image and get precise crowd density predictions with ZIP models!
669
  """)
670
 
671
  # 添加俑息青板
672
+ with gr.Accordion("ℹ️ About ZIP", open=False):
673
  gr.Markdown("""
674
+ **ZIP (Zero-Inflated Poisson)** is a framework designed for crowd counting, a task where the goal is to estimate how many people are present in an image. It was introduced in the paper [ZIP: Scalable Crowd Counting via Zero-Inflated Poisson Modeling](https://arxiv.org/abs/2506.19955).
675
+ ZIP is based on a simple idea: not all empty areas in an image mean the same thing. Some regions are empty because there are truly no people there (like walls or sky), while others are places where people could appear but just happen not to in this particular image. ZIP separates these two cases using two prediction heads:
676
+ - **Structural Zeros**: These are regions that naturally never contain people (e.g., the background or torso areas). These are handled by the Ο€ head.
677
+ - **Sampling Zeros**: These are regions where people could appear but don't in this image. These are modeled by the Ξ» head.
678
+
679
+ By separating *where* people are likely to be from *how many* are present, ZIP produces more accurate and interpretable crowd estimates, especially in scenes with large empty spaces or varied crowd densities.
680
 
681
  Choose from different model variants: **ZIP-B** (Base), **ZIP-S** (Small), **ZIP-T** (Tiny), **ZIP-N** (Nano), **ZIP-P** (Pico)
682
  """)
 
787
  gr.Markdown("""
788
  ### Step-by-step Guide:
789
 
790
+ 1. **πŸŽ›οΈ Select Model**: Choose your preferred model variant, pre-trained dataset, and evaluation metric from the dropdown
791
  2. **πŸ“Έ Upload Image**: Click the image area to upload your crowd photo or use clipboard
792
  3. **πŸš€ Analyze**: Click the "Analyze Crowd" button to start processing
793
  4. **πŸ“Š View Results**: Examine the density maps and crowd count in the output panels
 
795
  ### Understanding the Outputs:
796
 
797
  **πŸ“Š Main Results:**
798
+ - **🎯 Density Map**: Shows where people are located with color intensity, modeled by (1-Ο€) * Ξ»
799
  - **οΏ½ Predicted Count**: Total number of people detected in the image
800
 
801
  **πŸ” Zero Analysis:**
802
+ - **πŸ—οΈ Structural Zero Map**: Indicates regions that structurally cannot contain head annotations (e.g., walls, sky, torso, or background). These are governed by the Ο€ head, which estimates the probability that a region never contains people.
803
+ - **πŸ“Š Sampling Zero Map**: Shows areas where people could be present but happen not to appear in the current image. These zeros are modeled by (1-Ο€) * exp(-Ξ»), where the expected count Ξ» is near zero.
804
+ - **🎯 Complete Zero Map**: A combined visualization of zero probabilities, capturing both structural and sampling zeros. This map reflects overall non-crowd likelihood per region.
805
 
806
  **🎯 Hotspots:**
807
+ - **πŸ“ˆ Lambda Map**: Highlights areas with high expected crowd density. Each value represents the expected number of people in that region, modeled by the Poisson intensity (Ξ»). This map focuses on *how many* people are likely to be present, assuming people could appear there.
808
  """)
809
 
810
  # ζ·»εŠ ζŠ€ζœ―δΏ‘ζ―
 
812
  gr.Markdown("""
813
  ### Model Variants:
814
  - **ZIP-B**: Base model with best performance
815
+ - **ZIP-S**: Small model for faster inference
816
  - **ZIP-T**: Tiny model for resource-constrained environments
817
  - **ZIP-N**: Nano model for mobile applications
818
  - **ZIP-P**: Pico model for edge devices
819
 
820
  ### Datasets:
821
+ - **ShanghaiTech A**: Dense, low-resolution crowd scenes
822
+ - **ShanghaiTech B**: Sparse, high-resolution crowd scenes
823
+ - **UCF-QNRF**: Dense, ultra high-resolution crowd images
824
+ - **NWPU-Crowd**: Largest ultra high-resolution crowd counting dataset
825
 
826
  ### Metrics:
827
  - **MAE**: Mean Absolute Error - average counting error