Libra-1995 commited on
Commit
76b3444
·
1 Parent(s): 1102668

feat: update output code

Browse files
Files changed (1) hide show
  1. web_server.py +16 -8
web_server.py CHANGED
@@ -28,6 +28,7 @@ IN_HUGGINGFACE_SPACE = os.getenv('IN_HUGGINGFACE_SPACE', 'false') == 'true'
28
  STOP_SPACE_TIMEOUT = int(os.getenv('STOP_SPACE_TIMEOUT', '7200'))
29
  HF_TOKEN = os.getenv('HF_TOKEN', None)
30
  SPACE_PARAMS = json.loads(os.getenv('PARAMS', '{}'))
 
31
 
32
  print("IN_HUGGINGFACE_SPACE:", IN_HUGGINGFACE_SPACE)
33
  print("STOP_SPACE_TIMEOUT:", STOP_SPACE_TIMEOUT)
@@ -104,6 +105,15 @@ def auto_stop():
104
  server_space_id = SPACE_PARAMS["server_space_id"]
105
  client_space_id = SPACE_PARAMS["client_space_id"]
106
  api = HfApi(token=HF_TOKEN)
 
 
 
 
 
 
 
 
 
107
  api.delete_repo(
108
  repo_id=server_space_id,
109
  repo_type="space"
@@ -224,10 +234,10 @@ class EnvHandler:
224
  with open(os.path.join(self.output, 'data.pkl'), 'wb') as wf:
225
  pickle.dump([self._save_data], wf)
226
 
227
- ground_xyz = np.asarray(o3d.io.read_point_cloud(os.path.join(output, 'ground.ply')).points)
228
- scene_xyz = np.asarray(o3d.io.read_point_cloud(os.path.join(output, 'scene.ply')).points)
229
  results = hugsim_evaluate([self._save_data], ground_xyz, scene_xyz)
230
- with open(os.path.join(output, 'eval.json'), 'w') as f:
231
  json.dump(results, f)
232
 
233
  self._log("Evaluation results saved.")
@@ -335,18 +345,16 @@ if __name__ == "__main__":
335
  {"camera": camera_config},
336
  {"kinematic": kinematic_config}
337
  )
338
- cfg.base.output_dir = cfg.base.output_dir + ad
339
 
340
  model_path = os.path.join(cfg.base.model_base, cfg.scenario.scene_name)
341
  model_config = OmegaConf.load(os.path.join(model_path, 'cfg.yaml'))
342
  model_config.update({"model_path": "/app/app_datas/PAMI2024/release/ss/scenes/nuscenes/scene-0383"})
343
  cfg.update(model_config)
344
 
345
- output = os.path.join(cfg.base.output_dir, cfg.scenario.scene_name+"_"+cfg.scenario.mode)
346
- os.makedirs(output, exist_ok=True)
347
 
348
- print("Output directory:", output)
349
- env_handler = EnvHandler(cfg, output)
350
  print("Environment handler initialized.")
351
  web_server = WebServer(env_handler, auth_token=os.getenv('HUGSIM_AUTH_TOKEN'))
352
  print("Web server initialized.")
 
28
  STOP_SPACE_TIMEOUT = int(os.getenv('STOP_SPACE_TIMEOUT', '7200'))
29
  HF_TOKEN = os.getenv('HF_TOKEN', None)
30
  SPACE_PARAMS = json.loads(os.getenv('PARAMS', '{}'))
31
+ OUTPUT_DIR = "/app/app_datas/output"
32
 
33
  print("IN_HUGGINGFACE_SPACE:", IN_HUGGINGFACE_SPACE)
34
  print("STOP_SPACE_TIMEOUT:", STOP_SPACE_TIMEOUT)
 
105
  server_space_id = SPACE_PARAMS["server_space_id"]
106
  client_space_id = SPACE_PARAMS["client_space_id"]
107
  api = HfApi(token=HF_TOKEN)
108
+
109
+ if GlobalState.done:
110
+ api.upload_folder(
111
+ repo_id=SPACE_PARAMS["competition_id"],
112
+ folder_path=OUTPUT_DIR,
113
+ repo_type="dataset",
114
+ path_in_repo=f"eval_results/{SPACE_PARAMS['submission_id']}",
115
+ )
116
+
117
  api.delete_repo(
118
  repo_id=server_space_id,
119
  repo_type="space"
 
234
  with open(os.path.join(self.output, 'data.pkl'), 'wb') as wf:
235
  pickle.dump([self._save_data], wf)
236
 
237
+ ground_xyz = np.asarray(o3d.io.read_point_cloud(os.path.join(self.output, 'ground.ply')).points)
238
+ scene_xyz = np.asarray(o3d.io.read_point_cloud(os.path.join(self.output, 'scene.ply')).points)
239
  results = hugsim_evaluate([self._save_data], ground_xyz, scene_xyz)
240
+ with open(os.path.join(self.output, 'eval.json'), 'w') as f:
241
  json.dump(results, f)
242
 
243
  self._log("Evaluation results saved.")
 
345
  {"camera": camera_config},
346
  {"kinematic": kinematic_config}
347
  )
 
348
 
349
  model_path = os.path.join(cfg.base.model_base, cfg.scenario.scene_name)
350
  model_config = OmegaConf.load(os.path.join(model_path, 'cfg.yaml'))
351
  model_config.update({"model_path": "/app/app_datas/PAMI2024/release/ss/scenes/nuscenes/scene-0383"})
352
  cfg.update(model_config)
353
 
354
+ os.makedirs(OUTPUT_DIR, exist_ok=True)
 
355
 
356
+ print("Output directory:", OUTPUT_DIR)
357
+ env_handler = EnvHandler(cfg, OUTPUT_DIR)
358
  print("Environment handler initialized.")
359
  web_server = WebServer(env_handler, auth_token=os.getenv('HUGSIM_AUTH_TOKEN'))
360
  print("Web server initialized.")