Text-to-3D
image-to-3d
chaoxu commited on
Commit
5abebd6
β€’
1 Parent(s): 3055ceb

elev estimate synced from GitHub

Browse files
Files changed (27) hide show
  1. {one2345_elev_est β†’ elevation_estimate}/.gitignore +0 -0
  2. elevation_estimate/__init__.py +0 -0
  3. elevation_estimate/estimate_wild_imgs.py +10 -0
  4. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/__init__.py +0 -0
  5. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/backbone/__init__.py +0 -0
  6. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/backbone/resnet_fpn.py +0 -0
  7. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/loftr.py +0 -0
  8. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/loftr_module/__init__.py +0 -0
  9. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/loftr_module/fine_preprocess.py +0 -0
  10. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/loftr_module/linear_attention.py +0 -0
  11. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/loftr_module/transformer.py +0 -0
  12. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/coarse_matching.py +0 -0
  13. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/cvpr_ds_config.py +0 -0
  14. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/fine_matching.py +0 -0
  15. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/geometry.py +0 -0
  16. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/position_encoding.py +0 -0
  17. {one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/supervision.py +0 -0
  18. {one2345_elev_est β†’ elevation_estimate}/pyproject.toml +1 -1
  19. elevation_estimate/utils/__init__.py +0 -0
  20. {one2345_elev_est/oee β†’ elevation_estimate}/utils/elev_est_api.py +10 -15
  21. {one2345_elev_est/oee β†’ elevation_estimate}/utils/plotting.py +0 -0
  22. {one2345_elev_est/oee β†’ elevation_estimate}/utils/plt_utils.py +0 -0
  23. {one2345_elev_est/oee β†’ elevation_estimate}/utils/utils3d.py +0 -0
  24. elevation_estimate/utils/weights/.gitkeep +0 -0
  25. {one2345_elev_est/tools β†’ elevation_estimate/utils}/weights/indoor_ds_new.ckpt +0 -0
  26. one2345_elev_est/tools/estimate_wild_imgs.py +0 -35
  27. one2345_elev_est/tools/example.py +0 -38
{one2345_elev_est β†’ elevation_estimate}/.gitignore RENAMED
File without changes
elevation_estimate/__init__.py ADDED
File without changes
elevation_estimate/estimate_wild_imgs.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import os.path as osp
2
+ from .utils.elev_est_api import elev_est_api
3
+
4
+ def estimate_elev(root_dir):
5
+ img_dir = osp.join(root_dir, "stage2_8")
6
+ img_paths = []
7
+ for i in range(4):
8
+ img_paths.append(f"{img_dir}/0_{i}.png")
9
+ elev = elev_est_api(img_paths)
10
+ return elev
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/__init__.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/backbone/__init__.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/backbone/resnet_fpn.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/loftr.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/loftr_module/__init__.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/loftr_module/fine_preprocess.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/loftr_module/linear_attention.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/loftr_module/transformer.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/coarse_matching.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/cvpr_ds_config.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/fine_matching.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/geometry.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/position_encoding.py RENAMED
File without changes
{one2345_elev_est/oee/models β†’ elevation_estimate}/loftr/utils/supervision.py RENAMED
File without changes
{one2345_elev_est β†’ elevation_estimate}/pyproject.toml RENAMED
@@ -1,5 +1,5 @@
1
  [project]
2
- name = "one2345_elev_est"
3
  version = "0.1"
4
 
5
  [tool.setuptools.packages.find]
 
1
  [project]
2
+ name = "elevation_estimate"
3
  version = "0.1"
4
 
5
  [tool.setuptools.packages.find]
elevation_estimate/utils/__init__.py ADDED
File without changes
{one2345_elev_est/oee β†’ elevation_estimate}/utils/elev_est_api.py RENAMED
@@ -1,21 +1,19 @@
1
- import matplotlib.pyplot as plt
2
- import warnings
3
-
4
- import numpy as np
5
- import cv2
6
  import os
 
 
7
  import os.path as osp
8
  import imageio
9
  from copy import deepcopy
10
 
11
  import loguru
12
  import torch
13
- from oee.models.loftr import LoFTR, default_cfg
14
  import matplotlib.cm as cm
 
15
 
16
- from oee.utils import plt_utils
17
- from oee.utils.plotting import make_matching_figure
18
- from oee.utils.utils3d import rect_to_img, canonical_to_camera, calc_pose
 
19
 
20
 
21
  class ElevEstHelper:
@@ -28,13 +26,10 @@ class ElevEstHelper:
28
  _default_cfg = deepcopy(default_cfg)
29
  _default_cfg['coarse']['temp_bug_fix'] = True # set to False when using the old ckpt
30
  matcher = LoFTR(config=_default_cfg)
31
- ckpt_path = "weights/indoor_ds_new.ckpt"
 
32
  if not osp.exists(ckpt_path):
33
- loguru.logger.info("Downloading feature matcher...")
34
- os.makedirs("weights", exist_ok=True)
35
- import gdown
36
- gdown.cached_download(url="https://drive.google.com/uc?id=19s3QvcCWQ6g-N1PrYlDCg-2mOJZ3kkgS",
37
- path=ckpt_path)
38
  matcher.load_state_dict(torch.load(ckpt_path)['state_dict'])
39
  matcher = matcher.eval().cuda()
40
  cls._feature_matcher = matcher
 
 
 
 
 
 
1
  import os
2
+ import cv2
3
+ import numpy as np
4
  import os.path as osp
5
  import imageio
6
  from copy import deepcopy
7
 
8
  import loguru
9
  import torch
 
10
  import matplotlib.cm as cm
11
+ import matplotlib.pyplot as plt
12
 
13
+ from ..loftr import LoFTR, default_cfg
14
+ from . import plt_utils
15
+ from .plotting import make_matching_figure
16
+ from .utils3d import rect_to_img, canonical_to_camera, calc_pose
17
 
18
 
19
  class ElevEstHelper:
 
26
  _default_cfg = deepcopy(default_cfg)
27
  _default_cfg['coarse']['temp_bug_fix'] = True # set to False when using the old ckpt
28
  matcher = LoFTR(config=_default_cfg)
29
+ current_dir = os.path.dirname(os.path.abspath(__file__))
30
+ ckpt_path = os.path.join(current_dir, "weights/indoor_ds_new.ckpt")
31
  if not osp.exists(ckpt_path):
32
+ raise FileNotFoundError(f"Checkpoint not found at {ckpt_path}")
 
 
 
 
33
  matcher.load_state_dict(torch.load(ckpt_path)['state_dict'])
34
  matcher = matcher.eval().cuda()
35
  cls._feature_matcher = matcher
{one2345_elev_est/oee β†’ elevation_estimate}/utils/plotting.py RENAMED
File without changes
{one2345_elev_est/oee β†’ elevation_estimate}/utils/plt_utils.py RENAMED
File without changes
{one2345_elev_est/oee β†’ elevation_estimate}/utils/utils3d.py RENAMED
File without changes
elevation_estimate/utils/weights/.gitkeep ADDED
File without changes
{one2345_elev_est/tools β†’ elevation_estimate/utils}/weights/indoor_ds_new.ckpt RENAMED
File without changes
one2345_elev_est/tools/estimate_wild_imgs.py DELETED
@@ -1,35 +0,0 @@
1
- import tqdm
2
- import imageio
3
- import json
4
- import os.path as osp
5
- import os
6
-
7
- from oee.utils import plt_utils
8
- from oee.utils.elev_est_api import elev_est_api
9
-
10
-
11
- def visualize(img_paths, elev):
12
- imgs = [imageio.imread_v2(img_path) for img_path in img_paths]
13
- plt_utils.image_grid(imgs, 2, 2, label=f"elev={elev}")
14
-
15
-
16
- def estimate_elev(root_dir):
17
- # root_dir = "/home/linghao/Datasets/objaverse-processed/zero12345_img/wild"
18
- # dataset = "supp_fail"
19
- # root_dir = "/home/chao/chao/OpenComplete/zero123/zero123/gradio_tmp/"
20
- # obj_names = sorted(os.listdir(root_dir))
21
- # results = {}
22
- # for obj_name in tqdm.tqdm(obj_names):
23
- img_dir = osp.join(root_dir, "stage2_8")
24
- img_paths = []
25
- for i in range(4):
26
- img_paths.append(f"{img_dir}/0_{i}.png")
27
- elev = elev_est_api(img_paths)
28
- # visualize(img_paths, elev)
29
- # results[obj_name] = elev
30
- # json.dump(results, open(osp.join(root_dir, f"../{dataset}_elev.json"), "w"), indent=4)
31
- return elev
32
-
33
-
34
- # if __name__ == '__main__':
35
- # main()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
one2345_elev_est/tools/example.py DELETED
@@ -1,38 +0,0 @@
1
- import imageio
2
- import numpy as np
3
-
4
- from oee.utils import plt_utils
5
- from oee.utils.elev_est_api import elev_est_api
6
- import argparse
7
-
8
-
9
- def visualize(img_paths, elev):
10
- imgs = [imageio.imread_v2(img_path) for img_path in img_paths]
11
- plt_utils.image_grid(imgs, 2, 2, label=f"elev={elev}")
12
-
13
-
14
- def main():
15
- parser = argparse.ArgumentParser()
16
- parser.add_argument("--img_paths", type=str, nargs=4, help="image paths",
17
- default=["assets/example_data/0_0.png",
18
- "assets/example_data/0_1.png",
19
- "assets/example_data/0_2.png",
20
- "assets/example_data/0_3.png"])
21
- parser.add_argument("--min_elev", type=float, default=30, help="min elevation")
22
- parser.add_argument("--max_elev", type=float, default=150, help="max elevation")
23
- parser.add_argument("--dbg", default=False, action="store_true", help="debug mode")
24
- parser.add_argument("--K_path", type=str, default=None, help="path to K")
25
- args = parser.parse_args()
26
-
27
- if args.K_path is not None:
28
- K = np.loadtxt(args.K_path)
29
- else:
30
- K = None
31
-
32
- elev = elev_est_api(args.img_paths, args.min_elev, args.max_elev, K, args.dbg)
33
-
34
- visualize(args.img_paths, elev)
35
-
36
-
37
- if __name__ == '__main__':
38
- main()