SimSwap icon indicating copy to clipboard operation
SimSwap copied to clipboard

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

Open netrunner-exe opened this issue 2 years ago • 9 comments

netrunner-exe avatar May 08 '22 07:05 netrunner-exe

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  

boreas-l avatar May 09 '22 08:05 boreas-l

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

YaoQ avatar May 09 '22 08:05 YaoQ

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 avatar May 09 '22 11:05 netrunner-exe

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?

netrunner-exe avatar May 10 '22 09:05 netrunner-exe

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

boreas-l avatar May 10 '22 09:05 boreas-l

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

[email protected] @boreas-l

netrunner-exe avatar May 10 '22 09:05 netrunner-exe

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

That would be great, looking forward to it!

netrunner-exe avatar May 10 '22 14:05 netrunner-exe

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

BeaverInGreenland avatar May 20 '22 09:05 BeaverInGreenland

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

netrunner-exe avatar May 20 '22 11:05 netrunner-exe