Spaces:
Build error
Build error
initial commit
Browse files- README.md +1 -1
- app.py +35 -0
- coco_val2017_000000001000.jpg +0 -0
- requirements.txt +17 -0
- turing-2018-bengio-hinton-lecun.jpg +0 -0
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title: DeepPrivacy
|
3 |
emoji: 🌍
|
4 |
colorFrom: gray
|
5 |
colorTo: blue
|
|
|
1 |
---
|
2 |
+
title: DeepPrivacy - A Generative Adversarial Network for Face Anonymization
|
3 |
emoji: 🌍
|
4 |
colorFrom: gray
|
5 |
colorTo: blue
|
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio
|
3 |
+
import numpy as np
|
4 |
+
import torch
|
5 |
+
import hashlib
|
6 |
+
from PIL import Image
|
7 |
+
import gradio.inputs
|
8 |
+
from deep_privacy.build import build_anonymizer
|
9 |
+
from deep_privacy.detection import ImageAnnotation
|
10 |
+
from typing import List
|
11 |
+
anonymizer = build_anonymizer()
|
12 |
+
|
13 |
+
cached_detections = {}
|
14 |
+
def anonymize(im: Image, truncation_value: float):
|
15 |
+
anonymizer.truncation_level = truncation_value
|
16 |
+
im = np.array(im.convert("RGB"))
|
17 |
+
md5_ = hashlib.md5(im.tobytes()).hexdigest()
|
18 |
+
if md5_ in cached_detections:
|
19 |
+
detections = cached_detections[md5_]
|
20 |
+
else:
|
21 |
+
detections: List[ImageAnnotation] = anonymizer.detector.get_detections([im])
|
22 |
+
cached_detections[md5_] = detections
|
23 |
+
im = anonymizer.anonymize_images([im], detections)[0]
|
24 |
+
im = Image.fromarray(im)
|
25 |
+
return im
|
26 |
+
|
27 |
+
|
28 |
+
iface = gradio.Interface(
|
29 |
+
anonymize, [gradio.inputs.Image(type="pil", label="Upload your image or try the example below!"), gradio.inputs.Slider(minimum=0, maximum=8, step=0.01, default=0.5, label="Truncation value (set to >0 to generate different bodies between runs)")],
|
30 |
+
examples=[["coco_val2017_000000001000.jpg", 0], ["turing-2018-bengio-hinton-lecun.jpg", 0]],
|
31 |
+
outputs="image",
|
32 |
+
title="DeepPrivacy: A Generative Adversarial Network for Face Anonymization",
|
33 |
+
description="A live demo of face anonymization with generative adversarial networks. See paper/code at: github.com/hukkelas/DeepPrivacy",
|
34 |
+
live=True)
|
35 |
+
iface.launch()
|
coco_val2017_000000001000.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
torchvision
|
3 |
+
numpy
|
4 |
+
cython
|
5 |
+
matplotlib
|
6 |
+
tqdm
|
7 |
+
tflib
|
8 |
+
autopep8
|
9 |
+
opencv-python
|
10 |
+
requests
|
11 |
+
pyyaml
|
12 |
+
addict
|
13 |
+
scikit-image
|
14 |
+
kornia
|
15 |
+
torch_fidelity
|
16 |
+
ninja
|
17 |
+
moviepy
|
turing-2018-bengio-hinton-lecun.jpg
ADDED