Masaaki Kawata
commited on
Commit
Β·
cc700fc
1
Parent(s):
d234d72
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ from typing import Iterable
|
|
| 8 |
from tempfile import NamedTemporaryFile
|
| 9 |
from PIL import Image
|
| 10 |
from nudenet import NudeDetector
|
| 11 |
-
from parallax import generate_parallax_images
|
| 12 |
|
| 13 |
|
| 14 |
class Theme(Base):
|
|
@@ -49,8 +49,8 @@ class Theme(Base):
|
|
| 49 |
)
|
| 50 |
|
| 51 |
|
| 52 |
-
@spaces.GPU
|
| 53 |
-
def
|
| 54 |
input_image = Image.fromarray(image, 'RGBA')
|
| 55 |
detector = NudeDetector()
|
| 56 |
layers = []
|
|
@@ -75,18 +75,35 @@ def generate(image: np.ndarray, n: int):
|
|
| 75 |
return [layers, json.dumps(indexes), nsfw]
|
| 76 |
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
with gr.Blocks(theme=Theme()) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
with gr.Row():
|
| 80 |
with gr.Column():
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
generate_button = gr.Button('Generate')
|
| 84 |
with gr.Column():
|
| 85 |
-
|
| 86 |
-
output_json = gr.JSON(label='Indexes')
|
| 87 |
-
output_nsfw = gr.Checkbox(label='NSFW')
|
| 88 |
|
| 89 |
-
|
|
|
|
| 90 |
|
| 91 |
|
| 92 |
if __name__ == '__main__':
|
|
|
|
| 8 |
from tempfile import NamedTemporaryFile
|
| 9 |
from PIL import Image
|
| 10 |
from nudenet import NudeDetector
|
| 11 |
+
from parallax import generate_parallax_images, generate_animation_images
|
| 12 |
|
| 13 |
|
| 14 |
class Theme(Base):
|
|
|
|
| 49 |
)
|
| 50 |
|
| 51 |
|
| 52 |
+
@spaces.GPU
|
| 53 |
+
def generate_parallax(image: np.ndarray, n: int):
|
| 54 |
input_image = Image.fromarray(image, 'RGBA')
|
| 55 |
detector = NudeDetector()
|
| 56 |
layers = []
|
|
|
|
| 75 |
return [layers, json.dumps(indexes), nsfw]
|
| 76 |
|
| 77 |
|
| 78 |
+
#@spaces.GPU
|
| 79 |
+
def generate_animation(image: np.ndarray):
|
| 80 |
+
return generate_animation_images(Image.fromarray(image, 'RGBA'))
|
| 81 |
+
|
| 82 |
+
|
| 83 |
with gr.Blocks(theme=Theme()) as demo:
|
| 84 |
+
gr.Markdown('**Parallax**')
|
| 85 |
+
|
| 86 |
+
with gr.Row():
|
| 87 |
+
with gr.Column():
|
| 88 |
+
parallax_input_image = gr.Image(image_mode='RGBA', label='Input')
|
| 89 |
+
parallax_input_layers = gr.Number(value=5, precision=0, minimum=2, maximum=10, step=1, label='Layers')
|
| 90 |
+
parallax_generate_button = gr.Button('Generate')
|
| 91 |
+
with gr.Column():
|
| 92 |
+
parallax_output_gallery = gr.Gallery(label='Outputs', columns=5)
|
| 93 |
+
parallax_output_json = gr.JSON(label='Indexes')
|
| 94 |
+
parallax_output_nsfw = gr.Checkbox(label='NSFW')
|
| 95 |
+
|
| 96 |
+
gr.Markdown('**Blink**')
|
| 97 |
+
|
| 98 |
with gr.Row():
|
| 99 |
with gr.Column():
|
| 100 |
+
animation_input_image = gr.Image(image_mode='RGBA', label='Input')
|
| 101 |
+
animation_generate_button = gr.Button('Generate')
|
|
|
|
| 102 |
with gr.Column():
|
| 103 |
+
animation_output_gallery = gr.Gallery(label='Outputs', columns=5)
|
|
|
|
|
|
|
| 104 |
|
| 105 |
+
parallax_generate_button.click(fn=generate_parallax, inputs=[parallax_input_image, parallax_input_layers], outputs=[parallax_output_gallery, parallax_output_json, parallax_output_nsfw], api_name='generate_parallax')
|
| 106 |
+
animation_generate_button.click(fn=generate_animation, inputs=animation_input_image, outputs=animation_output_gallery, api_name='generate_animation')
|
| 107 |
|
| 108 |
|
| 109 |
if __name__ == '__main__':
|