Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
import torch
|
| 3 |
from torch import nn
|
| 4 |
import imageio
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
class Generator(nn.Module):
|
|
@@ -40,6 +41,21 @@ def display_gif(file_name, save_name):
|
|
| 40 |
return imageio.mimsave(gif_filename, images)
|
| 41 |
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
def display_image(file_name):
|
| 44 |
|
| 45 |
image_filename = file_name + '0' + '.png'
|
|
@@ -75,7 +91,7 @@ def run(action, body, hair, top, bottom):
|
|
| 75 |
file_name_source = './Sprite/frames/domain_1/' + action + '/'
|
| 76 |
file_name_source = file_name_source + 'front' + '_' + str(body) + str(bottom) + str(top) + str(hair) + '_'
|
| 77 |
|
| 78 |
-
gif =
|
| 79 |
|
| 80 |
return 'avatar_source.gif'
|
| 81 |
|
|
|
|
| 2 |
import torch
|
| 3 |
from torch import nn
|
| 4 |
import imageio
|
| 5 |
+
import cv2
|
| 6 |
|
| 7 |
|
| 8 |
class Generator(nn.Module):
|
|
|
|
| 41 |
return imageio.mimsave(gif_filename, images)
|
| 42 |
|
| 43 |
|
| 44 |
+
def display_gif_pad(file_name, save_name):
|
| 45 |
+
images = []
|
| 46 |
+
|
| 47 |
+
for frame in range(8):
|
| 48 |
+
frame_name = '%d' % (frame)
|
| 49 |
+
image_filename = file_name + frame_name + '.png'
|
| 50 |
+
image = imageio.imread(image_filename)
|
| 51 |
+
image = image[:, :, :3]
|
| 52 |
+
image_pad = cv2.copyMakeBorder(image, 0, 0, 32, 32, cv2.BORDER_CONSTANT, value=0)
|
| 53 |
+
images.append(image_pad)
|
| 54 |
+
|
| 55 |
+
gif_filename = 'avatar_source.gif'
|
| 56 |
+
return imageio.mimsave(gif_filename, images)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
def display_image(file_name):
|
| 60 |
|
| 61 |
image_filename = file_name + '0' + '.png'
|
|
|
|
| 91 |
file_name_source = './Sprite/frames/domain_1/' + action + '/'
|
| 92 |
file_name_source = file_name_source + 'front' + '_' + str(body) + str(bottom) + str(top) + str(hair) + '_'
|
| 93 |
|
| 94 |
+
gif = display_gif_pad(file_name_source, 'avatar_source.gif')
|
| 95 |
|
| 96 |
return 'avatar_source.gif'
|
| 97 |
|