- Install the project by
python install setup.py
- Create dictionaries to configure:
algorithm_config
: your detection algorithm parameters, e.g.,weight_analysis
,mask_generation
,attribution_analysis
, etc.model_config
: your detector model parameters, e.g,input_size
,model_class
, etc.learner_config
: detector model training parameters, e.g.,batch_size
,epochs
, etc.optimizer_config
: detector model optimization parameters, e.g.,lr
,momentum
, etc.data_config
: detector dataset parameters, e.g.,number of splits
,max_train_samples
, etc.
- Import
depend
library and create a select dependent such asmask_gen
.
from depend import MaskGen, DPConfig
dependent = MaskGen(model_file_location)
config = DP_Config.from_dict(model_config, learner_config, algorithm_config, optimizer_config, data_config)
dependent.configure(config)
- To train trojan detector
dependent.train_detector()
- To infer with pretrained trojan detector, load the detector from path and run.
probabilities = dependent.infer(detector_path, target_models_path)
- Install poery
$pip install poetry
- Use
poetry cache clear --all .
to clean poetry cache if poetry takes too long to search for a library