hukkelas / deep_privacy2

DeepPrivacy2 - A Toolbox for Realistic Image Anonymization
Apache License 2.0
292 stars 33 forks source link

Running in Google Colab: Output and Running Time Issues #24

Open Gordon-4389 opened 5 months ago

Gordon-4389 commented 5 months ago

Hi @hukkelas,

Thanks for your work. I am currently running DeepPrivacy2's face anonymization in Google Colab using the V100 GPU, specifically the face.py anonymizer on a subset of the FDF256.

Google Colab's Parameters:

When I try to run anonymization on an image

! python3 anonymize.py configs/anonymizers/face.py -i ../DeepPrivacy2_Data/fdf256_DeepPrivacy2/002001.png --output_path ../002001.png

I get the following output:

/content/deep_privacy2
2024-03-17 14:04:53.462022: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:9261] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-03-17 14:04:53.462077: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:607] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-03-17 14:04:53.463799: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1515] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-03-17 14:04:55.284089: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
pygame 2.5.2 (SDL 2.28.2, Python 3.10.12)
Hello from the pygame community. https://www.pygame.org/contribute.html
error: XDG_RUNTIME_DIR not set in the environment.
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
Saving outputs to: outputs/anonymizers/face
2024-03-17 14:05:00,615 [INFO ] logger.py: 102 [0]
anonymizer = dp2.anonymizer.Anonymizer(
    _args_=[],
    detector=dp2.detection.face_detector.FaceDetector(
        _args_=[],
        cache_directory=PosixPath("outputs/face_detection_cache"),
        face_detector_cfg={"clip_boxes": True, "name": "DSFDDetector"},
        face_post_process_cfg={"fdf128_expand": False, "target_imsize": [256, 256]},
        score_threshold=0.3,
    ),
    face_G_cfg="configs/fdf/stylegan.py",
)
checkpoint_dir = PosixPath("outputs/anonymizers/face/checkpoints")
common.experiment_name = None
common.logger_backend = ["wandb", "stdout", "json", "image_dumper"]
common.output_dir = PosixPath("outputs")
common.wandb_project = "deep_privacy2"
detector = dp2.detection.face_detector.FaceDetector(
    _args_=[],
    cache_directory=PosixPath("outputs/face_detection_cache"),
    face_detector_cfg={"clip_boxes": True, "name": "DSFDDetector"},
    face_post_process_cfg={"fdf128_expand": False, "target_imsize": [256, 256]},
    score_threshold=0.3,
)
experiment_name = "configs/anonymizers/face.py"
filename = "configs/anonymizers/face.py"
output_dir = PosixPath("outputs/anonymizers/face")

2024-03-17 14:05:01,115 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead.
  warnings.warn(

2024-03-17 14:05:01,115 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing `weights=None`.
  warnings.warn(msg)

Saving outputs to: outputs/fdf/stylegan
2024-03-17 14:05:04,332 [INFO ] logger.py: 102 [0]Generator loaded, num parameters: 43.131523M
2024-03-17 14:05:04,333 [INFO ] logger.py: 102 [0]W cluster centers loaded. Number of centers: 512
2024-03-17 14:05:04,381 [INFO ] logger.py: 102 [0]Loaded generator from: configs/fdf/stylegan.py
2024-03-17 14:05:04,382 [WARNI] logger.py: 102 [0]Overwriting previous file: ../002001.png
2024-03-17 14:05:05,560 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,592 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,593 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,596 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,737 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,738 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,740 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,747 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,752 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,763 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,769 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,773 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,783 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,787 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,791 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,801 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

2024-03-17 14:05:05,806 [WARNI] warnings.py: 109 /usr/local/lib/python3.10/dist-packages/torch/nn/modules/instancenorm.py:80: UserWarning: input's size at dim=1 does not match num_features. You can silence this warning by not passing in num_features, which is not used because affine=False
  warnings.warn(f"input's size at dim={feature_dim} does not match num_features. "

Saved to: ../002001.png

I still get an anonymised output, but it takes 17 seconds to complete.

As such I have a couple of questions:

  1. How can I shorten the running time for a single anonymization, given if I were to measure FID, I would require more than 2000 samples?
  2. You suggest face.py for face anonymization only, but can FB_cse.py also work with the FDF256 in a similar runtime?
  3. What is the pygame terminal message, where is it from, and is it necessary to runtime?
  4. What is the reason for the ASLA errors, given that I do have access to a GPU in Google Colab?
  5. Why does it save to outputs/anonymizers/face and outputs/fdf/stylegan if I am only running anonymization and not training?
  6. How can I silence the UserWarning: input's size at dim=1 does not match num_features in-code?

Thanks for taking a look.

Kind Regards.

MrRaptorious commented 3 months ago

Did you find a solution to 6?

Gordon-4389 commented 3 months ago

Did you find a solution to 6?

HI Mr Raptorious,

I did not end up solving this issue, but I ignored the warnings using:

import warnings
warnings.filterwarnings("ignore")

Additionally, I ended up calling anonymize_image function separately, after setting up the parameters seperately as well.