Rodrigo_Cobo commited on
Commit
8f32fb8
1 Parent(s): 9ff509b

integrate gif and gan

Browse files
Files changed (2) hide show
  1. WiggleResults/split.py +9 -4
  2. app.py +7 -6
WiggleResults/split.py CHANGED
@@ -7,7 +7,9 @@ parser.add_argument('--dim', default=128, type=int, help='dimention image')
7
  args = parser.parse_args()
8
 
9
  path = "."
10
- dirs = os.listdir(path)
 
 
11
 
12
  dim = args.dim
13
 
@@ -53,12 +55,13 @@ def gif_order (data, center=True):
53
  #gsdfgsfgf
54
  return gif
55
 
56
-
57
  # This would print all the files and directories
58
  for file in dirs:
 
59
  if ".jpg" in file or ".png" in file:
60
  rowImages = []
61
- im = Image.open("./" + file)
62
  width, height = im.size
63
  im = im.convert('RGB')
64
 
@@ -75,8 +78,9 @@ for file in dirs:
75
  pointleft+= dim+4
76
  # Ya tengo todas las imagenes podria hacer el gif aca
77
  rowImages = gif_order(rowImages,center=False)
78
- name = file[:-4] + "_" + str(i) + '.gif'
79
  rowImages[0].save(name, save_all=True,format='GIF', append_images=rowImages[1:], optimize=True, duration=100, loop=0)
 
80
  pointtop += dim + 4
81
  pointleft = 3
82
  rowImages = []
@@ -89,3 +93,4 @@ for file in dirs:
89
 
90
  # Deleted
91
  #os.remove("data/" + file)
 
 
7
  args = parser.parse_args()
8
 
9
  path = "."
10
+ ROOT_DIR = os.path.dirname(__file__)
11
+ print(ROOT_DIR)
12
+ dirs = os.listdir(ROOT_DIR)
13
 
14
  dim = args.dim
15
 
 
55
  #gsdfgsfgf
56
  return gif
57
 
58
+ print("init gif generations!")
59
  # This would print all the files and directories
60
  for file in dirs:
61
+ print(file)
62
  if ".jpg" in file or ".png" in file:
63
  rowImages = []
64
+ im = Image.open("./" + ROOT_DIR + '/' + file)
65
  width, height = im.size
66
  im = im.convert('RGB')
67
 
 
78
  pointleft+= dim+4
79
  # Ya tengo todas las imagenes podria hacer el gif aca
80
  rowImages = gif_order(rowImages,center=False)
81
+ name = "./" + ROOT_DIR + '/' + file[:-4] + "_" + str(i) + '.gif'
82
  rowImages[0].save(name, save_all=True,format='GIF', append_images=rowImages[1:], optimize=True, duration=100, loop=0)
83
+ print('saved gif '+ name)
84
  pointtop += dim + 4
85
  pointleft = 3
86
  rowImages = []
 
93
 
94
  # Deleted
95
  #os.remove("data/" + file)
96
+ print("end gif generations!")
app.py CHANGED
@@ -55,14 +55,15 @@ def calculate_depth(model_type, img):
55
 
56
  def wiggle_effect(slider):
57
 
 
 
58
 
59
- # python main.py --gan_type WiggleGAN --expandGen 4 --expandDis 4 --batch_size 1 --visdom false --wiggleDepth 1 --seedLoad 31219_110 --gpu_mode false --cIm 1 --imageDim 256 --name_wiggle testing_name
60
- #subprocess.run([".\Scripts\activate"])
61
- subprocess.run(["python", "main.py", "--gan_type", 'WiggleGAN', "--expandGen", "4", "--expandDis", "4", "--batch_size", "1", "--cIm", "1",
62
- "--visdom", "false", "--wiggleDepth", "1", "--seedLoad", '31219_110', "--gpu_mode", "false", "--imageDim", "256", "--name_wiggle", "0"
63
  ])
64
-
65
- return [f'Images/Input-Test/1_d.png',f'Images/Input-Test/1_d.png']
 
66
 
67
 
68
  with gr.Blocks() as demo:
 
55
 
56
  def wiggle_effect(slider):
57
 
58
+ dim = 256
59
+ c_images = 1
60
 
61
+ subprocess.run(["python", "main.py", "--gan_type", 'WiggleGAN', "--expandGen", "4", "--expandDis", "4", "--batch_size", c_images, "--cIm", c_images,
62
+ "--visdom", "false", "--wiggleDepth", slider, "--seedLoad", '31219_110', "--gpu_mode", "false", "--imageDim", dim, "--name_wiggle", "result"
 
 
63
  ])
64
+ subprocess.run(["python", "WiggleResults\split.py", "--dim", dim])
65
+
66
+ return [f'WiggleResults/result.png',f'WiggleResults/result_0.gif']
67
 
68
 
69
  with gr.Blocks() as demo: