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

Will the test code be updated to properly work with own 512 and 224 pretrained models? #261

Open
netrunner-exe opened this issue May 8, 2022 · 9 comments

Comments

@netrunner-exe
Copy link

No description provided.

@boreas-l
Copy link

boreas-l commented May 9, 2022

I find:
1、in train.py and test_wholeimage_swapsingle.py, the initial network was not the same...
in train.py:

from models.projected_model import fsModel  
# model initial  
model = fsModel()  
# fsModel() source from **projected_model.py**, and in that, the Generator_Adain_Upsample source from fs_networks_fix

and in test_wholeimage_swapsingle.py:

from models.models import create_model  
# model initial
model = create_model(opt)  
# fsModel() source from fs_model.py, and in that, the Generator_Adain_Upsample source from fs_networks_512  

in general, the Generator_Adain_Upsample is diffenent between train.py and test_wholeimage_swapsingle.py.

2、so, after train, in your own pretrained_weight, you need initial network like train.py instead of test_wholeimage_swapsingle.py.

# test.py  
from models.projected_model import fsModel  

model = fsModel()  
# remenber add Gdeep=True in TestOptions 
model.initialize(opt)  
model.netG.eval()  

# and data preprocess like train.py
def data_preprocess(img):  
    img_tensor = transforms.ToTensor()(img)  
    img_tensor = img_tensor.view(-1, 3, img.size[0], img.size[1])  
    mean = torch.tensor([0.485, 0.456, 0.406]).cuda().view(1, 3, 1, 1)  
    std = torch.tensor([0.229, 0.224, 0.225]).cuda().view(1, 3, 1, 1)  
    img_tensor = img_tensor.cuda(non_blocking=True)  
    img_tensor = img_tensor.sub_(mean)._div(std)  
    return img_tensor  

@YaoQ
Copy link

YaoQ commented May 9, 2022

The preprocess and the postprocess part for own trained model are different the inference demo code, and you have to update the demo code according to train.py

@netrunner-exe
Copy link
Author

netrunner-exe commented May 9, 2022

I find: 1、in train.py and test_wholeimage_swapsingle.py, the initial network was not the same... in train.py:

from models.projected_model import fsModel  
# model initial  
model = fsModel()  
# fsModel() source from **projected_model.py**, and in that, the Generator_Adain_Upsample source from fs_networks_fix

and in test_wholeimage_swapsingle.py:

from models.models import create_model  
# model initial
model = create_model(opt)  
# fsModel() source from fs_model.py, and in that, the Generator_Adain_Upsample source from fs_networks_512  

in general, the Generator_Adain_Upsample is diffenent between train.py and test_wholeimage_swapsingle.py.

2、so, after train, in your own pretrained_weight, you need initial network like train.py instead of test_wholeimage_swapsingle.py.

# test.py  
from models.projected_model import fsModel  

model = fsModel()  
# remenber add Gdeep=True in TestOptions 
model.initialize(opt)  
model.netG.eval()  

# and data preprocess like train.py
def data_preprocess(img):  
    img_tensor = transforms.ToTensor()(img)  
    img_tensor = img_tensor.view(-1, 3, img.size[0], img.size[1])  
    mean = torch.tensor([0.485, 0.456, 0.406]).cuda().view(1, 3, 1, 1)  
    std = torch.tensor([0.229, 0.224, 0.225]).cuda().view(1, 3, 1, 1)  
    img_tensor = img_tensor.cuda(non_blocking=True)  
    img_tensor = img_tensor.sub_(mean)._div(std)  
    return img_tensor  

Thank you very much! I tried to make changes but got errors. But still, the fact that at least someone managed to run the test code pleases me. Otherwise, what is the point of training if it is impossible to fully run the test code with own model? Just because it's been asked for so long? Let's wait and hope that the developer will fix the test code and give us the opportunity to run all test code with old models and with our own pretrained models as it should be.

@netrunner-exe
Copy link
Author

I find: 1、in train.py and test_wholeimage_swapsingle.py, the initial network was not the same... in train.py:

from models.projected_model import fsModel  
# model initial  
model = fsModel()  
# fsModel() source from **projected_model.py**, and in that, the Generator_Adain_Upsample source from fs_networks_fix

and in test_wholeimage_swapsingle.py:

from models.models import create_model  
# model initial
model = create_model(opt)  
# fsModel() source from fs_model.py, and in that, the Generator_Adain_Upsample source from fs_networks_512  

in general, the Generator_Adain_Upsample is diffenent between train.py and test_wholeimage_swapsingle.py.

2、so, after train, in your own pretrained_weight, you need initial network like train.py instead of test_wholeimage_swapsingle.py.

# test.py  
from models.projected_model import fsModel  

model = fsModel()  
# remenber add Gdeep=True in TestOptions 
model.initialize(opt)  
model.netG.eval()  

# and data preprocess like train.py
def data_preprocess(img):  
    img_tensor = transforms.ToTensor()(img)  
    img_tensor = img_tensor.view(-1, 3, img.size[0], img.size[1])  
    mean = torch.tensor([0.485, 0.456, 0.406]).cuda().view(1, 3, 1, 1)  
    std = torch.tensor([0.229, 0.224, 0.225]).cuda().view(1, 3, 1, 1)  
    img_tensor = img_tensor.cuda(non_blocking=True)  
    img_tensor = img_tensor.sub_(mean)._div(std)  
    return img_tensor  

Can you provide full working with own pretrained 512 model example of test_wholeimage_swapsingle.py or manual on what and where to change or add?

@boreas-l
Copy link

so glad, can you provide your email? or another way?

@netrunner-exe
Copy link
Author

netrunner-exe commented May 10, 2022

so glad, can you provide your email? or another way?

netrunner.exe@gmail.com @boreas-l

@netrunner-exe
Copy link
Author

so glad, can you provide your email? or another way?

That would be great, looking forward to it!

@BeaverInGreenland
Copy link

According to what is said here, how should we modify the arguments to make an inference on our own pretrained models ?

@netrunner-exe
Copy link
Author

According to what is said here, how should we modify the arguments to make an inference on our own pretrained models ?

Hah, in usage doesn't writed anything about how to use own pretrained models. Currently, the test code is incompatible with published training code and own pretrained models...Do not waste your time and resources - there is no point in training, since you will not be able to use your model in any way:) Therefore, we are waiting for the announced SimSwap ++, maybe we will have more luck with it :)

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

4 participants