Open Kareem-94 opened 7 years ago
Thanks for your interest. These lines to be changed: https://github.com/pathak22/context-encoder/blob/master/train.lua#L282-L285 https://github.com/pathak22/context-encoder/blob/master/train.lua#L418-L431
https://github.com/pathak22/context-encoder/blob/master/test.lua#L78-L85 https://github.com/pathak22/context-encoder/blob/master/test.lua#L98
Great! I figured it out already! However i didn't get the syntax! How can I edit the mask position? Is there a place for X and Y shift and scale?
My main concern is to divide the picture into 9 squares (3 x 3) and put a mask on only one square of them each time then get the context encoder to inpaint the masked area!
I tried to edit the lines you told me about however i couldnt get the mask positioned where i want! Let me know dor example how to put the mask at the top left of the pic and i'll figure out everything else! Thanks
I believe this is more a lua question than related to context encoders. There is this random region inpainting code here: https://github.com/pathak22/context-encoder/blob/master/train_random.lua
You can take help from it, and modify accordingly. Let me know if I misunderstood your question.
Thanks for quick reply :D
I think you didn't get my point ... i want to change the mask location. I don't want it a the center. My concern is to put a square mask on a desired position on the picture however i can't do it by just changing the lines you told me about! I need to understand your algorithm to generate the mask.
Your help is really appreciated
Sorry, I mean to position the mask not to generate it!
i have the same question as kareem-94 i tried train_random.lua but didn't give me the required as i want to be able to shift the square mask all around the image. i.e to make the square mask shifted up/down/left/right i know that for each mask position i will have to train the network but my problem concerning the code real_ctx[{{},{1},{},{}}][mask_global] = 2117.0/255.0 - 1.0 real_ctx[{{},{2},{},{}}][mask_global] = 2104.0/255.0 - 1.0 real_ctx[{{},{3},{},{}}][mask_global] = 2*123.0/255.0 - 1.0 as train_random makes random mask(not square) position i want to be able to train the network for images had the mask on top left of it can u help?
Is there a way to provide images with masked regions ? Meaning images where some part is already masked white and this region is then inpainted ? Or does the masked region need to be always generated in the code ?
the masked region is generated by the code
Yes I know but is there is no way to input images with already masked regions ?
the code must work on the whole image and it generates a mask at the center so wt i want to do is to be able to make the square mask to go all around the image so that i m waiting for @pathak22 to help with that issue @pathak22 u did a wonderful job with yr code
Okay @NerminSalem I think it's better if I make another issue out of my concern
kindly @cryptedp if u found a way to move the mask all around the image, let me know
@Nermin do you want to reposition your mask, so that it is not in the center ?
yes, i want to be able to move the mask for example to be on the top left of the image or down bottom left and so on u know it s like i m assuming that the image is divided into 9 (3*3)squares and i want to be able to move the mask all over these squares
Do you mean something like that ?
yes exactly but i need the results to be good too
@cryptedp heyyyy!! How did u do that 😂😂
Yes that was just shifting the center but still using the inpaintcenter model in the demo code. But for shifting you can change the coordinates of
local real_center = real_ctx[{{},{},{1 + opt.fineSize/4, opt.fineSize/2 + opt.fineSize/4},{1 + opt.fineSize/4, opt.fineSize/2 + opt.fineSize/4}}]:clone()
and
real_ctx[{{},{1},{1 + opt.fineSize/4 + opt.overlapPred, opt.fineSize/2 + opt.fineSize/4 - opt.overlapPred},{1 + opt.fineSize/4 + opt.overlapPred, opt.fineSize/2 + opt.fineSize/4 - opt.overlapPred}}] = 2*117.0/255.0 - 1.0
to whereever you want to position the square box (in train.lua). But I am not sure how to change the model to change the results though. Maybe you can add these coordinates in train_random.lua and train them ...
@Kareem-94 I changed the coordinates of
real_center = image_ctx[{{},{},{1 + inputSize/4, inputSize/2 + inputSize/4},{1 + inputSize/4, inputSize/2 + inputSize/4}}]:clone()
to real_center = image_ctx[{{},{},{1 , inputSize/2 },{1 , inputSize/2 }}]:clone()
in demo.lua.
Futhermore I changed
image_ctx[{{},{1},{1 + inputSize/4 + opt.overlapPred, inputSize/2 + inputSize/4 - opt.overlapPred},{1 + inputSize/4 + opt.overlapPred, inputSize/2 + inputSize/4 - opt.overlapPred}}] = 2*117.0/255.0 - 1.0 image_ctx[{{},{2},{1 + inputSize/4 + opt.overlapPred, inputSize/2 + inputSize/4 - opt.overlapPred},{1 + inputSize/4 + opt.overlapPred, inputSize/2 + inputSize/4 - opt.overlapPred}}] = 2*104.0/255.0 - 1.0 image_ctx[{{},{3},{1 + inputSize/4 + opt.overlapPred, inputSize/2 + inputSize/4 - opt.overlapPred},{1 + inputSize/4 + opt.overlapPred, inputSize/2 + inputSize/4 - opt.overlapPred}}] = 2*123.0/255.0 - 1.0
to
image_ctx[{{},{1},{1 + opt.overlapPred, inputSize/2 - opt.overlapPred},{1 + opt.overlapPred, inputSize/2 - opt.overlapPred}}] = 2*117.0/255.0 - 1.0 image_ctx[{{},{2},{1 + opt.overlapPred, inputSize/2 - opt.overlapPred},{1 + opt.overlapPred, inputSize/2 - opt.overlapPred}}] = 2*104.0/255.0 - 1.0 image_ctx[{{},{3},{1 + opt.overlapPred, inputSize/2 - opt.overlapPred},{1 + opt.overlapPred, inputSize/2 - opt.overlapPred}}] = 2*123.0/255.0 - 1.0
@cryptedp thanks alot for sharing yr code
@cryptedp I'll try to train the model again from scratch at the new mask location and see the results! Thanks very much for the code! Really appreciated.
Did you find the solution to your question mentioned below ? If yes,then kindly let me know too :) @cryptedp
"Is there a way to provide images with masked regions ? Meaning images where some part is already masked white and this region is then inpainted ?"
@Kareem-94 , @pathak22 , how to fulfill the corresponding python slice or pytorch slice in terms of the torch slice " real_ctx[{{},{3},{},{}}][mask_global] = 2*123.0/255.0 - 1.0" ?
hiii, i m so interested in yr work, i want to be able to make the mask at the top left of the image and be able to in-paint that region successfully, what has to be changed in the training and test code to achieve this thanks