text stringlengths 0 184 |
|---|
mapping_result_strs.append(result_str) |
for k in timings: |
overall_timings[k].extend(timings[k]) |
print('\nResults') |
for s in mapping_result_strs: |
print(s) |
run_mast3r_pipeline(samples, data_dir, workdir, is_train, mast3r_model, device) |
array_to_str = lambda array: ';'.join([f"{x:.09f}" for x in array]) |
none_to_str = lambda n: ';'.join(['nan'] * n) |
submission_file = '/kaggle/working/submission.csv' |
with open(submission_file, 'w') as f: |
if is_train: |
f.write('dataset,scene,image,rotation_matrix,translation_vector\n') |
for dataset, predictions in samples.items(): |
for prediction in predictions: |
cluster_name = 'outliers' if prediction.cluster_index is None else f'cluster{prediction.cluster_index}' |
# ✅ `rotation` is a list of lists, flatten it |
if prediction.rotation is None: |
rotation_str = none_to_str(9) |
else: |
rotation_flat = prediction.rotation.flatten() # flatten 3x3 list -> 9 elems |
rotation_str = array_to_str(rotation_flat) |
# ✅ `translation` is a flat list |
if prediction.translation is None: |
translation_str = none_to_str(3) |
else: |
translation_str = array_to_str(prediction.translation) |
f.write(f'{prediction.dataset},{cluster_name},{prediction.filename},{rotation_str},{translation_str}\n') |
else: |
f.write('image_id,dataset,scene,image,rotation_matrix,translation_vector\n') |
for dataset, predictions in samples.items(): |
for prediction in predictions: |
cluster_name = 'outliers' if prediction.cluster_index is None else f'cluster{prediction.cluster_index}' |
if prediction.rotation is None: |
rotation_str = none_to_str(9) |
else: |
rotation_flat = prediction.rotation.flatten() |
rotation_str = array_to_str(rotation_flat) |
if prediction.translation is None: |
translation_str = none_to_str(3) |
else: |
translation_str = array_to_str(prediction.translation) |
f.write(f'{prediction.image_id},{prediction.dataset},{cluster_name},{prediction.filename},{rotation_str},{translation_str}\n') |
# Preview the output |
!head {submission_file} |
# Definitely Compute results if running on the training set. |
# Do not do this when submitting a notebook for scoring. All you have to do is save your submission to /kaggle/working/submission.csv. |
if is_train: |
t = time() |
final_score, dataset_scores = metric.score( |
gt_csv='/kaggle/input/image-matching-challenge-2025/train_labels.csv', |
user_csv=submission_file, |
thresholds_csv='/kaggle/input/image-matching-challenge-2025/train_thresholds.csv', |
mask_csv=None if is_train else os.path.join(data_dir, 'mask.csv'), |
inl_cf=0, |
strict_cf=-1, |
verbose=True, |
) |
print(f'Computed metric in: {time() - t:.02f} sec.') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.