|
37 | 37 | from workflows.anomaly_detection import Anodec |
38 | 38 | from workflows.auto_labeling import ( |
39 | 39 | CustomCoDETRObjectDetection, |
| 40 | + CustomRFDETRObjectDetection, |
40 | 41 | HuggingFaceObjectDetection, |
41 | 42 | UltralyticsObjectDetection, |
42 | 43 | ZeroShotObjectDetection, |
@@ -686,6 +687,7 @@ def execute(self) -> bool: |
686 | 687 | "hf_models_objectdetection", |
687 | 688 | "ultralytics", |
688 | 689 | "custom_codetr", |
| 690 | + "roboflow", |
689 | 691 | ] |
690 | 692 |
|
691 | 693 | # Common parameters between models |
@@ -832,6 +834,79 @@ def execute(self) -> bool: |
832 | 834 | self.dataset, self.dataset_info, run_config |
833 | 835 | ) |
834 | 836 |
|
| 837 | + if SUPPORTED_MODEL_SOURCES[3] in selected_model_source: |
| 838 | + |
| 839 | + config_rfdetr = config_autolabel["roboflow"] |
| 840 | + |
| 841 | + # Shared config parameters |
| 842 | + shared_config = { |
| 843 | + "epochs": config_autolabel["epochs"], |
| 844 | + "learning_rate": config_autolabel["learning_rate"], |
| 845 | + "weight_decay": config_autolabel["weight_decay"], |
| 846 | + "early_stop_patience": config_autolabel["early_stop_patience"], |
| 847 | + "early_stop_threshold": config_autolabel["early_stop_threshold"], |
| 848 | + } |
| 849 | + |
| 850 | + run_config = { |
| 851 | + "export_dataset_root": config_rfdetr["export_dataset_root"], |
| 852 | + "mode": config_autolabel["mode"], |
| 853 | + "inference_settings": config_autolabel["inference_settings"], |
| 854 | + "config": None, |
| 855 | + # RF-DETR specific parameters |
| 856 | + "batch_size": config_rfdetr["batch_size"], |
| 857 | + "grad_accum_steps": config_rfdetr["grad_accum_steps"], |
| 858 | + "lr_encoder": config_rfdetr["lr_encoder"], |
| 859 | + "resolution": config_rfdetr["resolution"], |
| 860 | + "use_ema": config_rfdetr["use_ema"], |
| 861 | + "gradient_checkpointing": config_rfdetr["gradient_checkpointing"], |
| 862 | + "early_stopping_min_delta": config_rfdetr["early_stopping_min_delta"], |
| 863 | + "early_stopping_use_ema": config_rfdetr["early_stopping_use_ema"], |
| 864 | + } |
| 865 | + |
| 866 | + rfdetr_configs = config_rfdetr["configs"] |
| 867 | + |
| 868 | + for config in ( |
| 869 | + pbar := tqdm(rfdetr_configs, desc="Processing RF-DETR configurations") |
| 870 | + ): |
| 871 | + pbar.set_description(f"RF-DETR model {config}") |
| 872 | + run_config["config"] = config |
| 873 | + |
| 874 | + try: |
| 875 | + wandb_exit_code = 0 |
| 876 | + wandb_run = wandb_init( |
| 877 | + run_name=config, |
| 878 | + project_name="RF-DETR Auto Labeling", |
| 879 | + dataset_name=self.dataset_info["name"], |
| 880 | + config=run_config, |
| 881 | + wandb_activate=True, |
| 882 | + ) |
| 883 | + |
| 884 | + detector = CustomRFDETRObjectDetection( |
| 885 | + self.dataset, self.dataset_info, run_config |
| 886 | + ) |
| 887 | + |
| 888 | + # Convert data to RF-DETR format |
| 889 | + detector.convert_data() |
| 890 | + |
| 891 | + # Training |
| 892 | + if "train" in mode: |
| 893 | + logging.info(f"Training RF-DETR model: {config}") |
| 894 | + detector.train(run_config, shared_config) |
| 895 | + |
| 896 | + # Inference |
| 897 | + if "inference" in mode: |
| 898 | + logging.info(f"Running inference for RF-DETR model: {config}") |
| 899 | + detector.inference( |
| 900 | + inference_settings=config_autolabel["inference_settings"] |
| 901 | + ) |
| 902 | + |
| 903 | + except Exception as e: |
| 904 | + logging.error(f"Error during RF-DETR workflow with {config}: {e}") |
| 905 | + wandb_exit_code = 1 |
| 906 | + finally: |
| 907 | + wandb_close(wandb_exit_code) |
| 908 | + |
| 909 | + |
835 | 910 | elif workflow == "auto_labeling_zero_shot": |
836 | 911 | config = WORKFLOWS["auto_labeling_zero_shot"] |
837 | 912 | workflow_zero_shot_object_detection( |
|
0 commit comments