cvlab-epfl/tf-lift

get both keypoints and descriptors in one function call.

Opened this issue · 5 comments

Hello, thank you very much for sharing tf version of LIFT.

The question is:

In tester we got three possible subtasks for which of them we got model to download, many the functions in tester works taking in account config.subtask value.

So let`s say I want to obtain descriptors, then I should first launch tester with subtask=='kps' and get keypoints, then with subtask=='ori' and get them with orientations, and finally I should launch tester with subtask=='desc' and compute descriptors from image and keypoints from previous('ori') launch.

So I`ll need to reinitialize tester 3 times or at least tester.network and tester.subtask attributes.
Which is not handy.

Is there someway to obtain both keypoints and descriptor from one object via method call and without reinitializing tester few times in a row? Something like:

lift = LIFT()
kps, desc =lift.get_kps_n_desc(img) 

Hello, thank you very much for sharing tf version of LIFT.

The question is:

In tester we got three possible subtasks for which of them we got model to download, many the functions in tester works taking in account config.subtask value.

So let`s say I want to obtain descriptors, then I should first launch tester with subtask=='kps' and get keypoints, then with subtask=='ori' and get them with orientations, and finally I should launch tester with subtask=='desc' and compute descriptors from image and keypoints from previous('ori') launch.

So I`ll need to reinitialize tester 3 times or at least tester.network and tester.subtask attributes.
Which is not handy.

Is there someway to obtain both keypoints and descriptor from one object via method call and without reinitializing tester few times in a row? Something like:

lift = LIFT()
kps, desc =lift.get_kps_n_desc(img) 

It is the task I am working on. I was thinking to write a python script and call subtask kps, ori and desc one by one.

`
class Sys_command():
class Clock():
def init(self):
self.st = 0
self.en = 0

    def start(self):
        self.reset()
        self.st = time.time()

    def reset(self):
        self.st = 0
        self.en = 0

    def end(self):
        self.en = time.time()

    def get_during(self):
        return self.en - self.st
@classmethod
def demo(cls):
    os.system('ls')

@classmethod
def demo_python(cls):
    print('python lift_runner.py')
    os.system('python lift_runner.py')

@classmethod
def python_command(cls, command='ls'):
    os.system(command)

@classmethod
def main_lift_release_aug(cls, img_path, kp_txt, ori_txt, desc_h5):
    run_kp = 'python main.py --task=test --subtask=kp --logdir=release-aug --test_img_file=%s --test_out_file=%s --use_batch_norm=false --mean_std_type=hardcoded'
    run_kp = run_kp % (img_path, kp_txt)

    run_ori = 'python main.py --task=test --subtask=ori --logdir=release-aug --test_img_file=%s --test_out_file=%s --test_kp_file=%s  --use_batch_norm=false --mean_std_type=hardcoded'
    run_ori = run_ori % (img_path, ori_txt, kp_txt)

    run_desc = 'python main.py --task=test --subtask=desc --logdir=release-aug --test_img_file=%s --test_out_file=%s --test_kp_file=%s  --use_batch_norm=false --mean_std_type=hardcoded'
    run_desc = run_desc % (img_path, desc_h5, ori_txt)

    cls.python_command(run_kp)
    cls.python_command(run_ori)
    cls.python_command(run_desc)

@classmethod
def demo_lisf(cls):
    # cp /deep_homo_test/lift_runner.py  /tf-lift/
    clock = Clock()
    clock.start()
    lift_test_root = '/deep_homo_test'
    img_path = os.path.join(lift_test_root, 'demo.JPG')
    kp_txt = os.path.join(lift_test_root, 'demo_kp.txt')
    ori_txt = os.path.join(lift_test_root, 'demo_ori.txt')
    desc_h5 = os.path.join(lift_test_root, 'demo_desc.h5')
    cls.main_lift_release_aug(img_path, kp_txt, ori_txt, desc_h5)
    clock.end()
    print('=' * 5 + ' use time: %ss' % clock.get_during())`

@coolbeam hey coolbeam, I am working on Lift now. Could you please send me the script you refered so that I can get both keypoints and descriptors in one function call.

Thanks a lot for you help

@coolbeam hey coolbeam, I am working on Lift now. Could you please send me the script you refered so that I can get both keypoints and descriptors in one function call.

Thanks a lot for you help

Hi, The code is provided in the previous reply. This is done by using os.system('command to call kp, ori and desc').

@ZhixiongSun ,
You can get help from:
https://github.com/4xle/tf-lift/blob/master/run_test_pass_on_image.py
which is from the PR from @4xle.

It is available by from subprocess import run to run several python scripts in a shell in order.