dmytromishkin commited on
Commit
5081776
·
verified ·
1 Parent(s): 9e478c8

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. LICENSE.md +13 -0
  2. README.md +18 -2
  3. script.py +39 -20
LICENSE.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright 2025 Dmytro Mishkin, Jack Langerman
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
README.md CHANGED
@@ -1,4 +1,20 @@
1
- # My Cool Handcrafted Submission 2025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- This repo contains a submission to the [S23DR Challenge](https://huggingface.co/spaces/usm3d/S23DR) (part of the [USM3D](https://usm3d.github.io/) workshop at CVPR2025). It was prepared by [dmytromishkin](https://huggingface.co/dmytromishkin).
4
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+ # Handcrafted solution example for the S23DR competition
5
+
6
+ This repo provides a minimalistic example of a wireframe estimation submission to S23DR competition.
7
+ We recommend you take a look at [this example](https://github.com/s23dr/hoho2025/blob/main/hoho2025/example_solutions.py), for detailed code of this submission. It also provides useful I/O and visualization functions.
8
+
9
+ This example seeks to simply provide minimal code which succeeds at reading the dataset and producing a solution (in this case two vertices at the origin and edge of zero length connecting them).
10
+
11
+ `script.py` - is the main file which is run by the competition space. It should produce `submission.parquet` as the result of the run. Please see the additional comments in the `script.py` file.
12
+
13
+
14
+ # How to submit
15
+
16
+ Use the notebook [example_notebook.ipynb](example_notebook.ipynb)
17
+
18
+
19
 
 
20
 
script.py CHANGED
@@ -11,12 +11,15 @@ import pandas as pd
11
  import numpy as np
12
  from datasets import load_dataset
13
  from typing import Dict
14
- from tqdm import tqdm
 
 
 
 
15
 
16
  def empty_solution(sample):
17
  '''Return a minimal valid solution, i.e. 2 vertices and 1 edge.'''
18
  return np.zeros((2,3)), [(0, 1)]
19
- from handcrafted_solution import predict
20
 
21
  class Sample(Dict):
22
  def pick_repr_data(self, x):
@@ -49,6 +52,7 @@ if __name__ == "__main__":
49
  print(os.system('ls -lahtr /tmp/data/'))
50
  print('/tmp/data/data')
51
  print(os.system('ls -lahtrR /tmp/data/data'))
 
52
 
53
  data_path_test_server = Path('/tmp/data')
54
  data_path_local = Path().home() / '.cache/huggingface/datasets/usm3d___hoho25k_test_x/'
@@ -66,7 +70,15 @@ if __name__ == "__main__":
66
  repo_type="dataset",
67
  )
68
  data_path = data_path_test_server
 
 
69
  print(data_path)
 
 
 
 
 
 
70
  data_files = {
71
  "validation": [str(p) for p in data_path.rglob('*public*/**/*.tar')],
72
  "test": [str(p) for p in data_path.rglob('*private*/**/*.tar')],
@@ -78,33 +90,40 @@ if __name__ == "__main__":
78
  trust_remote_code=True,
79
  writer_batch_size=100
80
  )
 
81
  print('load with webdataset')
 
 
82
  print(dataset, flush=True)
83
 
84
  print('------------ Now you can do your solution ---------------')
85
  solution = []
86
- num_fails = 0
 
 
 
 
 
 
 
 
 
 
 
87
  for subset_name in dataset:
88
- for i, sample in enumerate(tqdm(dataset[subset_name])):
89
- # replace this with your solution
 
90
  print(Sample(sample), flush=True)
91
  print('------')
92
- try:
93
- pred_vertices, pred_edges = predict(sample, visualize=False)
94
- except Exception as e:
95
- print (f"Faile due to {e}")
96
- pred_vertices, pred_edges = empty_solution(sample)
97
- num_fails+=1
98
- #print (f'{pred_vertices=}, {pred_edges=}')
99
- solution.append({
100
- 'order_id': sample['order_id'],
101
- 'wf_vertices': pred_vertices.tolist(),
102
- 'wf_edges': pred_edges
103
- })
104
  print('------------ Saving results ---------------')
