Rodrigo_Cobo commited on
Commit
d5307ab
1 Parent(s): ecd9245

added video version

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. WiggleResults/split.py +0 -99
  3. app.py +5 -4
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  title: Wiggle-GAN
3
- emoji: ⬅️⬅️📷➡️➡️
4
  colorFrom: gray
5
  colorTo: blue
6
  sdk: gradio
1
  ---
2
  title: Wiggle-GAN
3
+ emoji: ⬅️📷➡️
4
  colorFrom: gray
5
  colorTo: blue
6
  sdk: gradio
WiggleResults/split.py DELETED
@@ -1,99 +0,0 @@
1
- import os
2
- from PIL import Image
3
- import argparse
4
- import imageio
5
- import numpy as np
6
-
7
- parser = argparse.ArgumentParser(description='change to useful name')
8
- parser.add_argument('--dim', default=128, type=int, help='dimention image')
9
- args = parser.parse_args()
10
-
11
- path = "."
12
- ROOT_DIR = os.path.dirname(__file__)
13
- dirs = os.listdir(ROOT_DIR)
14
-
15
- dim = args.dim
16
-
17
- def gif_order (data, center=True):
18
- gif = []
19
- base = 1
20
-
21
- #primera mitad
22
- i = int((len(data)-2)/2)
23
- while(i > base ):
24
- gif.append(data[i])
25
- #print(i)
26
- i -= 1
27
-
28
-
29
- #el del medio izq
30
- gif.append(data[int((len(data)-2)/2) + 1])
31
- #print(int((len(data)-2)/2) + 1)
32
-
33
- #el inicial
34
- if center:
35
- gif.append(data[0])
36
- #print(0)
37
-
38
- # el del medio der
39
- gif.append(data[int((len(data) - 2) / 2) + 2])
40
- #print(int((len(data) - 2) / 2) +2)
41
- #segunda mitad
42
- i = int((len(data)-2)/2) + 3
43
- while (i < len(data)):
44
- gif.append(data[i])
45
- #print(i)
46
- i += 1
47
- #print("---------")
48
-
49
- invertedgif = gif[::-1]
50
- invertedgif = invertedgif[1:]
51
-
52
- gif = gif[1:] + invertedgif
53
- #print(gif)
54
- #for image in gif:
55
- # image.show()
56
- #gsdfgsfgf
57
- return gif
58
-
59
- print(" [*] Init gif generations!")
60
- # This would print all the files and directories
61
- for file in dirs:
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('P')
67
-
68
- #CROP (left, top, right, bottom)
69
-
70
- pointleft = 3
71
- pointtop = 3
72
- i = 0
73
- while (pointtop < height):
74
- while (pointleft < width):
75
- im1 = im.crop((pointleft, pointtop, dim+pointleft, dim+pointtop))
76
- h1 = im1.size[0] * 4
77
- im1 = im1.resize([h1,h1], Image.Resampling.LANCZOS)
78
- rowImages.append(im1)
79
- #im1.show()
80
- pointleft+= dim+4
81
- # Ya tengo todas las imagenes podria hacer el gif aca
82
- rowImages = gif_order(rowImages,center=False)
83
- name = "./" + ROOT_DIR + '/' + file[:-4] + "_" + str(i) + '.gif'
84
- rowImages[0].save(name, save_all=True,format='GIF', append_images=rowImages[1:], optimize=True, duration=100, loop=0)
85
-
86
- #print(rowImages)
87
- pointtop += dim + 4
88
- pointleft = 3
89
- rowImages = []
90
- i+=1
91
- #im2 = im.crop((width / 2, 0, width, height))
92
- # im2.show()
93
-
94
- #im1.save("./2" + file[:-4] + ".png")
95
- #im2.save("./" + file[:-4] + ".png")
96
-
97
- # Deleted
98
- #os.remove("data/" + file)
99
- print(" [*] End gif generations!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -61,7 +61,7 @@ def calculate_depth(model_type, gan_type, dim, slider, img):
61
  ])
62
  subprocess.run(["python", "WiggleResults/split.py", "--dim", dim])
63
 
64
- return [out_im, f'WiggleResults/'+ name_output + '.jpg',f'WiggleResults/' + name_output + '_0.gif']
65
 
66
 
67
  with gr.Blocks() as demo:
@@ -80,9 +80,10 @@ with gr.Blocks() as demo:
80
  with gr.Row():
81
  inp.append(gr.Image(type="pil", label="Input"))
82
  out = [gr.Image(type="pil", label="depth_estimation")]
83
- with gr.Row():
84
- out.append(gr.Image(type="file", label="Output_images"))
85
- out.append(gr.Image(type="file", label="Output_wiggle"))
 
86
  btn = gr.Button("Calculate depth + Wiggle")
87
  btn.click(fn=calculate_depth, inputs=inp, outputs=out)
88
 
61
  ])
62
  subprocess.run(["python", "WiggleResults/split.py", "--dim", dim])
63
 
64
+ return [out_im,f'WiggleResults/' + name_output + '_0.gif', f'WiggleResults/' + "out" + '_0.mp4', f'WiggleResults/'+ name_output + '.jpg']
65
 
66
 
67
  with gr.Blocks() as demo:
80
  with gr.Row():
81
  inp.append(gr.Image(type="pil", label="Input"))
82
  out = [gr.Image(type="pil", label="depth_estimation")]
83
+ with gr.Row():
84
+ out.append(gr.Image(type="file", label="Output_wiggle_gif"))
85
+ out.append(gr.Video(type="file", label="Output_wiggle_video"))
86
+ out.append(gr.Image(type="file", label="Output_images"))
87
  btn = gr.Button("Calculate depth + Wiggle")
88
  btn.click(fn=calculate_depth, inputs=inp, outputs=out)
89