def register_datasets(backend): """Import and register datasets automatically.""" if backend == "pytorch": from . import pytorch elif backend == "tensorflow": from . import tensorflow elif backend == "mindspore": import mindspore.dataset from . import mindspore ClassFactory.lazy_register("vega.datasets.common", {"imagenet": ["Imagenet"]}) from . import common from . import transforms
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import loss functions.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.networks.pytorch.losses", { "sum_loss": ["trainer.loss:SumLoss"], "smooth_l1_loss": ["trainer.loss:SmoothL1Loss"], "custom_cross_entropy_loss": ["trainer.loss:CustomCrossEntropyLoss"], "cross_entropy_label_smooth": ["trainer.loss:CrossEntropyLabelSmooth"], "mix_auxiliary_loss": ["trainer.loss:MixAuxiliaryLoss"], })
"""Lazy import tensorflow networks.""" from .network import Sequential from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.networks.tensorflow", { "resnet_tf": ["ResNetTF", 'ResNetSlim'], # backbones "backbones.resnet_det": ["ResNetDet"], # customs "customs.edvr.edvr": ["EDVR"], "customs.gcn_regressor": ["GCNRegressor"], # detectors "detectors.faster_rcnn_trainer_callback": ["FasterRCNNTrainerCallback"], "detectors.faster_rcnn": ["FasterRCNN"], "detectors.tf_optimizer": ["TFOptimizer"], # losses "losses.cross_entropy_loss": ["CrossEntropyLoss"], "losses.mix_auxiliary_loss": ["MixAuxiliaryLoss"], "losses.charbonnier": ["CharbonnierLoss"], # necks "necks.mask_rcnn_box": ["MaskRCNNBox"], }) ClassFactory.lazy_register( "vega.networks.tensorflow.utils", { "anchor_utils.anchor_generator": ["AnchorGenerator"], "hyperparams.initializer": ["Initializer"],
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import mindspore network.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.networks.mindspore", { "dnet": ["DNet"], "super_network": ["DartsNetwork", "CARSDartsNetwork", "GDASDartsNetwork"], "backbones.load_official_model": ["OffcialModelLoader"], "backbones.resnet_ms": ["ResNetMs"], "losses.mix_auxiliary_loss": ["MixAuxiliaryLoss"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Import and register evaluator automatically.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.evaluator", { "device_evaluator": ["DeviceEvaluator"], "host_evaluator": ["HostEvaluator"], "evaluator": ["Evaluator"], })
from .search_algorithm import SearchAlgorithm from .ea_conf import EAConfig from .pareto_front_conf import ParetoFrontConfig from .pareto_front import ParetoFront from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.core.search_algs", { "ps_differential": ["DifferentialAlgorithm"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import detector.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.networks.pytorch.detectors", { "auto_lane_detector": ["AutoLaneDetector"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Import and register modules automatically.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.modules", { "module": ["network:Module"], }) def register_modules(): """Import and register modules automatically.""" from . import blocks from . import cells from . import connections from . import operators from . import preprocess from . import loss from . import getters from . import necks from . import backbones from . import distillation
from .metrics import Metrics from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.metrics.pytorch", { "lane_metric": ["trainer.metric:LaneMetric"], "regression": ["trainer.metric:MSE", "trainer.metric:mse"], "detection_metric": ["trainer.metric:CocoMetric", "trainer.metric:coco"], "gan_metric": ["trainer.metric:GANMetric"], "classifier_metric": ["trainer.metric:accuracy", "trainer.metric:Accuracy", "trainer.metric:SklearnMetrics"], "auc_metrics": ["trainer.metric:AUC", "trainer.metric:auc"], "segmentation_metric": ["trainer.metric:IoUMetric"], "sr_metric": ["trainer.metric:PSNR", "trainer.metric:SSIM"], "r2score": ["trainer.metric:r2score", "trainer.metric:R2Score"], "nlp_metric": ["trainer.metric:accuracy_score", "trainer.metric:f1_score", "trainer.metric:NlpMetrics"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import hpo algorithms.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.algorithms.hpo", { "asha_hpo": ["AshaHpo"], "bohb_hpo": ["BohbHpo"], "boss_hpo": ["BossHpo"], "random_hpo": ["RandomSearch"], "evolution_search": ["EvolutionAlgorithm"], "pbt_hpo": ["PBTHpo"], "pbt_trainer_callback": ["PbtTrainerCallback"], "sha_base.hebo_adaptor": ["HeboAdaptor"], })
ClassFactory.lazy_register( "vega.datasets.transforms", { # common "AutoAugment": ["AutoAugment"], "AutoContrast": ["AutoContrast"], "BboxTransform": ["BboxTransform"], "Brightness": ["Brightness"], "Color": ["Color"], "Compose": ["Compose", "ComposeAll"], "Compose_pair": ["Compose_pair"], "Contrast": ["Contrast"], "Cutout": ["Cutout"], "Equalize": ["Equalize"], "RandomCrop_pair": ["RandomCrop_pair"], "RandomHorizontalFlip_pair": ["RandomHorizontalFlip_pair"], "RandomMirrow_pair": ["RandomMirrow_pair"], "RandomRotate90_pair": ["RandomRotate90_pair"], "RandomVerticallFlip_pair": ["RandomVerticallFlip_pair"], "RandomColor_pair": ["RandomColor_pair"], "RandomRotate_pair": ["RandomRotate_pair"], "Rescale_pair": ["Rescale_pair"], "Normalize_pair": ["Normalize_pair"], # GPU only "ImageTransform": ["ImageTransform"], "Invert": ["Invert"], "MaskTransform": ["MaskTransform"], "Posterize": ["Posterize"], "Rotate": ["Rotate"], "SegMapTransform": ["SegMapTransform"], "Sharpness": ["Sharpness"], "Shear_X": ["Shear_X"], "Shear_Y": ["Shear_Y"], "Solarize": ["Solarize"], "Translate_X": ["Translate_X"], "Translate_Y": ["Translate_Y"], "RandomGaussianBlur_pair": ["RandomGaussianBlur_pair"], "RandomHorizontalFlipWithBoxes": ["RandomHorizontalFlipWithBoxes"], "Resize": ["Resize"], "RandomCrop": ["RandomCrop"], "RandomHorizontalFlip": ["RandomHorizontalFlip"], "Normalize": ["Normalize"], "ToTensor": ["ToTensor"], })
from .metrics import Metrics from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.metrics.tensorflow", { "segmentation_metric": ["trainer.metric:IoUMetric"], "classifier_metric": ["trainer.metric:accuracy"], "sr_metric": ["trainer.metric:PSNR", "trainer.metric:SSIM"], "forecast": ["trainer.metric:MSE", "trainer.metric:RMSE"], "r2score": ["trainer.metric:r2score", "trainer.metric:R2Score"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import pytorch backbones.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.networks.pytorch.backbones", { "getter": ["BackboneGetter", "ResNetBackbone"], "load_official_model": ["OffcialModelLoader"], "resnet_variant_det": ["ResNetVariantDet"], "resnext_variant_det": ["ResNeXtVariantDet"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import ops.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.networks.pytorch.ops", { "fmdunit": ["network:FMDUnit", "network:LinearScheduler"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import pytorch blocks.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.networks.pytorch.blocks", { "block": ["Block"], "conv_ws": ["ConvWS2d"], "stem": ['PreTwoStem'], })
from .metrics import Metrics from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.metrics.mindspore", { "segmentation_metric": ["trainer.metric:IoUMetric"], "classifier_metric": ["trainer.metric:accuracy"], "sr_metric": ["trainer.metric:PSNR", "trainer.metric:SSIM"], })
from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.datasets.pytorch", { "coco_transforms": ["CocoCategoriesTransform", "PolysToMaskTransform"], })
ClassFactory.lazy_register( "vega.networks", { "adelaide": ["AdelaideFastNAS"], "bert": [ "BertClassification", "TinyBertForPreTraining", "BertClassificationHeader" ], "dnet": ["DNet", "DNetBackbone"], "erdb_esr": ["ESRN"], "faster_backbone": ["FasterBackbone"], "faster_rcnn": ["FasterRCNN"], "mobilenet": ["MobileNetV3Tiny", "MobileNetV2Tiny"], "mobilenetv3": ["MobileNetV3Small", "MobileNetV3Large"], "necks": ["FPN"], "quant": ["Quantizer"], "resnet_det": ["ResNetDet"], "resnet_general": ["ResNetGeneral"], "resnet": ["ResNet"], "resnext_det": ["ResNeXtDet"], "sgas_network": ["SGASNetwork"], "simple_cnn": ["SimpleCnn"], "spnet_backbone": ["SpResNetDet"], "super_network": ["DartsNetwork", "CARSDartsNetwork", "GDASDartsNetwork"], "text_cnn": ["TextCells", "TextCNN"], "gcn": ["GCN"], "vit": ["VisionTransformer"], "mtm_sr": ["MtMSR"], })
from .callback import Callback from .callback_list import CallbackList from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.trainer.callbacks", { "metrics_evaluator": ["trainer.callback:MetricsEvaluator"], "progress_logger": ["trainer.callback:ProgressLogger"], "performance_saver": ["trainer.callback:PerformanceSaver"], "lr_scheduler": ["trainer.callback:LearningRateScheduler"], "model_builder": ["trainer.callback:ModelBuilder"], "model_statistics": ["trainer.callback:ModelStatistics"], "model_checkpoint": ["trainer.callback:ModelCheckpoint"], "report_callback": ["trainer.callback:ReportCallback"], "runtime_callback": ["trainer.callback:RuntimeCallback"], "detection_progress_logger": ["trainer.callback:DetectionProgressLogger"], "detection_metrics_evaluator": ["trainer.callback:DetectionMetricsEvaluator"], "visual_callback": ["trainer.callback:VisualCallBack"], "model_tuner": ["trainer.callback:ModelTuner"], "timm_trainer_callback": ["trainer.callback:TimmTrainerCallback"], })
# This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import nas algorithms.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.algorithms.nas", { "adelaide_ea": ["AdelaideCodec", "AdelaideMutate", "AdelaideRandom", "AdelaideEATrainerCallback"], "auto_lane": ["AutoLaneNas", "AutoLaneNasCodec", "AutoLaneTrainerCallback"], "backbone_nas": ["BackboneNasCodec", "BackboneNasSearchSpace", "BackboneNas"], "cars": ["CARSAlgorithm", "CARSTrainerCallback", "CARSPolicyConfig"], "darts_cnn": ["DartsCodec", "DartsFullTrainerCallback", "DartsNetworkTemplateConfig", "DartsTrainerCallback"], "dnet_nas": ["DblockNasCodec", "DblockNas", "DnetNasCodec", "DnetNas"], "esr_ea": ["ESRCodec", "ESRTrainerCallback", "ESRSearch"], "fis": ["AutoGateGrdaS1TrainerCallback", "AutoGateGrdaS2TrainerCallback", "AutoGateS1TrainerCallback", "AutoGateS2TrainerCallback", "AutoGroupTrainerCallback", "CtrTrainerCallback"], "mfkd": ["MFKD1", "SimpleCnnMFKD"], "modnas": ["ModNasAlgorithm", "ModNasTrainerCallback"], "segmentation_ea": ["SegmentationCodec", "SegmentationEATrainerCallback", "SegmentationNas"], "sgas": ["SGASTrainerCallback"], "sm_nas": ["SmNasCodec", "SMNasM"], "sp_nas": ["SpNasS", "SpNasP"], "sr_ea": ["SRCodec", "SRMutate", "SRRandom"], "mfasc": ["search_algorithm:MFASC"] })
# it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import dataset.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.datasets.common", { "avazu": ["AvazuDataset"], "cifar10": ["Cifar10"], "cifar100": ["Cifar100"], "div2k": ["DIV2K"], "cls_ds": ["ClassificationDataset"], "cityscapes": ["Cityscapes"], "div2k_unpair": ["Div2kUnpair"], "fmnist": ["FashionMnist"], # "imagenet": ["Imagenet"], "mnist": ["Mnist"], "sr_datasets": ["Set5", "Set14", "BSDS100"], "auto_lane_datasets": ["AutoLaneDataset"], "coco": ["CocoDataset", "DetectionDataset"], "glue": ["GlueDataset"], "spatiotemporal": ["SpatiotemporalDataset"], "reds": ["REDS"], "nasbench": ["Nasbench"], })
from .loss import Loss from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.modules.loss", { "multiloss": ["trainer.loss:MultiLoss", "trainer.loss:SingleLoss"], "focal_loss": ["trainer.loss:FocalLoss"], "f1_loss": ["trainer.loss:F1Loss"], "forecast_loss": ["trainer.loss:ForecastLoss"], "mean_loss": ["trainer.loss:MeanLoss"], "ProbOhemCrossEntropy2d": ["trainer.loss:ProbOhemCrossEntropy2d"], "gan_loss": ["trainer.loss:GANLoss"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import data augmentation algorithms.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.algorithms.data_augmentation", { "pba_hpo": ["PBAHpo"], "pba_trainer_callback": ["PbaTrainerCallback"], "cyclesr": ["CyclesrTrainerCallback"], })
# -*- coding:utf-8 -*- from .pipe_step import PipeStep from .pipeline import Pipeline from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.core.pipeline", { "search_pipe_step": ["SearchPipeStep"], "train_pipe_step": ["TrainPipeStep"], "benchmark_pipe_step": ["BenchmarkPipeStep"], "multi_task_pipe_step": ["MultiTaskPipeStep"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import necks.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.networks.pytorch.necks", { "ffm": ["network:FeatureFusionModule"], "fpn": ["FPN"] })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import compression algorithms.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.algorithms.compression", { "prune_ea": ["PruneCodec", "PruneEA", "PruneSearchSpace", "PruneTrainerCallback"], "prune_ea_mobilenet": ["PruneMobilenetCodec", "PruneMobilenetTrainerCallback"], "quant_ea": ["QuantCodec", "QuantEA", "QuantTrainerCallback"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import custom network.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.networks.pytorch.customs", { "nago": ["network:NAGO"], "deepfm": ["network:DeepFactorizationMachineModel"], "autogate": ["network:AutoGateModel"], "autogroup": ["network:AutoGroupModel"], "bisenet": ["network:BiSeNet"], "modnas": ["network:ModNasArchSpace"], "mobilenetv2": ["network:MobileNetV2"], "gcn_regressor": ["network:GCNRegressor"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Import and register trainer automatically.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.trainer", { "trainer_torch": ["TrainerTorch"], "trainer_tf": ["TrainerTf"], "trainer_ms": ["TrainerMs"], "trainer": ["Trainer"], "script_runner": ["ScriptRunner"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import head network.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register( "vega.networks.pytorch.heads", { "auto_lane_head": ["network:AutoLaneHead"], "auxiliary_head": ["network:AuxiliaryHead"], })
# -*- coding:utf-8 -*- # Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved. # This program is free software; you can redistribute it and/or modify # it under the terms of the MIT License. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MIT License for more details. """Lazy import gan network.""" from vega.common.class_factory import ClassFactory ClassFactory.lazy_register("vega.networks.pytorch.gan", { "fully_super_network": ["network:Generator"], })