forked from caoji2001/HOSER
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
32 lines (25 loc) · 712 Bytes
/
utils.py
File metadata and controls
32 lines (25 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from types import SimpleNamespace
import math
import random
import numpy as np
import torch
def set_seed(seed):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
if torch.cuda.is_available():
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
def create_nested_namespace(data):
if isinstance(data, dict):
return SimpleNamespace(
**{k: create_nested_namespace(v) for k, v in data.items()}
)
return data
def get_angle(lat1, lon1, lat2, lon2):
dy = lat2 - lat1
dx = math.cos(math.pi / 180 * lat1) * (lon2 - lon1)
angle = math.atan2(dy, dx)
if angle < 0:
angle += math.pi * 2
return angle