toshas commited on
Commit
4cce5d7
1 Parent(s): 0ea72b7

remove persistence

Browse files
app.py CHANGED
@@ -25,23 +25,8 @@ desc = """
25
  """
26
 
27
 
28
- def init_persistence(purge=False):
29
- if not os.path.exists('/data'):
30
- return
31
- os.environ['ckpt_dir'] = "/data/Marigold_ckpt"
32
- os.environ['TRANSFORMERS_CACHE'] = "/data/hfcache"
33
- os.environ['HF_DATASETS_CACHE'] = "/data/hfcache"
34
- os.environ['HF_HOME'] = "/data/hfcache"
35
- if purge:
36
- os.system("rm -rf /data/Marigold_ckpt/*")
37
-
38
-
39
- def download_code_weights():
40
  os.system('git clone https://github.com/prs-eth/Marigold.git')
41
- os.system('cd Marigold && bash script/download_weights.sh')
42
- os.system('echo /data && ls -la /data')
43
- os.system('echo /data/Marigold_ckpt && ls -la /data/Marigold_ckpt')
44
- os.system('echo /data/Marigold_ckpt/Marigold_v1_merged && ls -la /data/Marigold_ckpt/Marigold_v1_merged')
45
 
46
 
47
  def find_first_png(directory):
@@ -61,20 +46,14 @@ def marigold_process(path_input, path_out_png=None, path_out_obj=None, path_out_
61
  os.makedirs(path_output_dir, exist_ok=True)
62
  shutil.copy(path_input, path_input_dir)
63
 
64
- persistence_args = ""
65
- if os.path.exists('/data'):
66
- persistence_args = "--checkpoint /data/Marigold_ckpt/Marigold_v1_merged"
67
-
68
  os.system(
69
  f"cd Marigold && python3 run.py "
70
- f"{persistence_args} "
71
  f"--input_rgb_dir \"{path_input_dir}\" "
72
  f"--output_dir \"{path_output_dir}\" "
73
  f"--n_infer 10 "
74
  f"--denoise_steps 10 "
75
  )
76
 
77
- # depth_colored, depth_bw, depth_npy
78
  path_out_colored = find_first_png(path_output_dir + "/depth_colored")
79
  assert path_out_colored is not None, "Processing failed"
80
  path_out_bw = find_first_png(path_output_dir + "/depth_bw")
@@ -114,13 +93,23 @@ iface = gr.Interface(
114
  ),
115
  ],
116
  allow_flagging="never",
117
- # examples=[
118
- # [
119
- # os.path.join(os.path.dirname(__file__), "files/test.png"),
120
- # os.path.join(os.path.dirname(__file__), "files/test.png.out.png"),
121
- # os.path.join(os.path.dirname(__file__), "files/test.png.out.2.png"),
122
- # ],
123
- # ],
 
 
 
 
 
 
 
 
 
 
124
  css="""
125
  .viewport {
126
  aspect-ratio: 4/3;
@@ -134,6 +123,5 @@ iface = gr.Interface(
134
 
135
 
136
  if __name__ == "__main__":
137
- init_persistence()
138
- download_code_weights()
139
  iface.queue().launch(server_name="0.0.0.0", server_port=7860)
 
25
  """
26
 
27
 
28
+ def download_code():
 
 
 
 
 
 
 
 
 
 
 
29
  os.system('git clone https://github.com/prs-eth/Marigold.git')
 
 
 
 
30
 
31
 
32
  def find_first_png(directory):
 
46
  os.makedirs(path_output_dir, exist_ok=True)
47
  shutil.copy(path_input, path_input_dir)
48
 
 
 
 
 
49
  os.system(
50
  f"cd Marigold && python3 run.py "
 
51
  f"--input_rgb_dir \"{path_input_dir}\" "
52
  f"--output_dir \"{path_output_dir}\" "
53
  f"--n_infer 10 "
54
  f"--denoise_steps 10 "
55
  )
56
 
 
57
  path_out_colored = find_first_png(path_output_dir + "/depth_colored")
58
  assert path_out_colored is not None, "Processing failed"
59
  path_out_bw = find_first_png(path_output_dir + "/depth_bw")
 
93
  ),
94
  ],
95
  allow_flagging="never",
96
+ examples=[
97
+ [
98
+ os.path.join(os.path.dirname(__file__), "files/bee.jpg"),
99
+ os.path.join(os.path.dirname(__file__), "files/bee_vis.png"),
100
+ os.path.join(os.path.dirname(__file__), "files/bee_pred.png"),
101
+ ],
102
+ [
103
+ os.path.join(os.path.dirname(__file__), "files/cat.jpg"),
104
+ os.path.join(os.path.dirname(__file__), "files/cat_vis.png"),
105
+ os.path.join(os.path.dirname(__file__), "files/cat_pred.png"),
106
+ ],
107
+ [
108
+ os.path.join(os.path.dirname(__file__), "files/swings.jpg"),
109
+ os.path.join(os.path.dirname(__file__), "files/swings_vis.png"),
110
+ os.path.join(os.path.dirname(__file__), "files/swings_pred.png"),
111
+ ],
112
+ ],
113
  css="""
114
  .viewport {
115
  aspect-ratio: 4/3;
 
123
 
124
 
125
  if __name__ == "__main__":
126
+ download_code()
 
127
  iface.queue().launch(server_name="0.0.0.0", server_port=7860)
files/Bee_Collecting_Pollen_2004-08-14.jpg DELETED
Binary file (146 kB)
 
files/bee.jpg ADDED
files/bee_pred.png ADDED
files/bee_vis.png ADDED
files/cat.jpg ADDED
files/cat_pred.png ADDED
files/cat_vis.png ADDED
files/swings.jpg ADDED
files/swings_pred.png ADDED
files/swings_vis.png ADDED