Example #1
0
def setup(opts):
    shutil.move(
        opts['face_detector'],
        'deep_privacy/detection/dsfd/weights/WIDERFace_DSFD_RES152.pth')
    config = config_parser.load_config('models/default/config.yml')
    ckpt = utils.load_checkpoint(opts['checkpoint_dir'])
    generator = infer.init_generator(config, ckpt)
    anonymizer = deep_privacy_anonymizer.DeepPrivacyAnonymizer(
        generator, 128, use_static_z=True)
    return anonymizer
Example #2
0
def run_gt(imgf):
    # run original DeepPrivacy modified to save results locally
    config = load_config("test/models/default/config.yml")
    checkpoint = torch.load("test/models/default/checkpoints/step_40000000.ckpt")
    generator = infer.init_generator(config, checkpoint)
    anonymizer = deep_privacy_anonymizer.DeepPrivacyAnonymizer(generator,
                                                               batch_size=1,
                                                               use_static_z=True,
                                                               keypoint_threshold=.1,
                                                               face_threshold=.6)

    anonymizer.anonymize_image_paths([imgf], ["example_anonymized.jpg"])
def anon_and_write_imgs(list_of_path_to_imgs, list_of_path_to_saveimgs):
    print('---> anony \t- loading config')
    config = load_config("models/large/config.yml")
    print('---> anony \t- initializating generator')
    generator = infer.init_generator(config, torch.load(path_to_ckpt))
    print('---> anony \t- build anonymizer')

    anonymizer = deep_privacy_anonymizer.DeepPrivacyAnonymizer(
        generator,
        batch_size=32,
        use_static_z=True,
        keypoint_threshold=.1,
        face_threshold=.6)

    print('---> anony \t- anonymize')
    anonymizer.anonymize_image_paths(list_of_path_to_imgs,
                                     list_of_path_to_saveimgs)
Example #4
0
from deep_privacy.inference import deep_privacy_anonymizer, infer

if __name__ == "__main__":
    generator, _, source_path, _, target_path, config = infer.read_args(
        [{
            "name": "anonymize_source",
            "default": False
        }, {
            "name": "max_face_size",
            "default": 1.0
        }, {
            "name": "without_source",
            "default": False
        }], )
    a = deep_privacy_anonymizer.DeepPrivacyAnonymizer(generator,
                                                      32,
                                                      use_static_z=True,
                                                      keypoint_threshold=.1,
                                                      face_threshold=.6,
                                                      replace_tight_bbox=True)

    a.anonymize_video(source_path,
                      target_path,
                      start_frame=0,
                      end_frame=None,
                      with_keypoints=True,
                      anonymize_source=config.anonymize_source,
                      max_face_size=float(config.max_face_size),
                      without_source=config.without_source)
Example #5
0
from deep_privacy.inference import deep_privacy_anonymizer, infer

if __name__ == "__main__":
    generator, imsize, source_path, image_paths, save_path = infer.read_args()

    anonymizer = deep_privacy_anonymizer.DeepPrivacyAnonymizer(
        generator, 128, use_static_z=True, replace_tight_bbox=True)

    anonymizer.anonymize_folder(source_path, save_path)
Example #6
0
from deep_privacy.config_parser import load_config
from deep_privacy.inference import infer, deep_privacy_anonymizer
import torch

config = load_config("models/large/config.yml")
checkpoint = torch.load("models/large/checkpoints/step_40000000.ckpt")
generator = infer.init_generator(config, checkpoint)

anonymizer = deep_privacy_anonymizer.DeepPrivacyAnonymizer(
    generator,
    batch_size=32,
    use_static_z=True,
    keypoint_threshold=.1,
    face_threshold=.6)
#anonymizer.anonymize_image_paths(["images/demo.jpg"], ["images/demo_anonymized.jpg"])
anonymizer.anonymize_video(["images/portrait.mp4"],
                           ["images/portrait_anon.mp4"])
import numpy as np
import os
import matplotlib.pyplot as plt
from deep_privacy import torch_utils
from deep_privacy.inference import infer, deep_privacy_anonymizer
from deep_privacy.data_tools.dataloaders import load_dataset_files, cut_bounding_box
from deep_privacy.visualization import utils as vis_utils

if __name__ == "__main__":
    generator, _, _, _, _ = infer.read_args()
    imsize = generator.current_imsize
    images, bounding_boxes, landmarks = load_dataset_files("data/fdf_png",
                                                           imsize,
                                                           load_fraction=True)
    batch_size = 128
    anonymizer = deep_privacy_anonymizer.DeepPrivacyAnonymizer(
        generator, batch_size, use_static_z=True)
    savedir = os.path.join(".debug", "test_examples", "inference_check")
    os.makedirs(savedir, exist_ok=True)
    num_iterations = 1
    ims_to_save = []
    percentages = [0]
    z = generator.generate_latent_variable(1, "cuda", torch.float32).zero_()
    for idx in range(-20, -1):
        orig = images[idx]
        orig = np.array(orig)
        pose = landmarks[idx:idx + 1]

        assert orig.dtype == np.uint8

        to_save = orig.copy()
        to_save = vis_utils.draw_faces_with_keypoints(
from deep_privacy.inference import deep_privacy_anonymizer, infer

if __name__ == "__main__":
    generator, imsize, source_path, image_paths, save_path = infer.read_args()

    anonymizer = deep_privacy_anonymizer.DeepPrivacyAnonymizer(
        generator, 128, use_static_z=True)

    anonymizer.anonymize_folder(source_path, save_path)