anonymous commited on
Commit
385c778
1 Parent(s): 7f0d7fa

add examples

Browse files
.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

  • SHA256: d0506d88f8a8e41d19f3c2cc148b67a7a33608c4a26a1f86fa5f7b92ff53271d
  • Pointer size: 129 Bytes
  • Size of remote file: 8.94 kB
examples/images/masks/obama.png ADDED

Git LFS Details

  • SHA256: 4066cabdc3a6f897f6cf1626d767085401e15c7441c40dfd83363a5b17a705f3
  • Pointer size: 129 Bytes
  • Size of remote file: 8.65 kB
examples/images/masks/steam-clock.png ADDED

Git LFS Details

  • SHA256: 2105c83921a3d86c417e394fd1c31aed7000bbdd6afd7d865586d85164850818
  • Pointer size: 130 Bytes
  • Size of remote file: 12.1 kB
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

  • SHA256: 4431e2ce30e59d3867e1a29c3358ef7ea7bbb3fb8f90e2593f60d400657a52c8
  • Pointer size: 131 Bytes
  • Size of remote file: 992 kB
examples/images/processed/coast.png ADDED

Git LFS Details

  • SHA256: 60e40960cf1fac6cbaefb3c3339a5defde29f04b471a319a9897d735aa0fcde3
  • Pointer size: 132 Bytes
  • Size of remote file: 2.56 MB
examples/images/processed/obama.png ADDED

Git LFS Details

  • SHA256: 8e0f1e3b4057b69f47634cc74a07348dd7f59efb6bd9cf46a302c4453493a02c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.08 MB
examples/images/processed/sakura.png ADDED

Git LFS Details

  • SHA256: 662d5bd0f67390c2afb8c32b22259a5ad35f6f046e461c7e4dd44f2bdbed6f36
  • Pointer size: 132 Bytes
  • Size of remote file: 1.05 MB
examples/images/processed/steam-clock.png ADDED

Git LFS Details

  • SHA256: cd547c0bb73ae5c0df932f598d2f2024d6db90fad67608a8d780a780fbdfa553
  • Pointer size: 131 Bytes
  • Size of remote file: 816 kB
examples/images/processed/yann-lecun.png ADDED

Git LFS Details

  • SHA256: 59936038d159daef75d9ed8afd33f43fc0061ba1d2680a09023c1678884aeac6
  • Pointer size: 132 Bytes
  • Size of remote file: 1.43 MB
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
+