-
Notifications
You must be signed in to change notification settings - Fork 624
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
Help..I have a try of pytorch and meet pixel problem #20
Comments
For the purpose that more people can read it, I will still reply using English but you can contact me by email if you still have troubles in reproducing it in PyTorch...😄 Firstly, the VGG-19 requires input image to be [0, 255] and then... Secondly, did you subtract the mean pixel? One easier way to debug might be starting from a PyTorch version of style transfer implementation such as this one from original author Leon Gatys: https://github.com/leongatys/PytorchNeuralStyleTransfer |
Wow, so fast..
And I also do the normalization to the image.
But the problem still exists. So I'm trying to figure out ... |
I think VGG-19 requires input to be [0, 255] subtracted by mean pixel? |
thanks! I had sent you a gmail the day before yesterday and I don't know if you have received it. The model I use is from Pytorch and the VGG-19 model requires input to be [0-1]...I think the model I use is right because it works in common style transfer. I compared two ways to load the image: PIL vs OpenCV-python, and I found something weird but I'm still not sure where the problem comes from. I'm confused about the code below from 'neural_gram.lua': if name == style_layers[next_style_idx] then
print("Setting up style layer ", i, ":", layer.name)
local gram = GramMatrix():float():cuda()
local input = net:forward(content_image_caffe):clone()
local target = net:forward(style_image_caffe):clone()
local mask = mask_image:clone():repeatTensor(1,1,1):expandAs(target):cuda()
# if I don't use histogram match and just input target to gram-loss function
# like this : target_gram = gram:forward(target):clone()
local match, correspondence =
cuda_utils.patchmatch_r(input, target, params.patchmatch_size, 1)
match:cmul(mask)
local target_gram = gram:forward(match):clone()
target_gram:div(mask:sum())
local norm = params.normalize_gradients
local loss_module = nn.StyleLoss(params.style_weight, target_gram, norm, mask_image):float():cuda()
net:add(loss_module)
table.insert(style_losses, loss_module)
next_style_idx = next_style_idx + 1
end I haven't use histogram and just input activation layer from style-image to gram-loss function. |
If only style loss but no histogram loss the quality will be less good but not like the one you posted. There might still have some bug so I would first ensure entire image style transfer works and then debug masked region using unit tests. |
Yeah...The entire image style transfer works. |
After a long parameters tuning the first step is almost working. |
It's a nice work and I want to use pytorch to re-accomplish it.
But during the first step 'IndependentMapping' I meet a pixel mess problem...
I do clamp and use mask image to do backward but the pixels seem to be out of range.
The loss function I use are content loss,gram loss, and TV loss. I haven't use histogram loss.
The model I use is Vgg19 from pytorch model zoo which the data range is 0-1.I'm sure the image I put into is right format(RGB) and when I tune the style weight or content the result changes a bit. I have no clear idea where the problem is.
Can you help me?Thanks!
貌似我该说中文?
The text was updated successfully, but these errors were encountered: