Upload 7 files
Browse files- ensemble.py +56 -0
- vswin_base_depth/result_swin_base_depth.pkl +3 -0
- vswin_base_rgb/result_swin-base_rgb.pkl +3 -0
- vswin_large_depth/result_swin_large_depth.pkl +3 -0
- vswin_large_rgb/result_swin_large_rgb.pkl +3 -0
- vswin_small_depth/result_swin_small_depth.pkl +3 -0
- vswin_small_rgb/result_swin_small_rgb.pkl +3 -0
ensemble.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#coding:utf-8
|
| 2 |
+
import os
|
| 3 |
+
import pickle
|
| 4 |
+
import zipfile
|
| 5 |
+
from os.path import basename
|
| 6 |
+
import tqdm
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
def read_numpy(file_path):
|
| 10 |
+
return np.load(file_path)
|
| 11 |
+
|
| 12 |
+
def load_pkl(file_path):
|
| 13 |
+
with open(file_path, 'rb') as f:
|
| 14 |
+
data = pickle.load(f)
|
| 15 |
+
f.close()
|
| 16 |
+
return data
|
| 17 |
+
|
| 18 |
+
with open('../data/label_map.txt', 'r') as f:
|
| 19 |
+
ids = [line.strip() for line in f.readlines()]
|
| 20 |
+
|
| 21 |
+
def get_prob_labels(file_path):
|
| 22 |
+
pred_meta = load_pkl(file_path)
|
| 23 |
+
out_probs = [x['pred_score'].cpu().numpy() for x in pred_meta]
|
| 24 |
+
out_probs = np.vstack(out_probs) # [51440, 3215]
|
| 25 |
+
out_labels = np.argmax(out_probs, axis=1) # [51440]
|
| 26 |
+
return out_probs, out_labels
|
| 27 |
+
|
| 28 |
+
# RGB:
|
| 29 |
+
vswin_small_rgb_prob, _ = get_prob_labels('./vswin_small_rgb/result_swin_small_rgb.pkl')
|
| 30 |
+
vswin_base_rgb_prob, _ = get_prob_labels('./vswin_base_rgb/result_swin_base_rgb.pkl')
|
| 31 |
+
vswin_large_rgb_prob, _ = get_prob_labels('./vswin_large_rgb/result_swin_large_rgb.pkl')
|
| 32 |
+
rgb_prob = 0.4 * vswin_large_rgb_prob + 0.4 * vswin_base_rgb_prob + 0.2 * vswin_small_rgb_prob
|
| 33 |
+
|
| 34 |
+
# Depth:
|
| 35 |
+
vswin_small_depth_prob, _ = get_prob_labels('./vswin_small_depth/result_swin_small_depth.pkl')
|
| 36 |
+
vswin_base_depth_prob, _ = get_prob_labels('./vswin_base_depth/result_swin_base_depth.pkl')
|
| 37 |
+
vswin_large_depth_prob, _ = get_prob_labels('./vswin_large_depth/result_swin_large_depth.pkl')
|
| 38 |
+
|
| 39 |
+
depth_prob = 0.65 * vswin_large_depth_prob + 0.35 * vswin_base_depth_prob
|
| 40 |
+
|
| 41 |
+
fused_prob = rgb_prob * 0.5 + depth_prob * 0.5 # [51440. 3215]
|
| 42 |
+
|
| 43 |
+
out_labels = np.argmax(fused_prob, axis=1) # [51440]
|
| 44 |
+
############################################
|
| 45 |
+
|
| 46 |
+
with open('./answer.txt', 'w') as f:
|
| 47 |
+
for label in out_labels:
|
| 48 |
+
f.write(ids[label]+'\n')
|
| 49 |
+
f.close()
|
| 50 |
+
|
| 51 |
+
csv_file_path = './answer.txt'
|
| 52 |
+
zip_file_path = './answer.zip'
|
| 53 |
+
|
| 54 |
+
with zipfile.ZipFile(zip_file_path, 'w') as zipf:
|
| 55 |
+
zipf.write(csv_file_path, os.path.basename(csv_file_path))
|
| 56 |
+
|
vswin_base_depth/result_swin_base_depth.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c8fd7de88d8aac3dfb256af2209e89dd1a637bef8f185d1b2a9b644d09e2f44f
|
| 3 |
+
size 965149739
|
vswin_base_rgb/result_swin-base_rgb.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b96c6a4362aeba6894185bcaac5c25756061acbf4a3accb769faff28580632a7
|
| 3 |
+
size 964541738
|
vswin_large_depth/result_swin_large_depth.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c0f4e343fe7edff059204275d24be150cddbfb8827e4e102fb5f4fe3d963714e
|
| 3 |
+
size 965153079
|
vswin_large_rgb/result_swin_large_rgb.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:558e0d2c598bde2744bab46a4c8b6d9fdc04bb56de97d459cb54d13501b290f1
|
| 3 |
+
size 964801225
|
vswin_small_depth/result_swin_small_depth.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d7126f597541454dd01ef05c764e191919230cc3394875a946665bf10b36c5fc
|
| 3 |
+
size 964779047
|
vswin_small_rgb/result_swin_small_rgb.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5d8aa004a65126843cb35c24f75acb812fbb5306bb13697fef1a44b90b7f29fc
|
| 3 |
+
size 964525474
|