Spaces:
Runtime error
Runtime error
anonymous
commited on
Commit
·
c9f0162
1
Parent(s):
b34b0cb
update
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ from glob import glob
|
|
| 3 |
import yaml
|
| 4 |
import os
|
| 5 |
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
import torch
|
| 8 |
import torchvision
|
|
@@ -40,6 +41,7 @@ def prepare_model():
|
|
| 40 |
return vae.to('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu')
|
| 41 |
|
| 42 |
|
|
|
|
| 43 |
@torch.no_grad()
|
| 44 |
def add_censorship(input_image, mode, pixelation_block_size, blur_kernel_size, soft_edges, soft_edge_kernel_size):
|
| 45 |
background, layers, _ = input_image.values()
|
|
@@ -93,6 +95,7 @@ def add_censorship(input_image, mode, pixelation_block_size, blur_kernel_size, s
|
|
| 93 |
gr.Info("Try to donwload/copy the censored image to the `Remove censorsip' tab")
|
| 94 |
return images[0].permute(1, 2, 0).cpu().numpy()
|
| 95 |
|
|
|
|
| 96 |
@torch.no_grad()
|
| 97 |
def remove_censorship(input_image, x1, y1, x2, y2):
|
| 98 |
background, layers, _ = input_image.values()
|
|
|
|
| 3 |
import yaml
|
| 4 |
import os
|
| 5 |
|
| 6 |
+
import spaces
|
| 7 |
import gradio as gr
|
| 8 |
import torch
|
| 9 |
import torchvision
|
|
|
|
| 41 |
return vae.to('cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu')
|
| 42 |
|
| 43 |
|
| 44 |
+
@spaces.GPU
|
| 45 |
@torch.no_grad()
|
| 46 |
def add_censorship(input_image, mode, pixelation_block_size, blur_kernel_size, soft_edges, soft_edge_kernel_size):
|
| 47 |
background, layers, _ = input_image.values()
|
|
|
|
| 95 |
gr.Info("Try to donwload/copy the censored image to the `Remove censorsip' tab")
|
| 96 |
return images[0].permute(1, 2, 0).cpu().numpy()
|
| 97 |
|
| 98 |
+
@spaces.GPU
|
| 99 |
@torch.no_grad()
|
| 100 |
def remove_censorship(input_image, x1, y1, x2, y2):
|
| 101 |
background, layers, _ = input_image.values()
|