{"id":22615547,"url":"https://github.com/sovit-123/detr-custom-training","last_synced_at":"2026-03-16T15:40:49.986Z","repository":{"id":65409556,"uuid":"591725560","full_name":"sovit-123/detr-custom-training","owner":"sovit-123","description":"Training DETR (Detection Transformer) on custom object detection datasets.","archived":false,"fork":false,"pushed_at":"2023-02-08T16:24:24.000Z","size":85,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T00:13:46.337Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sovit-123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-21T17:09:28.000Z","updated_at":"2024-10-25T23:51:16.000Z","dependencies_parsed_at":"2023-02-12T14:16:57.683Z","dependency_job_id":null,"html_url":"https://github.com/sovit-123/detr-custom-training","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sovit-123/detr-custom-training","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fdetr-custom-training","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fdetr-custom-training/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fdetr-custom-training/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fdetr-custom-training/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sovit-123","download_url":"https://codeload.github.com/sovit-123/detr-custom-training/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fdetr-custom-training/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267107895,"owners_count":24037342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-08T19:08:21.296Z","updated_at":"2026-03-16T15:40:44.947Z","avatar_url":"https://github.com/sovit-123.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Training DETR (Detection Transformer)\n\n\n\nA repository for training DETR on custom datasets.\n\nSoon to be merged with the [Vision Transformers](https://github.com/sovit-123/vision_transformers) library. Some experiments for learning rate and transformer layer tuning may still continue here. **But all the major updates will be integrated into [Vision Transformers](https://github.com/sovit-123/vision_transformers)**.\n\n## Currently Supported Models\n\n* `detr_resnet50`\n* `detr_resnet50_dc5`\n* `detr_resnet101`\n* `detr_resnet101_dc5`\n\nAll the models are loaded from PyTorch Hub - `facebookresearch/detr`.\n\n## Quick Setup\n\n```\ngit clone https://github.com/sovit-123/detr-custom-training.git\n```\n\n**Recommended to install [PyTorch 1.12.0 and Torchvision 0.13.0 from official](https://pytorch.org/get-started/previous-versions/#v1120) website with CUDA support and then do**:  \n\n```\npip install -r requirements.txt\n```\n\n## Custom Training\n\n* Check how to prepare dataset?\n\n```\npython train.py --epochs 100 --data data/custom_data.yaml --name custom_data\n```\n\n## Inference on Images\n\n* Pretrained model inference\n\n```\npython inference.py --input path/to/image\n```\n\n* Using custom trained model (`--weights` should correspond to the correct `--model` )\n\n```\npython inference.py --input path/to/image --weights outputs/training/custom_training/best_model.pth --model detr_resnet50\n                                                                                                            detr_resnet50_dc5\n                                                                                                            detr_resnet101\n                                                                                                            detr_resnet101_dc5\n```\n\n## Inference on Videos\n\n* Pretrained model inference\n\n```\npython inference_video.py --input path/to/video\n```\n\n* sing custom trained model (`--weights` should correspond to the correct `--model` )\n\n```\npython inference.py --input path/to/video --weights outputs/training/custom_training/best_model.pth --model detr_resnet50\n                                                                                                            detr_resnet50_dc5\n                                                                                                            detr_resnet101\n                                                                                                            detr_resnet101_dc5\n```\n\n## Custom Dataset Preparation\n\nThe content of the `custom_data.yaml` (in `data` directory) should be the following:\n\n```\n# Images and labels direcotry should be relative to train.py\nTRAIN_DIR_IMAGES: ../custom_data/train/images\nTRAIN_DIR_LABELS: ../custom_data/train/annotations\n# VALID_DIR should be relative to train.py\nVALID_DIR_IMAGES: ../custom_data/valid/images\nVALID_DIR_LABELS: ../custom_data/valid/annotations\n\n# Class names.\nCLASSES: [\n    '__background__',\n    'smoke'\n]\n\n# Number of classes (object classes + 1 for background class).\nNC: 2\n\n# Whether to save the predictions of the validation set while training.\nSAVE_VALID_PREDICTION_IMAGES: True\n```\n\n* `images` directory should contain all the images.\n* `annotations` directory should contain all the annotations in XML format (similar to Pascal VOC XML files).\n* **OR** both images and annotations can be in the same directory for a particular split (train/valid). Just provide the same path in the *DIR_IMAGES and *DIR_LABELS attribute in the YAML file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsovit-123%2Fdetr-custom-training","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsovit-123%2Fdetr-custom-training","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsovit-123%2Fdetr-custom-training/lists"}