ldkong commited on
Commit
2f23f07
β€’
1 Parent(s): ef99204

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -1,6 +1,7 @@
 
1
  import torch
2
  from torch import nn
3
- import gradio as gr
4
 
5
 
6
  class Generator(nn.Module):
@@ -27,6 +28,18 @@ class Generator(nn.Module):
27
  return output
28
 
29
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  def path(action, body, hair, top, bottom):
31
 
32
  # body
@@ -50,9 +63,13 @@ def path(action, body, hair, top, bottom):
50
  elif bottom == "golden": bottom = '1'
51
  elif bottom == "red": bottom = '2'
52
  elif bottom == "silver": bottom = '3'
53
-
54
- name = 'front' + '_' + str(body) + str(bottom) + str(top) + str(hair)
55
- return name
 
 
 
 
56
 
57
 
58
  gr.Interface(
 
1
+ import gradio as gr
2
  import torch
3
  from torch import nn
4
+ import imageio
5
 
6
 
7
  class Generator(nn.Module):
 
28
  return output
29
 
30
 
31
+ def display_gif(file_name):
32
+ images = []
33
+
34
+ for frame in range(8):
35
+ frame_name = '_%d' % (frame)
36
+ image_filename = file_name + frame_name + '.png'
37
+ images.append(imageio.imread(image_filename))
38
+
39
+ gif_filename = 'avatar.gif'
40
+ return imageio.mimsave(gif_filename, images)
41
+
42
+
43
  def path(action, body, hair, top, bottom):
44
 
45
  # body
 
63
  elif bottom == "golden": bottom = '1'
64
  elif bottom == "red": bottom = '2'
65
  elif bottom == "silver": bottom = '3'
66
+
67
+ name = 'Sprite/' + 'domain_1/' + action + '/'
68
+ name = name + 'front' + '_' + str(body) + str(bottom) + str(top) + str(hair) + '_'
69
+
70
+ gif = display_gif(name)
71
+
72
+ return gif
73
 
74
 
75
  gr.Interface(