Spaces:
Runtime error
Runtime error
anonymous
commited on
Commit
·
385c778
1
Parent(s):
7f0d7fa
add examples
Browse files- .gitattributes +1 -0
- .gitignore +14 -0
- app.py +19 -1
- examples/add_censorship.yaml +28 -0
- examples/images/masks/car.png +3 -0
- examples/images/masks/obama.png +3 -0
- examples/images/masks/steam-clock.png +3 -0
- examples/images/original/car.jpg +0 -0
- examples/images/original/coast.jpg +0 -0
- examples/images/original/obama.jpg +0 -0
- examples/images/original/sakura.jpg +0 -0
- examples/images/original/steam-clock.jpg +0 -0
- examples/images/original/yann-lecun.jpg +0 -0
- examples/images/processed/car.png +3 -0
- examples/images/processed/coast.png +3 -0
- examples/images/processed/obama.png +3 -0
- examples/images/processed/sakura.png +3 -0
- examples/images/processed/steam-clock.png +3 -0
- examples/images/processed/yann-lecun.png +3 -0
- examples/remove_censorship.yaml +16 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python
|
| 2 |
+
__pycache__
|
| 3 |
+
venv
|
| 4 |
+
|
| 5 |
+
# Misc
|
| 6 |
+
.DS_Store
|
| 7 |
+
.fleet
|
| 8 |
+
.idea
|
| 9 |
+
|
| 10 |
+
# Local env files
|
| 11 |
+
.env
|
| 12 |
+
.env.*
|
| 13 |
+
!.env.example
|
| 14 |
+
|
app.py
CHANGED
|
@@ -16,6 +16,11 @@ pretrained_model_path = snapshot_download(repo_id="revp2024/revp-censorship")
|
|
| 16 |
with open(glob(os.path.join(pretrained_model_path, 'hparams.yml'), recursive=True)[0]) as f:
|
| 17 |
args = Namespace(**yaml.safe_load(f))
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
def prepare_model():
|
| 20 |
print('Loading model ...')
|
| 21 |
vae_lora_config = LoraConfig(
|
|
@@ -126,7 +131,7 @@ css = '''
|
|
| 126 |
'''
|
| 127 |
with gr.Blocks(css=css) as demo:
|
| 128 |
gr.Markdown('# ReVP: Reversible Visual Processing with Latent Models')
|
| 129 |
-
gr.Markdown('Check out our project page for more info: https://revp2024.github.io')
|
| 130 |
with gr.Tab('Add censorship'):
|
| 131 |
with gr.Row():
|
| 132 |
with gr.Column():
|
|
@@ -160,6 +165,12 @@ with gr.Blocks(css=css) as demo:
|
|
| 160 |
inputs=[input_image, mode, pixelation_block_size, blur_kernel_size, soft_edges, soft_edge_kernel_size],
|
| 161 |
outputs=output_image
|
| 162 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
with gr.Tab('Remove censorship'):
|
| 165 |
with gr.Row():
|
|
@@ -188,6 +199,12 @@ with gr.Blocks(css=css) as demo:
|
|
| 188 |
inputs=[input_image, x1, y1, x2, y2],
|
| 189 |
outputs=output_image
|
| 190 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
# sync coordinate on changed
|
| 193 |
x1.change(lambda x : x, x1, x1_)
|
|
@@ -195,6 +212,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 195 |
y1.change(lambda x : x, y1, y1_)
|
| 196 |
y2.change(lambda x : x, y2, y2_)
|
| 197 |
|
|
|
|
| 198 |
if __name__ == '__main__':
|
| 199 |
demo.queue(4)
|
| 200 |
demo.launch()
|
|
|
|
| 16 |
with open(glob(os.path.join(pretrained_model_path, 'hparams.yml'), recursive=True)[0]) as f:
|
| 17 |
args = Namespace(**yaml.safe_load(f))
|
| 18 |
|
| 19 |
+
with open('examples/add_censorship.yaml') as f:
|
| 20 |
+
add_censor_examples = yaml.safe_load(f)
|
| 21 |
+
with open('examples/remove_censorship.yaml') as f:
|
| 22 |
+
remove_censor_examples = yaml.safe_load(f)
|
| 23 |
+
|
| 24 |
def prepare_model():
|
| 25 |
print('Loading model ...')
|
| 26 |
vae_lora_config = LoraConfig(
|
|
|
|
| 131 |
'''
|
| 132 |
with gr.Blocks(css=css) as demo:
|
| 133 |
gr.Markdown('# ReVP: Reversible Visual Processing with Latent Models')
|
| 134 |
+
gr.Markdown('### Check out our project page for more info: https://revp2024.github.io')
|
| 135 |
with gr.Tab('Add censorship'):
|
| 136 |
with gr.Row():
|
| 137 |
with gr.Column():
|
|
|
|
| 165 |
inputs=[input_image, mode, pixelation_block_size, blur_kernel_size, soft_edges, soft_edge_kernel_size],
|
| 166 |
outputs=output_image
|
| 167 |
)
|
| 168 |
+
gr.Examples(
|
| 169 |
+
examples=add_censor_examples,
|
| 170 |
+
fn=add_censorship,
|
| 171 |
+
inputs=[input_image, mode, pixelation_block_size, blur_kernel_size, soft_edges, soft_edge_kernel_size],
|
| 172 |
+
outputs=output_image
|
| 173 |
+
)
|
| 174 |
|
| 175 |
with gr.Tab('Remove censorship'):
|
| 176 |
with gr.Row():
|
|
|
|
| 199 |
inputs=[input_image, x1, y1, x2, y2],
|
| 200 |
outputs=output_image
|
| 201 |
)
|
| 202 |
+
gr.Examples(
|
| 203 |
+
examples=remove_censor_examples,
|
| 204 |
+
fn=remove_censorship,
|
| 205 |
+
inputs=[input_image, x1, y1, x2, y2],
|
| 206 |
+
outputs=output_image
|
| 207 |
+
)
|
| 208 |
|
| 209 |
# sync coordinate on changed
|
| 210 |
x1.change(lambda x : x, x1, x1_)
|
|
|
|
| 212 |
y1.change(lambda x : x, y1, y1_)
|
| 213 |
y2.change(lambda x : x, y2, y2_)
|
| 214 |
|
| 215 |
+
|
| 216 |
if __name__ == '__main__':
|
| 217 |
demo.queue(4)
|
| 218 |
demo.launch()
|
examples/add_censorship.yaml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- - background: examples/images/original/car.jpg
|
| 2 |
+
layers:
|
| 3 |
+
- examples/images/masks/car.png
|
| 4 |
+
composite: examples/images/original/car.jpg
|
| 5 |
+
- Black
|
| 6 |
+
- 40
|
| 7 |
+
- 151
|
| 8 |
+
- false
|
| 9 |
+
- 35
|
| 10 |
+
- - background: examples/images/original/obama.jpg
|
| 11 |
+
layers:
|
| 12 |
+
- examples/images/masks/obama.png
|
| 13 |
+
composite: examples/images/original/obama.jpg
|
| 14 |
+
- Pixelation
|
| 15 |
+
- 40
|
| 16 |
+
- 151
|
| 17 |
+
- true
|
| 18 |
+
- 35
|
| 19 |
+
- - background: examples/images/original/steam-clock.jpg
|
| 20 |
+
layers:
|
| 21 |
+
- examples/images/masks/steam-clock.png
|
| 22 |
+
composite: examples/images/original/steam-clock.jpg
|
| 23 |
+
- Gaussian blur
|
| 24 |
+
- 40
|
| 25 |
+
- 151
|
| 26 |
+
- true
|
| 27 |
+
- 35
|
| 28 |
+
|
examples/images/masks/car.png
ADDED
|
Git LFS Details
|
examples/images/masks/obama.png
ADDED
|
Git LFS Details
|
examples/images/masks/steam-clock.png
ADDED
|
Git LFS Details
|
examples/images/original/car.jpg
ADDED
|
examples/images/original/coast.jpg
ADDED
|
examples/images/original/obama.jpg
ADDED
|
examples/images/original/sakura.jpg
ADDED
|
examples/images/original/steam-clock.jpg
ADDED
|
examples/images/original/yann-lecun.jpg
ADDED
|
examples/images/processed/car.png
ADDED
|
Git LFS Details
|
examples/images/processed/coast.png
ADDED
|
Git LFS Details
|
examples/images/processed/obama.png
ADDED
|
Git LFS Details
|
examples/images/processed/sakura.png
ADDED
|
Git LFS Details
|
examples/images/processed/steam-clock.png
ADDED
|
Git LFS Details
|
examples/images/processed/yann-lecun.png
ADDED
|
Git LFS Details
|
examples/remove_censorship.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
- - examples/images/processed/car.png
|
| 2 |
+
- 0
|
| 3 |
+
- 0
|
| 4 |
+
- 10000
|
| 5 |
+
- 10000
|
| 6 |
+
- - examples/images/processed/obama.png
|
| 7 |
+
- 0
|
| 8 |
+
- 0
|
| 9 |
+
- 10000
|
| 10 |
+
- 10000
|
| 11 |
+
- - examples/images/processed/steam-clock.png
|
| 12 |
+
- 0
|
| 13 |
+
- 0
|
| 14 |
+
- 10000
|
| 15 |
+
- 10000
|
| 16 |
+
|