The maintainer has not written a description at the source.
Repo IntptrMax/SwapFighter, read from GitHub 1 min ago. IntptrMax has not joined Take My Repo.
IntptrMax/SwapFighter is a public repo on GitHub by IntptrMax. It declares the Apache-2.0 license on GitHub. It is written mainly in Python, has 13 stars and last changed on 2026-10-11. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-22.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
"Swap your backbone, fight for better detection."
SWAP-Fighter is a modular anchor-free framework inspired by FCOS and YOLOv8. It allows you to plug different timm backbones into a unified neck and decoupled multi-task head, supporting:
detect: horizontal bounding box detectionobb: oriented bounding box detection with angle predictionsegment: instance segmentation (YOLOv8-seg style)keypoint: multi-person pose estimation (YOLOv8-pose style)multilabel: multi-label image classificationlinear_probe: frozen-backbone linear probing for multi-label classificationChinese name: ζ₯倴ιΈη β because you can "connect" almost any backbone you want. δΈζθ―΄ζη±ζ€θΏε ₯
GitHub: https://github.com/IntptrMax/SwapFighter
timm (features_only=True).
See BackboneList.md for a curated list.detect: horizontal boxesobb: oriented boxes with angle regressionsegment: instance segmentation with prototype-based mask headkeypoint: pose estimation with per-keypoint branch (YOLOv8-pose style)multilabel: multi-label classificationlinear_probe: frozen backbone + linear/multi-layer head--head-channels projection)--neck-out-channels 64 128 256)detect/segment/keypoint: CIoU Loss + optional DFL.obb: CRIoU + ProbIoU or KLD Loss (selectable) + optional DFL.sin_cos: cosine loss + periodic L1 auxiliary lossdirect: periodic L1 lossproto_dim, proto_stride (2/4/8), mask_weightkpt_branch outputting normalized absolute coordinatesbias=0.5 initialization β initial prediction at image centergap, gem, attentionlinear, mlp, ml_decoderbce, asl (Asymmetric Loss)fp32, fp16, bf16GradScaler for fp16results.png panels (no empty subplots)--verbose-metrics: print per-class mAP table--grad-checkpointing: save GPU memory on large modelsdetect: mAP@0.5, mAP@0.5:0.95, AR@100 (YOLOv8-style)obb: rotated IoU mAP@0.5, mAP@0.5:0.95 (ProbIoU-based)segment: both bbox mAP and mask mAP (prototype-scale mask IoU)keypoint: both bbox mAP and OKS pose mAPmultilabel: mAP, CF1, OP, OR, OF1, EMRsimmim_pretrain.py pre-trains a backbone on unlabeled images.detect/obb: num_dets, boxes, scores, classes (end2end)segment: num_dets, boxes, scores, classes, mask_coefs, proto (end2end)keypoint: num_dets, boxes, scores, classes, keypoints (end2end)multilabel: logits (B, C) or probs (B, C) with --with-sigmoidinfer.py (auto-detects format from file suffix)The framework uses timm to access a wide range of pre-trained models. Any backbone supported by timm.create_model(..., features_only=True) can be used in principle.
See BackboneList.md for a curated list of tested backbones, including:
| Family | Example Names |
|---|---|
| ConvNeXtV2 (FCMAE) | convnextv2_atto.fcmae_ft_in1k, convnextv2_tiny.fcmae_ft_in1k |
| ConvNeXt | convnext_tiny, convnext_base |
| MobileNet | mobilenetv3_small_100, mobilenetv3_large_100 |
| ResNet / ResNeXt / ResNeSt | resnet50, resnext50_32x4d, resnest50 |
| Swin Transformer | swin_tiny_patch4_window7_224.ms_in1k |
| Hiera | hiera_small_abswin_256.sbb2_e200_in12k_ft_in1k |
| ViT | vit_base_patch16_224, vit_large_patch16_224 |
| DINOv2 / DINOv3 | vit_small_patch16_dinov3.lvd1689m, convnext_tiny.dinov3_lvd1689m |
| EfficientNet | efficientnet_b0 ~ b7, efficientnetv2_rw_s |
| Lightweight | ghostnet_100, fasternet_tiny |
Backbone feature selection is automatic:
ViTAdapter to build a multi-scale pyramid from the single-scale tokens.8, 16, 32.git clone https://github.com/IntptrMax/SwapFighter.git
cd SwapFighter
pip install -r requirements.txtCore requirements:
--simplify)No
shapelyortorchmetricsrequired β evaluation and rotated NMS are implemented in pure NumPy / PyTorch.
detect) and Oriented (obb) detectionYOLO-style folder structure:
datasets/
βββ your_dataset/
βββ images/
β βββ train/
β βββ val/
βββ labels/
βββ train/
βββ val/
Horizontal detection labels (detect):
class_id cx cy w h
Oriented detection labels (obb):
class_id x1 y1 x2 y2 x3 y3 x4 y4
All values normalized to [0, 1]. The loader also cross-accepts 5-column / 9-column formats.
segment)YOLOv8-seg polygon format:
class_id x1 y1 x2 y2 x3 y3 ... xn yn
All values normalized to [0, 1]. Each line is a polygon with at least 3 vertices. The dataset automatically rasterizes polygons to prototype-scale masks (img_size / proto_stride).
keypoint)YOLOv8-pose format β one line per instance:
# With visibility (3 values per keypoint)
class_id cx cy w h x1 y1 v1 x2 y2 v2 ... xK yK vK
# Without visibility (2 values per keypoint)
class_id cx cy w h x1 y1 x2 y2 ... xK yK
[0, 1].v β {0, 1, 2} where 0 = not labeled, 1 = labeled but occluded, 2 = visible.visibility='auto' auto-detects the format from the first few samples; override with --keypoint-visibility yes|no.--flip-idx should be supplied for left-right symmetric keypoints (e.g. COCO 17).multilabel / linear_probe)Two data sources: local txt files or HuggingFace datasets.
Local txt files:
datasets/
βββ your_multilabel_dataset/
βββ train2017/
βββ val2017/
βββ train_labels.txt
βββ val_labels.txt
Each line can be:
filename\t[0, 14, 26] (tab-separated, list of class ids)filename 0 0 1 0 1 ... (space-separated one-hot vector)HuggingFace datasets: must contain image and labels fields, optionally label_names. Use --hf-dataset, --hf-config, --hf-train-split, --hf-val-split.
datasets/
βββ unlabeled_images/
βββ any_subdir/
β βββ a.jpg
β βββ ...
βββ b.png
Supported extensions: .jpg, .jpeg, .png, .bmp.
python train.py \
--task detect \
--data-root ./datasets/my_data \
--backbone convnextv2_tiny.fcmae_ft_in1k \
--img-size 640 \
--batch-size 16 \
--epochs 100 \
--precision fp16 \
--save-dir ./outputspython train.py \
--task obb \
--data-root ./datasets/dota_like \
--backbone convnextv2_tiny.fcmae_ft_in1k \
--img-size 1024 \
--batch-size 8 \
--angle-format sin_cos \
--angle-range pi2 \
--obb-reg-loss probiou \
--save-dir ./outputspython train.py \
--task segment \
--data-root ./datasets/my_seg_data \
--num-classes 2 \
--backbone convnextv2_tiny.fcmae_ft_in1k \
--img-size 640 \
--batch-size 8 \
--proto-dim 32 \
--proto-stride 4 \
--mask-weight 5.0 \
--epochs 100 \
--precision fp16 \
--save-dir ./outputsKey segment options:
--proto-dim: prototype / mask coefficient channels (default 32; YOLOv8-seg uses 32).--proto-stride: prototype downsample stride, one of 2/4/8 (default 4). Smaller = finer masks, more VRAM.--mask-weight: mask loss weight (default 1.0; YOLOv8-seg uses 5.0).python train.py \
--task keypoint \
--data-root ./datasets/tiger-pose \
--num-classes 1 \
--num-keypoints 17 \
--backbone convnextv2_tiny.fcmae_ft_in1k \
--img-size 640 \
--batch-size 8 \
--keypoint-weight 12.0 \
--head-kpt-num-convs 3 \
--epochs 100 \
--precision fp16 \
--save-dir ./outputsKey keypoint options:
--num-keypoints: number of keypoints per instance (must match your labels).--keypoint-weight: keypoint loss weight (default 12.0, following YOLOv8-pose).--head-kpt-num-convs: number of conv layers in the keypoint branch (default 3).--keypoint-visibility: auto / yes / no.--flip-idx: list of keypoint indices for horizontal flip (e.g. for COCO 17: 0 2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15).python train.py \
--task multilabel \
--data-root ./datasets/multilabel_data \
--train-labels train_labels.txt \
--val-labels val_labels.txt \
--num-classes 20 \
--backbone convnextv2_atto.fcmae_ft_in1k \
--img-size 224 \
--batch-size 64 \
--loss asl \
--epochs 40 \
--save-dir ./outputsHuggingFace variant:
python train.py \
--task multilabel \
--hf-dataset ibrahimdaud/multi-label-food-recognition \
--num-classes 90 \
--backbone convnextv2_tiny.fcmae_ft_in1k \
--img-size 320 \
--loss bce \
--epochs 100 \
--save-dir ./outputspython train.py \
--task linear_probe \
--data-root ./datasets/multilabel_data \
--num-classes 20 \
--backbone vit_small_patch16_dinov3.lvd1689m \
--img-size 224 \
--batch-size 512 \
--epochs 20 \
--save-dir ./outputs--task detect|obb|segment|keypoint|multilabel|linear_probe--data-root, --backbone, --img-size, --batch-size, --epochs, --lr--precision fp32|fp16|bf16--optimizer sgd|adamw, --scheduler lambda|step|multistep|cosine|onecycle--patience, --resume, --no-ema, --save-dir--head-channels: shared head channels for detect/obb/segment/keypoint--neck-out-channels: single value or 3 values (e.g., 64 128 256)--grad-checkpointing: enable gradient checkpointing--verbose-metrics: print per-class mAP tableAny other config item can be overridden by appending key=value.
Training automatically creates a runX folder:
runX/
βββ best.pth
βββ last.pth
βββ training_log.csv # per-task columns
βββ config.json
βββ results.png # per-task panels
infer.py auto-detects the backend from the weights suffix (.pth/.pt β PyTorch, .onnx β ONNX). You can still override with --format pytorch|onnx.
python infer.py \
--task detect \
--weights ./outputs/detect/run1/best.pth \
--image path/to/image.jpg \
--conf 0.7 --nms 0.3 \
--output result.jpg \
--class-names pill capsule tabletpython infer.py \
--task obb \
--weights ./outputs/obb/run1/best.pth \
--image path/to/image.jpg \
--conf 0.5 \
--output result_obb.jpg \
--class-names plane ship vehiclepython infer.py \
--task segment \
--weights ./outputs/segment/run1/best.pth \
--image path/to/image.jpg \
--conf 0.5 \
--output result_seg.jpg \
--showSegmentation-specific flags:
--no-mask: skip mask visualization (bbox only)--mask-alpha: overlay alpha (0~1, default 0.5)python infer.py \
--task keypoint \
--weights ./outputs/keypoint/run1/best.pth \
--image path/to/person.jpg \
--conf 0.5 \
--output result_pose.jpg \
--showKeypoint-specific flags:
--no-kpt: skip keypoint visualization (bbox only)--kpt-radius: keypoint circle radius (default 6)--kpt-thr: visibility threshold (default 0.3)python infer.py \
--task multilabel \
--weights ./outputs/multilabel/run1/best.pth \
--image path/to/image.jpg \
--threshold 0.5 --top-k 5 \
--output result.jpg# Suffix .onnx β ONNX automatically, no --format needed
python infer.py \
--weights best_end2end.onnx \
--image test.jpg \
--conf 0.7 --nms 0.3 \
--class-names pill capsule tabletFor OBB, also pass --angle-format and --angle-range. For segment/keypoint, the ONNX predictor handles both raw and end2end outputs automatically.
Additional options:
--output-dir: save multiple images to a directory.--show: display result window.--show-size: max window width.--device cpu: force CPU inference.python export.py \
--weights ./outputs/detect/run1/best.pth \
--dynamic --simplifypython export.py \
--weights ./outputs/obb/run1/best.pth \
--dynamic --simplify# Raw mode (output0 + proto) python export.py --weights ./outputs/segment/run1/best.pth # End2end mode (NMS embedded) python export.py \ --weights ./outputs/segment/run1/best.pth \ --end2end --conf 0.25 --nms 0.5 --max-det 300
# Raw mode (output0) python export.py --weights ./outputs/keypoint/run1/best.pth # End2end mode (NMS embedded; keypoints output as pixel coordinates) python export.py \ --weights ./outputs/keypoint/run1/best.pth \ --end2end --conf 0.25 --nms 0.5 --max-det 300
# Default: outputs logits (B, C) python export.py \ --weights ./outputs/multilabel/run1/best.pth \ --dynamic --simplify # With embedded sigmoid: outputs probs (B, C) β (0, 1) python export.py \ --weights ./outputs/multilabel/run1/best.pth \ --with-sigmoid --dynamic --simplify # β best_probs.onnx
Why
--with-sigmoid? By default the exported graph outputs raw logits, which require asigmoidon the deployment side. If you want a zero-logic deployment (e.g. on TensorRT / NCNN / TFLite), export with--with-sigmoidto get probabilities directly. Thresholding and Top-K remain in the application layer.
detect: output0 (B, 4+nc, P) β [cx, cy, w, h, cls...]obb: output0 (B, 5+nc, P) β [cx, cy, w, h, angle, cls...]segment: output0 (B, 4+nc+k, P) + proto (B, k, ph, pw)keypoint: output0 (B, 4+nc+2K, P) β [cx, cy, w, h, cls..., kpt_norm...]multilabel: logits (B, num_classes) or probs (B, num_classes)--end2end):
detect/obb: num_dets, boxes, scores, classessegment: num_dets, boxes, scores, classes, mask_coefs, protokeypoint: num_dets, boxes, scores, classes, keypoints (all pixel coordinates)--conf, --nms, --max-det control its parameters.Metadata (backbone, img_size, mean, std, strides, proto_dim, proto_stride, num_keypoints, etc.) is embedded in the ONNX file. ONNXPredictor reads it back automatically β including whether the multilabel output is logits or probs.
python simmim_pretrain.py \
--data-dir ./datasets/unlabeled_images \
--backbone convnextv2_atto \
--img-size 224 \
--mask-patch-size 32 \
--mask-ratio 0.6 \
--epochs 100 \
--batch-size 64 \
--lr 1e-4 \
--output ./simmim_pretrained/convnextv2_atto_simmim.pthThen use the pre-trained weights:
python train.py \
--task detect \
--data-root ./datasets/my_data \
--backbone convnextv2_atto \
--pretrained-source simmim \
--backbone-pretrained-path ./simmim_pretrained/convnextv2_atto_simmim.pth \
--img-size 640 --batch-size 16 --epochs 100Use the same
--backbonein pre-training and downstream.img-sizedoes not need to match.
All hyperparameters are centralised in swapfighter/cfg/config.py. Task-specific defaults are in swapfighter/tasks/*.py.
Key parameters:
task: detect, obb, segment, keypoint, multilabel, linear_probedata_root, train_split, val_split, num_classesbackbone_name, pretrained, img_sizeneck_type, neck_num_layers, neck_out_channels, head_channelshead_type, head_norm_layer, head_act_layerwith_angle, angle_range, angle_formatreg_max, dfl_weight, obb_reg_lossproto_dim, proto_stride, mask_weight (segment)num_keypoints, keypoint_weight, keypoint_visibility, flip_idx (keypoint)batch_size, lr, backbone_lr_scale, weight_decay, epochswarmup_epochs, optimizer, schedulerprecision: fp32, fp16, bf16mosaic_prob, mosaic_disable_epochconf_threshold, nms_threshold, obb_nms_thresholdeval_map_start_epoch, eval_conf_threshold, verbose_metricspatience, use_ema, ema_decaytal_topk, tal_alpha, tal_betapool_type, head_type, loss, eval_threshold (multilabel)SWAP-Fighter/
βββ swapfighter/
β βββ api.py # SF class
β βββ cfg/
β β βββ config.py # Config class
β βββ tasks/ # Task registry and defaults
β β βββ __init__.py
β β βββ detect.py
β β βββ obb.py
β β βββ segment.py
β β βββ keypoint.py
β β βββ multilabel.py
β β βββ linear_probe.py
β βββ engine/
β β βββ base_trainer.py
β β βββ base_predictor.py
β β βββ trainers/
β β β βββ detect.py
β β β βββ segment.py
β β β βββ keypoint.py
β β β βββ multilabel.py
β β βββ predictors/
β β β βββ detect.py
β β β βββ segment.py
β β β βββ keypoint.py
β β β βββ multilabel.py
β β β βββ onnx.py
β β βββ exporters/
β β βββ onnx.py
β β βββ _onnx_impl.py
β βββ models/
β β βββ backbones.py
β β βββ backbones_vit_adapter.py
β β βββ necks/ # lightfpn, bifpn
β β βββ heads/ # decoupled, seg_decoupled, keypoint_decoupled, ml_decoder
β β βββ detectors/ # detect_fcos, detect_fcos_seg, detect_fcos_keypoint
β β βββ classifiers/ # multi_label
β βββ datasets/
β β βββ yolo_det.py
β β βββ yolo_seg.py
β β βββ yolo_keypoint.py
β β βββ cls_dataset.py
β βββ utils/
β βββ box_ops.py
β βββ mask_ops.py
β βββ losses.py
β βββ seg_losses.py
β βββ keypoint_loss.py
β βββ metrics.py
β βββ postprocess.py
β βββ logger.py
βββ train.py # Training entry
βββ infer.py # Inference entry (auto-detects format)
βββ export.py # ONNX export entry
βββ simmim_pretrain.py # SimMIM self-supervised pre-training
βββ requirements.txt
βββ README.md
βββ README.zh-CN.md
βββ BackboneList.md
--use-amp flag is replaced by --precision.fp16 uses GradScaler automatically; bf16 requires Ampere or newer.shapely.cv2.resize upsampling) for speed and consistency.boxes and keypoints, matching Segment's convention.logits by default; use --with-sigmoid to embed Sigmoid and get probs (B, C).infer.py auto-selects pytorch / onnx by weights suffix (.pth/.pt β pytorch, .onnx β onnx). Override with --format.results.png panels are per-task β no empty columns/subplots.Contributions are welcome! Please open an issue or PR at https://github.com/IntptrMax/SwapFighter.
This project is licensed under the Apache 2.0 License β see the LICENSE file for details.
Happy Swapping! π
IntptrMax/SwapFighter is a public repo on GitHub by IntptrMax. Its maker has not written a description.
It declares the Apache-2.0 license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-10-11. GitHub counts 1 open issue and pull requests. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Use Stable Diffusion with C#
This is a simple C# demo for stable-diffusion.cpp with safe code only.