Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get a subspace in W+? #1

Open
Kihensarn opened this issue May 20, 2022 · 1 comment
Open

How to get a subspace in W+? #1

Kihensarn opened this issue May 20, 2022 · 1 comment

Comments

@Kihensarn
Copy link

Kihensarn commented May 20, 2022

An excellent work. But there are some questions for me.How can I get a subspace that dosen't change the selected region in W+ space? And how much time it cost? Hope you can help me.

@prclibo
Copy link
Owner

prclibo commented May 26, 2022

You can refer to the following code in the discover_subspace.ipynb.

if task == 'eye_photo_act_mp_sup_mp':
    for space, magnitude in zip(['s'], [20]): # zip(['s', 'w+', 'w', 'z'], [8, 2, 2, 1]):
        dataloader = dataloader_to(zs0[:2], space)
        nose_segmenter = FaceSegmenter(segmenter_path, mask_labels=[4, 5, 6], morphology='dilation', ks_ratio=0.1).to(device)
        f_photo = MaskedMSE(generator, space, nose_segmenter, (48, 48), return_complementary=True)

        JtJs_photo = load_or_compute(cache_path % (space, task, 'photo'), lambda: find_jtj_direct(f_photo, dataloader), recompute=False, map_location=device)
        with torch.no_grad():
            s_act, v_act = compute_early_projected_pca(JtJs_photo[0],[JtJs_photo[1]], sup_ratio=[1e-3])

            torch.save([s_act, v_act], span_path % (space, task))
            visualize(zs0[[21, 30]], space, magnitude, v_act, steps=[ -1, 1], selector=range(10))

Basically this code changes the region marked by nose_segmenter (wrong name, should be eye_segmenter) while preserving the rest region (as you need). For W+ space, just assign "w+" to space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants