Downloads · 30 days
0
MRiabov/WireSegHR
WireSegHR is a image segmentation model from MRiabov. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as apache-2.0.
This repository contains the segmentation-only implementation of the two-stage WireSegHR model, training on the WireSegHR dataset plus the TTPLA dataset.
Downloads · 30 days
0
Access
Public
Updated Sep 4, 2025
Repo size
500 MB
Likes
0
Public
Click a slice to open those files.
.pt308 MB · 68%
From the Hugging Face model README
This repository contains the segmentation-only implementation of the two-stage WireSegHR model, training on the WireSegHR dataset plus the TTPLA dataset.
You'll need a GDrive service account to fetch the WireSegHR dataset using scripts in this repo. Get a GDrive key as described in this short README, and put it in /secrets/drive-json.json
scripts/setup.sh
This installs dependencies and merges the TTPLA dataset into the WireSegHR dataset format.
python3 train.py --config configs/default.yaml
python3 infer.py --config configs/default.yaml --image /path/to/image.jpg
The default config default.yaml is suitable for a 24GB VRAM GPU with support for bf16 (e.g., RTX 3090/4090).
train.py).src/wireseghr/data/ and model components under src/wireseghr/model/.paper-tex/ (paper-tex/sections/ contains the Method, Results, etc.).nvidia/mit-b3). We set num_channels to match input channels.backbone: resnet50). The stem is adapted to the requested in_channels, and we expose features from layer1..layer4 at strides 1/4, 1/8, 1/16, 1/32 with channels [256, 512, 1024, 2048]..jpg/.jpeg, masks are .png.dataset/train/images/1.jpg, 2.jpg, ... and dataset/train/gts/1.png, 2.png, ...dataset/val/images/... and dataset/val/gts/...dataset/test/images/... and dataset/test/gts/...Update configs/default.yaml with your paths under data.train_images, data.train_masks, etc. Defaults point to dataset/train/images, dataset/train/gts, and validation to dataset/val/....
python3 infer.py \
--config configs/default.yaml \
--ckpt ckpt_5000.pt \
--image dataset/test/images/123.jpg \
--out outputs/infer
python3 infer.py \
--config configs/default.yaml \
--ckpt ckpt_5000.pt \
--image dataset/test/images/123.jpg \
--out outputs/infer \
--metrics \
--mask dataset/test/gts/123.png
python3 infer.py \
--config configs/default.yaml \
--ckpt ckpt_5000.pt \
--images_dir dataset/test/images \
--out outputs/infer \
--metrics \
--masks_dir dataset/test/gts
Notes:
> 0 to match training logic.images/123.jpg ↔ gts/123.png.Benchmark mode times the model on a directory of images and reports coarse/fine/total latency statistics. When --metrics is provided, it also computes IoU/F1/Precision/Recall over the benchmark set (both fine and coarse outputs).
Example (uses data.test_images and data.test_masks from the config by default):
python3 infer.py \
--config configs/default.yaml \
--benchmark \
--ckpt ckpt_5000.pt \
--bench_warmup 2 \
--bench_limit 0 \
--bench_report_json outputs/bench_report.json \
--metrics
If your ground truth directory is different from data.test_masks, please override it with --bench_masks_dir:
python3 infer.py \
--config configs/default.yaml \
--benchmark \
--ckpt ckpt_5000.pt \
--bench_warmup 2 \
--bench_limit 0 \
--bench_report_json outputs/bench_report.json \
--metrics \
--bench_masks_dir /path/to/gts
You will see output like:
[WireSegHR][bench] Results (ms):
Coarse avg=50.16 p50=44.48 p95=76.78
Fine avg=534.38 p50=419.52 p95=1187.66
Total avg=584.54 p50=464.73 p95=1300.07
Target < 1000 ms per 3000x4000 image: YES
[WireSegHR][bench][Fine] IoU=0.6098 F1=0.7576 P=0.6418 R=0.9244
[WireSegHR][bench][Coarse] IoU=0.5315 F1=0.6941 P=0.5467 R=0.9502
*These metrics were obtained after 5000 iterations
Optional: you can save a JSON timing report with --bench_report_json. Schema:
summary
avg_ms, p50_ms, p95_msavg_coarse_ms, avg_fine_msimagesper_image: list of objects with
path, H, W, t_coarse_ms, t_fine_ms, t_total_msInput: <img src="images/026_input.png" alt="Input" width="50%"/>
Fine prediction: <img src="images/026_fine_pred.png" alt="Fine prediction" width="50%"/>