text stringlengths 1 93.6k |
|---|
}
|
for batch_idx, test_batch in enumerate(tqdm(test_dataloader)):
|
image = test_batch['target_image']
|
sem_label = test_batch['target_sem_label']
|
camera = test_batch['target_camera']
|
depth = test_batch['target_depth']
|
source_image = test_batch['source_image']
|
source_camera = test_batch['source_camera']
|
source_sem_label = test_batch['source_sem_label']
|
source_depth = test_batch['source_depth']
|
pair_ids = test_batch['pair_id']
|
# fetch depth pred
|
depth_save_path = os.path.join(result_dir, 'predictions', '{}_depth.npz'.format(pair_ids[0]))
|
depth_pred = np.load(depth_save_path)['depth']
|
depth_pred = torch.FloatTensor(depth_pred)
|
value_mask = torch.logical_not(torch.isnan(depth))
|
value_mask = torch.logical_and(value_mask, depth > 0.1)
|
stuff_mask = (sem_label == 0) # wall
|
stuff_mask = torch.logical_or(stuff_mask, sem_label == 1) # floor
|
stuff_mask = torch.logical_or(stuff_mask, sem_label == 21) # ceiling
|
object_mask = torch.logical_not(stuff_mask)
|
for sem_type in depth_metrics:
|
if sem_type == 'all':
|
valid_mask = value_mask
|
elif sem_type == 'stuff':
|
valid_mask = torch.logical_and(value_mask, stuff_mask)
|
elif sem_type == 'object':
|
valid_mask = torch.logical_and(value_mask, object_mask)
|
thres_all = valid_mask.sum().item()
|
sub_depth_pred = depth_pred[valid_mask]
|
sub_depth = depth[valid_mask]
|
l1_abs = torch.abs(sub_depth_pred - sub_depth)
|
depth_metrics[sem_type]['absolute']['cnt'] += thres_all
|
depth_metrics[sem_type]['absolute']['total'] += l1_abs.sum().item()
|
absrel = torch.abs(sub_depth_pred - sub_depth) / sub_depth
|
depth_metrics[sem_type]['absrel']['cnt'] += thres_all
|
depth_metrics[sem_type]['absrel']['total'] += absrel.sum().item()
|
thres = torch.max(
|
sub_depth_pred / sub_depth,
|
sub_depth / sub_depth_pred
|
)
|
delta_1 = thres < 1.25
|
depth_metrics[sem_type]['thres 1.25']['cnt'] += thres_all
|
depth_metrics[sem_type]['thres 1.25']['total'] += delta_1.sum().item()
|
delta_2 = thres < 1.25 ** 2
|
depth_metrics[sem_type]['thres 1.25^2']['cnt'] += thres_all
|
depth_metrics[sem_type]['thres 1.25^2']['total'] += delta_2.sum().item()
|
delta_3 = thres < 1.25 ** 3
|
depth_metrics[sem_type]['thres 1.25^3']['cnt'] += thres_all
|
depth_metrics[sem_type]['thres 1.25^3']['total'] += delta_3.sum().item()
|
if cfg.test.use_depth:
|
print("[depth]")
|
for sem_type in depth_metrics:
|
print("Semantic: {}".format(sem_type))
|
for metric in depth_metrics[sem_type]:
|
depth_metrics[sem_type][metric]['result'] = depth_metrics[sem_type][metric]['total'] / depth_metrics[sem_type][metric]['cnt']
|
print("\t{}: {}".format(metric, depth_metrics[sem_type][metric]['result']))
|
print("[done]")
|
if __name__ == "__main__":
|
main()
|
# <FILESEP>
|
"""
|
Uploads queries from 'customqueries.json' in bulk to BHCE, using the BHCE API.
|
"""
|
import json
|
import requests
|
# Your configuration here:
|
API_URL = "<YOUR_URL_HERE>/api/v2/saved-queries"
|
API_TOKEN = "Bearer <YOUR_BAERER_TOKEN_HERE>"
|
with open("customqueries.json", "r") as file:
|
data = json.load(file)
|
queries = data.get("queries", [])
|
def send_query(name, query, description=""):
|
headers = {
|
"accept": "application/json",
|
"Prefer": "0",
|
"Content-Type": "application/json",
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.