openvinotoolkit / anomalib

An anomaly detection library comprising state-of-the-art algorithms and features such as experiment management, hyper-parameter optimization, and edge inference.
https://anomalib.readthedocs.io/en/latest/
Apache License 2.0
3.68k stars 654 forks source link

Custom Dataset Config-Files have wrong structure? omegaconf.errors.ConfigAttributeError: Missing key model,object_type=dict #679

Closed monkeycc closed 1 year ago

monkeycc commented 1 year ago

Describe the bug

To Reproduce

Steps to reproduce the behavior:

cflow Rename AI

  1. python tools/train.py --config anomalib/models/AI/config.yaml

  2. error

    Traceback (most recent call last):
    File "tools/train.py", line 71, in <module>
    train()
    File "tools/train.py", line 49, in train
    config = get_configurable_parameters(model_name=args.model, config_path=args.config)
    File "D:\anaconda3ok\envs\anomalib_env\lib\site-packages\anomalib\config\config.py", line 139, in get_configurable_parameters
    config = update_input_size_config(config)
    File "D:\anaconda3ok\envs\anomalib_env\lib\site-packages\anomalib\config\config.py", line 32, in update_input_size_config
    config.model.input_size = config.dataset.image_size
    File "D:\anaconda3ok\envs\anomalib_env\lib\site-packages\omegaconf\dictconfig.py", line 355, in __getattr__
    self._format_and_raise(
    File "D:\anaconda3ok\envs\anomalib_env\lib\site-packages\omegaconf\base.py", line 231, in _format_and_raise
    format_and_raise(
    File "D:\anaconda3ok\envs\anomalib_env\lib\site-packages\omegaconf\_utils.py", line 900, in format_and_raise
    _raise(ex, cause)
    File "D:\anaconda3ok\envs\anomalib_env\lib\site-packages\omegaconf\_utils.py", line 798, in _raise
    raise ex.with_traceback(sys.exc_info()[2])  # set env var OC_CAUSE=1 for full trace
    File "D:\anaconda3ok\envs\anomalib_env\lib\site-packages\omegaconf\dictconfig.py", line 351, in __getattr__
    return self._get_impl(
    File "D:\anaconda3ok\envs\anomalib_env\lib\site-packages\omegaconf\dictconfig.py", line 442, in _get_impl
    node = self._get_child(
    File "D:\anaconda3ok\envs\anomalib_env\lib\site-packages\omegaconf\basecontainer.py", line 73, in _get_child
    child = self._get_node(
    File "D:\anaconda3ok\envs\anomalib_env\lib\site-packages\omegaconf\dictconfig.py", line 480, in _get_node
    raise ConfigKeyError(f"Missing key {key!s}")
    omegaconf.errors.ConfigAttributeError: Missing key model
    full_key: model
    object_type=dict
  3. configuration file


dataset:
  name: AI
  format: folder
  path: F:/mvtec_anomaly_detection/AI/
  normal_dir: OK # name of the folder containing normal images.
  abnormal_dir: NG # name of the folder containing abnormal images.
  normal_test_dir: CS # name of the folder containing normal test images.
  task: segmentation # classification or segmentation
  mask: null #optional
  extensions: null
  split_ratio: 0.2 # ratio of the normal images that will be used to create a test split
  image_size: 256
  train_batch_size: 128
  test_batch_size: 128
  inference_batch_size: 128
  fiber_batch_size: 256
  num_workers: 8
  transform_config:
    train: null
    val: null
  create_validation_set: false
  tiling:
    apply: false
    tile_size: null
    stride: null
    remove_border_count: 0
    use_random_tiling: False
    random_tile_count: 16

model:
  name: cflow
  backbone: wide_resnet50_2
  pre_trained: true
  layers:
    - layer2
    - layer3
    - layer4
  decoder: freia-cflow
  condition_vector: 128
  coupling_blocks: 8
  clamp_alpha: 1.9
  soft_permutation: false
  lr: 0.0001
  early_stopping:
    patience: 2
    metric: pixel_AUROC
    mode: max
  normalization_method: min_max # options: [null, min_max, cdf]

metrics:
  image:
    - F1Score
    - AUROC
  pixel:
    - F1Score
    - AUROC
  threshold:
    method: adaptive #options: [adaptive, manual]
    manual_image: null
    manual_pixel: null

visualization:
  show_images: False # show images on the screen
  save_images: True # save images to the file system
  log_images: True # log images to the available loggers (if any)
  image_save_path: null # path to which images will be saved
  mode: full # options: ["full", "simple"]

project:
  seed: 0
  path: ./results

logging:
  logger: [] # options: [comet, tensorboard, wandb, csv] or combinations.
  log_graph: false # Logs the model graph to respective logger.

optimization:
  export_mode: null #options: onnx, openvino

# PL Trainer Args. Don't add extra parameter here.
trainer:
  accelerator: auto # <"cpu", "gpu", "tpu", "ipu", "hpu", "auto">
  accumulate_grad_batches: 1
  amp_backend: native
  auto_lr_find: false
  auto_scale_batch_size: false
  auto_select_gpus: false
  benchmark: false
  check_val_every_n_epoch: 1
  default_root_dir: null
  detect_anomaly: false
  deterministic: false
  devices: 1
  enable_checkpointing: true
  enable_model_summary: true
  enable_progress_bar: true
  fast_dev_run: false
  gpus: null # Set automatically
  gradient_clip_val: 0
  ipus: null
  limit_predict_batches: 1.0
  limit_test_batches: 1.0
  limit_train_batches: 1.0
  limit_val_batches: 1.0
  log_every_n_steps: 50
  log_gpu_memory: null
  max_epochs: 50
  max_steps: -1
  max_time: null
  min_epochs: null
  min_steps: null
  move_metrics_to_cpu: false
  multiple_trainloader_mode: max_size_cycle
  num_nodes: 1
  num_processes: null
  num_sanity_val_steps: 0
  overfit_batches: 0.0
  plugins: null
  precision: 32
  profiler: null
  reload_dataloaders_every_n_epochs: 0
  replace_sampler_ddp: true
  strategy: null
  sync_batchnorm: false
  tpu_cores: null
  track_grad_norm: -1
  val_check_interval: 1.0
  1. data set:

mvtec_anomaly_detection/AI/OK/
1.png
2.png
...

mvtec_anomaly_detection/AI/NG/
xx1.png
xx2.png
...

mvtec_anomaly_detection/AI/CS/
cs1.png
cs2.png
...

Expected behavior

Screenshots

Hardware and Software Configuration

Additional context

aytek03 commented 1 year ago

@monkeycc Have you solved this problem?

samet-akcay commented 1 year ago

@aytek03, please refer to #671.