Rodrigo_Cobo commited on
Commit
4b2bdc6
1 Parent(s): 491b981

solution to multiple accesses

Browse files
Files changed (1) hide show
  1. app.py +11 -19
app.py CHANGED
@@ -8,7 +8,7 @@ import matplotlib.pyplot as plt
8
  from PIL import Image
9
  import subprocess
10
 
11
- def calculate_depth(model_type, img):
12
 
13
  if not os.path.exists('temp'):
14
  os.system('mkdir temp')
@@ -51,10 +51,6 @@ def calculate_depth(model_type, img):
51
  out_im = Image.fromarray(formatted)
52
  out_im.save("Images/Input-Test/1_d.png", "PNG")
53
 
54
- return out_im
55
-
56
- def wiggle_effect(slider, gan_type):
57
-
58
  dim = '256'
59
  c_images = '1'
60
  name_output = 'out'
@@ -66,31 +62,27 @@ def wiggle_effect(slider, gan_type):
66
  ])
67
  subprocess.run(["python", "WiggleResults/split.py", "--dim", dim])
68
 
69
- return [f'WiggleResults/'+ name_output + '.jpg',f'WiggleResults/' + name_output + '_0.gif']
70
 
71
 
72
  with gr.Blocks() as demo:
73
  gr.Markdown("Start typing below and then click **Run** to see the output.")
74
 
75
-
76
  ## Depth Estimation
77
  midas_models = ["DPT_Large","DPT_Hybrid","MiDaS_small"]
 
 
78
  inp = [gr.inputs.Dropdown(midas_models, default="MiDaS_small", label="Depth estimation model type")]
 
 
79
  with gr.Row():
80
  inp.append(gr.Image(type="pil", label="Input"))
81
- out = gr.Image(type="pil", label="depth_estimation")
82
- btn = gr.Button("Calculate depth")
 
 
 
83
  btn.click(fn=calculate_depth, inputs=inp, outputs=out)
84
 
85
 
86
- ## Wigglegram
87
- gan_models = ["Cycle","Cycle(half)","noCycle","noCycle-noCr","noCycle-noCr-noL1","OnlyGen"]
88
- inp = [gr.Slider(1,15, default = 2, label='StepCycles',step= 1)]
89
- inp.append(gr.inputs.Dropdown(gan_models, default="Cycle", label="Different Gan trainings"))
90
- with gr.Row():
91
- out = [ gr.Image(type="file", label="Output_images"), #TODO change to gallery
92
- gr.Image(type="file", label="Output_wiggle")]
93
- btn = gr.Button("Generate Wigglegram")
94
- btn.click(fn=wiggle_effect, inputs=inp, outputs=out)
95
-
96
  demo.launch()
 
8
  from PIL import Image
9
  import subprocess
10
 
11
+ def calculate_depth(model_type, gan_type, slider, img):
12
 
13
  if not os.path.exists('temp'):
14
  os.system('mkdir temp')
 
51
  out_im = Image.fromarray(formatted)
52
  out_im.save("Images/Input-Test/1_d.png", "PNG")
53
 
 
 
 
 
54
  dim = '256'
55
  c_images = '1'
56
  name_output = 'out'
 
62
  ])
63
  subprocess.run(["python", "WiggleResults/split.py", "--dim", dim])
64
 
65
+ return [out_im, f'WiggleResults/'+ name_output + '.jpg',f'WiggleResults/' + name_output + '_0.gif']
66
 
67
 
68
  with gr.Blocks() as demo:
69
  gr.Markdown("Start typing below and then click **Run** to see the output.")
70
 
 
71
  ## Depth Estimation
72
  midas_models = ["DPT_Large","DPT_Hybrid","MiDaS_small"]
73
+ gan_models = ["Cycle","Cycle(half)","noCycle","noCycle-noCr","noCycle-noCr-noL1","OnlyGen"]
74
+
75
  inp = [gr.inputs.Dropdown(midas_models, default="MiDaS_small", label="Depth estimation model type")]
76
+ inp.append(gr.inputs.Dropdown(gan_models, default="Cycle", label="Different Gan trainings"))
77
+ inp.append(gr.Slider(1,15, default = 2, label='StepCycles',step= 1))
78
  with gr.Row():
79
  inp.append(gr.Image(type="pil", label="Input"))
80
+ out = [gr.Image(type="pil", label="depth_estimation")]
81
+ with gr.Row():
82
+ out.append(gr.Image(type="file", label="Output_images"))
83
+ out.append(gr.Image(type="file", label="Output_wiggle"))
84
+ btn = gr.Button("Calculate depth + wiggle")
85
  btn.click(fn=calculate_depth, inputs=inp, outputs=out)
86
 
87
 
 
 
 
 
 
 
 
 
 
 
88
  demo.launch()