Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,6 @@ import onnx
|
|
5 |
import onnxruntime as rt
|
6 |
from numpy.random import RandomState
|
7 |
from skimage import transform
|
8 |
-
import json
|
9 |
|
10 |
|
11 |
def get_inter(r1, r2):
|
@@ -181,10 +180,10 @@ class Model:
|
|
181 |
if detail:
|
182 |
print(msg + f'body num error: {body_num}')
|
183 |
continue
|
184 |
-
bounds = (
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
if (bounds[2] - bounds[0]) / (bounds[3] - bounds[1]) > 0.7:
|
189 |
if detail:
|
190 |
print(msg + "ratio out of limit")
|
@@ -258,7 +257,8 @@ if __name__ == '__main__':
|
|
258 |
|
259 |
app = gr.Blocks()
|
260 |
with app:
|
261 |
-
gr.Markdown("# full-body anime\n\n"
|
|
|
262 |
"the model is not well, just use for fun.")
|
263 |
with gr.Tabs():
|
264 |
with gr.TabItem("generate image"):
|
@@ -270,7 +270,7 @@ if __name__ == '__main__':
|
|
270 |
gen_input2 = gr.Number(value=1, label="seed ( int between -2^31 and 2^31 - 1 )")
|
271 |
gen_input3 = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.6, label="truncation psi")
|
272 |
with gr.Group():
|
273 |
-
gen_submit = gr.Button("Generate")
|
274 |
with gr.Column():
|
275 |
gen_output1 = gr.Image(label="output image")
|
276 |
select_img_input_w1 = gr.Variable()
|
@@ -282,7 +282,7 @@ if __name__ == '__main__':
|
|
282 |
gr.Markdown("you'd better upload a standing full-body image")
|
283 |
encode_img_input = gr.Image(label="input image")
|
284 |
with gr.Group():
|
285 |
-
encode_img_submit = gr.Button("Run")
|
286 |
with gr.Column():
|
287 |
encode_img_output1 = gr.Textbox(label="output message")
|
288 |
with gr.Row():
|
@@ -302,7 +302,7 @@ if __name__ == '__main__':
|
|
302 |
choices=["current generated image",
|
303 |
"current encoded image"], type="index")
|
304 |
with gr.Group():
|
305 |
-
select_img1_button = gr.Button("select")
|
306 |
select_img1_output_img = gr.Image(label="selected image 1")
|
307 |
select_img1_output_w = gr.Variable()
|
308 |
with gr.Column():
|
@@ -311,15 +311,14 @@ if __name__ == '__main__':
|
|
311 |
choices=["current generated image",
|
312 |
"current encoded image"], type="index")
|
313 |
with gr.Group():
|
314 |
-
select_img2_button = gr.Button("select")
|
315 |
select_img2_output_img = gr.Image(label="selected image 2")
|
316 |
select_img2_output_w = gr.Variable()
|
317 |
generate_video_frame = gr.Slider(minimum=10, maximum=30, step=1, label="frame", value=15)
|
318 |
with gr.Group():
|
319 |
-
generate_video_button = gr.Button("Generate")
|
320 |
with gr.Column():
|
321 |
generate_video_output = gr.Video(label="output video")
|
322 |
-
|
323 |
gen_submit.click(gen_fn, [gen_input1, gen_input2, gen_input3],
|
324 |
[gen_output1, select_img_input_w1, select_img_input_img1])
|
325 |
encode_img_submit.click(encode_img_fn, [encode_img_input],
|
@@ -335,5 +334,4 @@ if __name__ == '__main__':
|
|
335 |
[select_img2_output_img, select_img2_output_w])
|
336 |
generate_video_button.click(gen_video_fn, [select_img1_output_w, select_img2_output_w, generate_video_frame],
|
337 |
[generate_video_output])
|
338 |
-
|
339 |
app.launch()
|
|
|
5 |
import onnxruntime as rt
|
6 |
from numpy.random import RandomState
|
7 |
from skimage import transform
|
|
|
8 |
|
9 |
|
10 |
def get_inter(r1, r2):
|
|
|
180 |
if detail:
|
181 |
print(msg + f'body num error: {body_num}')
|
182 |
continue
|
183 |
+
bounds = (min(waifu_rect[0], hr[0], br[0]),
|
184 |
+
min(waifu_rect[1], hr[1], br[1]),
|
185 |
+
max(waifu_rect[2], hr[2], br[2]),
|
186 |
+
max(waifu_rect[3], hr[3], br[3]))
|
187 |
if (bounds[2] - bounds[0]) / (bounds[3] - bounds[1]) > 0.7:
|
188 |
if detail:
|
189 |
print(msg + "ratio out of limit")
|
|
|
257 |
|
258 |
app = gr.Blocks()
|
259 |
with app:
|
260 |
+
gr.Markdown("# full-body anime GAN\n\n"
|
261 |
+
"![visitor badge](https://visitor-badge.glitch.me/badge?page_id=skytnt.full-body-anime-gan)\n\n"
|
262 |
"the model is not well, just use for fun.")
|
263 |
with gr.Tabs():
|
264 |
with gr.TabItem("generate image"):
|
|
|
270 |
gen_input2 = gr.Number(value=1, label="seed ( int between -2^31 and 2^31 - 1 )")
|
271 |
gen_input3 = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.6, label="truncation psi")
|
272 |
with gr.Group():
|
273 |
+
gen_submit = gr.Button("Generate", variant="primary")
|
274 |
with gr.Column():
|
275 |
gen_output1 = gr.Image(label="output image")
|
276 |
select_img_input_w1 = gr.Variable()
|
|
|
282 |
gr.Markdown("you'd better upload a standing full-body image")
|
283 |
encode_img_input = gr.Image(label="input image")
|
284 |
with gr.Group():
|
285 |
+
encode_img_submit = gr.Button("Run", variant="primary")
|
286 |
with gr.Column():
|
287 |
encode_img_output1 = gr.Textbox(label="output message")
|
288 |
with gr.Row():
|
|
|
302 |
choices=["current generated image",
|
303 |
"current encoded image"], type="index")
|
304 |
with gr.Group():
|
305 |
+
select_img1_button = gr.Button("select", variant="primary")
|
306 |
select_img1_output_img = gr.Image(label="selected image 1")
|
307 |
select_img1_output_w = gr.Variable()
|
308 |
with gr.Column():
|
|
|
311 |
choices=["current generated image",
|
312 |
"current encoded image"], type="index")
|
313 |
with gr.Group():
|
314 |
+
select_img2_button = gr.Button("select", variant="primary")
|
315 |
select_img2_output_img = gr.Image(label="selected image 2")
|
316 |
select_img2_output_w = gr.Variable()
|
317 |
generate_video_frame = gr.Slider(minimum=10, maximum=30, step=1, label="frame", value=15)
|
318 |
with gr.Group():
|
319 |
+
generate_video_button = gr.Button("Generate", variant="primary")
|
320 |
with gr.Column():
|
321 |
generate_video_output = gr.Video(label="output video")
|
|
|
322 |
gen_submit.click(gen_fn, [gen_input1, gen_input2, gen_input3],
|
323 |
[gen_output1, select_img_input_w1, select_img_input_img1])
|
324 |
encode_img_submit.click(encode_img_fn, [encode_img_input],
|
|
|
334 |
[select_img2_output_img, select_img2_output_w])
|
335 |
generate_video_button.click(gen_video_fn, [select_img1_output_w, select_img2_output_w, generate_video_frame],
|
336 |
[generate_video_output])
|
|
|
337 |
app.launch()
|