DragGAN icon indicating copy to clipboard operation
DragGAN copied to clipboard

Adding functions to input custom image

Open tianhaoxie opened this issue 1 year ago • 18 comments

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.

tianhaoxie avatar Jun 30 '23 12:06 tianhaoxie

@tianhaoxie very cool! how do we change the base model? is the default the horse one?

radames avatar Jul 01 '23 17:07 radames

@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.

tianhaoxie avatar Jul 01 '23 18:07 tianhaoxie

sorry, I just notice that, testing! great it uses the selected checkpoint 👏 very cool!

radames avatar Jul 01 '23 18:07 radames

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): resize = (1024,512) if torch.is_tensor(img) == False: transform = transforms.Compose( [ transforms.Resize(resize, ),

                transforms.ToTensor(),
                transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
            ]
        )

.... It will run, but wont make better results,

NandhaKishorM avatar Jul 01 '23 20:07 NandhaKishorM

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): resize = (1024,512) if torch.is_tensor(img) == False: transform = transforms.Compose( [ transforms.Resize(resize, ),

                transforms.ToTensor(),
                transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
            ]
        )

.... 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.

tianhaoxie avatar Jul 01 '23 22:07 tianhaoxie

hi @tianhaoxie , I also noticed that you might need to update the generator on the current model following this https://github.com/danielroich/PTI/issues/26 wdyt?

  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

radames avatar Jul 08 '23 01:07 radames

I follow the PTI and meet this https://github.com/danielroich/PTI/issues/50 , I hope this pr can help me.

631068264 avatar Jul 10 '23 07:07 631068264

Hi, i got a picture when i run pti, but the picture is blurry。 173729 please help me, thanks @tianhaoxie

zhaoxiong123 avatar Jul 10 '23 09:07 zhaoxiong123

I follow the PTI and meet this danielroich/PTI#50 , I hope this pr can help me.

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.

tianhaoxie avatar Jul 10 '23 12:07 tianhaoxie

Hi, i got a picture when i run pti, but the picture is blurry。 173729 please help me, thanks @tianhaoxie

It is normal for inversion to get results blurred and distorted.

tianhaoxie avatar Jul 10 '23 12:07 tianhaoxie

is there a possibility that in the future we can edit any image we add?

cocojambo89 avatar Jul 10 '23 18:07 cocojambo89

@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? When I load the custom image, the gradio UI is stuck somewhere.

MittalNeha avatar Jul 13 '23 09:07 MittalNeha

@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? When I load the custom image, the gradio UI is stuck somewhere.

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.

tianhaoxie avatar Jul 13 '23 11:07 tianhaoxie

@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? When I load the custom image, the gradio UI is stuck somewhere.

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?

cocojambo89 avatar Jul 13 '23 12:07 cocojambo89

@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? When I load the custom image, the gradio UI is stuck somewhere.

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).

tianhaoxie avatar Jul 13 '23 13:07 tianhaoxie

@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? When I load the custom image, the gradio UI is stuck somewhere.

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?

cocojambo89 avatar Jul 13 '23 17:07 cocojambo89

@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? When I load the custom image, the gradio UI is stuck somewhere.

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.

JanineCHEN avatar Aug 27 '23 08:08 JanineCHEN

looking forward

timchenxiaoyu avatar Jan 19 '24 03:01 timchenxiaoyu