-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Adding functions to input custom image #142
base: main
Are you sure you want to change the base?
Conversation
@tianhaoxie very cool! how do we change the base model? is the default the horse one? |
It follows the original way of DragGAN, default is lion and you can change it by changing checkpoints. |
sorry, I just notice that, testing! great it uses the selected checkpoint 👏 very cool! |
It is not working with stylegan_human_v2_1024, tried resize = (1024, 512) on L69 in inversion.py and also at L227 def train(self,img,w_plus=False):
.... It will run, but wont make better results, |
It only supports the pre-trained models that you can download in the script. Since the GAN inversion is based on PTI, I'm not sure if it supports stylegan_human. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @tianhaoxie , you probably don't want to commit .pyc files here
please add it to
.gitignore
on the main repo
__pycache__/
*.pyc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and for the model,
you can add it to the script
https://github.com/XingangPan/DragGAN/blob/main/scripts/download_models.jsos
https://github.com/XingangPan/DragGAN/blob/main/scripts/download_model.py
generated_image = self.g_ema.synthesis(ws,noise_mode='const') | ||
loss = self.cacl_loss(self.percept,generated_image,real_img) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @tianhaoxie I notice for some models, there is a dimension mismatch here between generated_image and real_img, do you know why the synthesis is not matching the self.g_ema.img_resolution
?
you can test with stylegan_human_v2_512
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, stylegan2 human is different from others, which has 1024by512 resolution, whereas typically the H and W are same.
hi @tianhaoxie , I also noticed that you might need to update the generator on the current model following this tmp['G_ema'] = old_G.eval().requires_grad_(False).cpu()# copy.deepcopy(new_G).eval().requires_grad_(False).cpu()
tmp['G'] = new_G.eval().requires_grad_(False).cpu() # copy.deepcopy(new_G).eval().requires_grad_(False).cpu()
tmp['D'] = old_D
tmp['training_set_kwargs'] = None
tmp['augment_pipe'] = None |
I follow the PTI and meet this danielroich/PTI#50 , I hope this pr can help me. |
Hi, i got a picture when i run pti, but the picture is blurry。 |
It's because the image resolution is depended on the stylegan checkpoint you selected. If the image you input is not exactly the resolution of the checkpoint, you need to crop and resize. |
It is normal for inversion to get results blurred and distorted. |
is there a possibility that in the future we can edit any image we add? |
@tianhaoxie I am trying to run the gradio visualizer from your github but it is not working! Can you possibly lay down the steps you followed to generate the gan_inv checkpoints and what all are the limitations for running this demo? |
Except for the stylegan human, all other checkpoints should work. Btw, you should upload your image by clicking 'inverse custom image', rather than drop it in the image box. |
we have feature in draggan for edit any uploaded image? |
no, only the categories that the pre-trained checkpoints we have(i.e. horse, face). |
if i good understand you have pre-trained categories e.g. face, horse.. and i can upload any photo where is face e.g. face of my sister and edit with draggan but i can't upload some category which is not trained e.g. cat? |
I believe so, the provided image should roughly belong to a data distribution approximated by any of the provided trained stylegan models. |
looking forward |
Hi, I combined part of the PTI code into the visualizer so that custom image can be uploaded directly. It add some code and makes some change to the viz/renderer. Maybe after testing, it can be added as a branch.