# geo_fewshot_pipe **Repository Path**: shuinan/geo_fewshot_pipe ## Basic Information - **Project Name**: geo_fewshot_pipe - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-31 - **Last Updated**: 2026-06-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MetaPro-Verify: Geometric-Aware Few-Shot Recognition Verification > Verification project for "Geometric-Aware Few-Shot Recognition for Industrial Pipeline Components" ## Overview This project implements the geometric-aware few-shot point cloud classification method proposed in the paper, including: - **Geometric Attribute Encoding Module**: 7 types of geometric features (cylindricity, planarity, curvature distribution, topological connectivity, cross-sectional profile, symmetry, scale features) - **Point-BERT Backbone**: Deep feature extraction - **Gated Fusion Module**: Multi-modal feature fusion - **Weighted Prototype Network**: Few-shot classification ## Directory Structure ``` MetaPro-Verify/ ├── data/ │ ├── industrial_dataset.py # TraceParts dataset loader │ ├── generate_traceparts_sample.py # Generate sample data │ └── augmentation.py # Data augmentation ├── models/ │ ├── pointbert/ # Point-BERT source code │ │ ├── __init__.py │ │ └── pointbert.py # Point-BERT model │ ├── geometric_encoder.py # Geometric attribute encoding module (core) │ ├── gated_fusion.py # Gated fusion │ └── protonet.py # Weighted prototype network ├── train.py # Meta-training ├── eval_fewshot.py # 5-way 1/5-shot evaluation ├── ablation.py # Ablation study ├── ablation_geometric.py # Geometric feature ablation ├── noise_robustness.py # Noise robustness ├── occlusion_robustness.py # Occlusion robustness ├── requirements.txt └── README.md ``` ## Environment Setup ### Dependencies ```bash pip install torch>=1.9.0 numpy>=1.20.0 scipy>=1.7.0 scikit-learn>=0.24.0 tqdm>=4.62.0 ``` Or install directly: ```bash pip install -r requirements.txt ``` ### Test Environment ```bash python -c "import torch; print(f'PyTorch: {torch.__version__}')" ``` ## Data Preparation ### Using TraceParts Standard Parts Library Organize point cloud files from TraceParts into `data/traceparts/` directory: ``` data/traceparts/ ├── straight_pipe/ │ ├── model1.ply │ ├── model2.ply │ └── ... ├── elbow_90/ │ └── ... └── ... ``` Supported formats: `.ply`, `.obj`, `.npy` ### Generate Sample Data (Optional) If you don't have TraceParts data, generate synthetic data: ```bash cd MetaPro-Verify python data/generate_traceparts_sample.py --output_dir data/traceparts --samples_per_class 50 --n_points 2048 ``` 12 industrial pipeline component categories: - **Base classes (8)**: straight_pipe, elbow_90, elbow_45, tee, flange, reducer, valve_ball, valve_gate - **Novel classes (4)**: valve_butterfly, valve_check, coupling, weld_neck ## Quick Test After generating data, run a quick test: ```bash python eval_fewshot.py --data_dir ./data/traceparts --num_episodes 10 --eval_1shot ``` ## Training ### Meta-training ```bash python train.py \ --data_dir ./data/traceparts \ --num_episodes 2000 \ --n_way 5 \ --k_shot 5 \ --lr 1e-4 \ --val_interval 100 \ --checkpoint_dir ./checkpoints ``` Parameters: - `--num_episodes`: Number of training episodes (default 2000) - `--n_way`: Number of classes per episode (default 5) - `--k_shot`: Number of support samples per class (default 5) - `--lr`: Learning rate (default 1e-4) - `--backbone`: Backbone type (simple/bert, default simple) ### Resume Training ```bash python train.py \ --data_dir ./data/traceparts \ --checkpoint ./checkpoints/best_model.pt \ --num_episodes 5000 ``` ## Evaluation ### Few-Shot Evaluation ```bash # Full evaluation (1-shot and 5-shot) python eval_fewshot.py \ --data_dir ./data/traceparts \ --checkpoint ./checkpoints/best_model.pt \ --num_episodes 600 # Evaluate 1-shot only python eval_fewshot.py \ --data_dir ./data/traceparts \ --eval_1shot --eval_all # Evaluate 5-shot only python eval_fewshot.py \ --data_dir ./data/traceparts \ --eval_5shot # Evaluate with novel classes python eval_fewshot.py \ --data_dir ./data/traceparts \ --eval_novel ``` Output format: ``` 5-way 5-shot (Base) Results: Accuracy: 85.32% ± 2.15% 95% CI: [83.17%, 87.47%] ``` ## Ablation Studies ### Full Ablation Study ```bash python ablation.py \ --data_dir ./data/traceparts \ --num_episodes 300 ``` Runs 5 configurations: 1. Full method (baseline) 2. Without geometric encoding 3. Without weighted prototype 4. Without gated fusion 5. Only backbone ### Geometric Feature Ablation ```bash python ablation_geometric.py \ --data_dir ./data/traceparts \ --num_episodes 200 ``` ## Robustness Experiments ### Noise Robustness ```bash python noise_robustness.py \ --data_dir ./data/traceparts \ --noise_levels 0.01,0.02,0.03,0.05 \ --num_episodes 200 ``` ### Occlusion Robustness ```bash python occlusion_robustness.py \ --data_dir ./data/traceparts \ --occlusion_ratios 0.1,0.2,0.3,0.4 \ --num_episodes 200 ``` ## Method Details ### Geometric Attribute Encoding 7 geometric features: | Feature | Dim | Description | |---------|-----|-------------| | Cylindricity | 9 | RANSAC cylinder fitting | | Planarity | 9 | PCA eigenvalue ratio | | Curvature | 14 | Mean/Gaussian curvature | | Topology | 4 | Connected components | | Cross-section | 14 | Circularity statistics | | Symmetry | 4 | Rotational symmetry | | Scale | 6 | Bounding box, volume | ### Gated Fusion ``` α = sigmoid(W_g[f; g] + b_g) h = α * W_f * f + (1-α) * W_g' * g ``` ### Weighted Prototype Network ``` p_c^init = mean(support_features) d_i = ||h_i - p_c^init||_2 w_i = exp(-d_i / τ) / Σ exp(-d_j / τ) p_c = Σ w_i * h_i P(y=c|x) = softmax(-||h - p_c||_2) ``` ## Expected Results | Configuration | Expected Trend | |---------------|----------------| | Full vs w/o geometric | +3-5% improvement | | Full vs w/o weighted prototype | +1-3% improvement | | Noise/occlusion robustness | Geometric features provide robustness | ## License MIT License