105
- print (f"Processed {len(solution)} entries, get {num_fails} fails")
106
- from time import sleep
107
- sleep(30)
108
  sub = pd.DataFrame(solution, columns=["order_id", "wf_vertices", "wf_edges"])
109
  sub.to_parquet("submission.parquet")
110
  print("------------ Done ------------ ")
 
11
  import numpy as np
12
  from datasets import load_dataset
13
  from typing import Dict
14
+ from joblib import Parallel, delayed
15
+ import os
16
+
17
+ from hoho2025.example_solutions import predict_wireframe
18
+ # check the https://github.com/s23dr/hoho2025/blob/main/hoho2025/example_solutions.py for the example solution
19
 
20
  def empty_solution(sample):
21
  '''Return a minimal valid solution, i.e. 2 vertices and 1 edge.'''
22
  return np.zeros((2,3)), [(0, 1)]
 
23
 
24
  class Sample(Dict):
25
  def pick_repr_data(self, x):
 
52
  print(os.system('ls -lahtr /tmp/data/'))
53
  print('/tmp/data/data')
54
  print(os.system('ls -lahtrR /tmp/data/data'))
55
+
56
 
57
  data_path_test_server = Path('/tmp/data')
58
  data_path_local = Path().home() / '.cache/huggingface/datasets/usm3d___hoho25k_test_x/'
 
70
  repo_type="dataset",
71
  )
72
  data_path = data_path_test_server
73
+
74
+
75
  print(data_path)
76
+
77
+ # dataset = load_dataset(params['dataset'], trust_remote_code=True, use_auth_token=params['token'])
78
+ # data_files = {
79
+ # "validation": [str(p) for p in [*data_path.rglob('*validation*.arrow')]+[*data_path.rglob('*public*/**/*.tar')]],
80
+ # "test": [str(p) for p in [*data_path.rglob('*test*.arrow')]+[*data_path.rglob('*private*/**/*.tar')]],
81
+ # }
82
  data_files = {
83
  "validation": [str(p) for p in data_path.rglob('*public*/**/*.tar')],
84
  "test": [str(p) for p in data_path.rglob('*private*/**/*.tar')],
 
90
  trust_remote_code=True,
91
  writer_batch_size=100
92
  )
93
+
94
  print('load with webdataset')
95
+
96
+
97
  print(dataset, flush=True)
98
 
99
  print('------------ Now you can do your solution ---------------')
100
  solution = []
101
+
102
+ def process_sample(sample):
103
+ try:
104
+ pred_vertices, pred_edges = predict_wireframe(sample)
105
+ except:
106
+ pred_vertices, pred_edges = empty_solution(sample)
107
+ return {
108
+ 'order_id': sample['order_id'],
109
+ 'wf_vertices': pred_vertices.tolist(),
110
+ 'wf_edges': pred_edges
111
+ }
112
+ num_cores = len(os.sched_getaffinity(0))
113
  for subset_name in dataset:
114
+ samples = list(dataset[subset_name])
115
+ # Print sample info for just a few samples to avoid clutter
116
+ for i, sample in enumerate(samples[:2]):
117
  print(Sample(sample), flush=True)
118
  print('------')
119
+
120
+ # Process samples in parallel with simple tqdm progress tracking
121
+ results = Parallel(n_jobs=num_cores)(
122
+ delayed(process_sample)(sample) for sample in tqdm(samples, desc=f"Processing {subset_name}")
123
+ )
124
+ solution.extend(results)
125
+
 
 
 
 
 
126
  print('------------ Saving results ---------------')
 
 
 
127
  sub = pd.DataFrame(solution, columns=["order_id", "wf_vertices", "wf_edges"])
128
  sub.to_parquet("submission.parquet")
129
  print("------------ Done ------------ ")