Comments (6)
Hi ThJOD,
In fact, the unet can handle images with arbitrary sizes. However, the best practice is that you need to train the model by feeding different sizes of images, otherwise, using a pretrained model you will not get good results. Here is some tips on how to load the images without crop and resizing: change the code https://github.com/Zhaoyi-Yan/Shift-Net_pytorch/blob/master/data/aligned_dataset.py#L33-L64
# delete the random cropping and resizing code above
if (not self.opt.no_flip) and random.random() < 0.5:
idx = [i for i in range(A.size(2) - 1, -1, -1)] # size(2)-1, size(2)-2, ... , 0
idx = torch.LongTensor(idx)
A = A.index_select(2, idx)
# let B directly equals A
B = A.clone()
# Just zero the mask is fine if not offline_loading_mask.
mask = A.clone().zero_()
if self.opt.offline_loading_mask:
mask = Image.open(self.mask_paths[random.randint(0, len(self.mask_paths)-1)])
# mask = mask.resize((self.opt.fineSize, self.opt.fineSize), Image.NEAREST)
mask = transforms.ToTensor()(mask)
from shift-net_pytorch.
Hey,
thank you very much! Inference worked like a charm with the proposed changes. Training had trouble with odd dimensions e.g. Image of size (1028,539,3) so I opted for resizing them to the closest lower power of 2 for now.
Best regards
ThJOD
from shift-net_pytorch.
No need the closest lower power of 2
, you only need to promise that the h
and w
should be odd number, and not less than 256. Then it will work.
from shift-net_pytorch.
Besides, when train your own model, you need to slightly change the code https://github.com/Zhaoyi-Yan/Shift-Net_pytorch/blob/master/models/shift_net/shiftnet_model.py, as it is only for 256256. You'd better generate your own masks for your own dataset as the sizes are not normal 256256. You can offline generate your masks and testing the images with them.
from shift-net_pytorch.
No need the closest lower power of 2, you only need to promise that the h and w should be odd
number, and not less than 256. Then it will work.
Do you mean even number? So they should be divisible by 2? Ok, I will try that out tomorrow!
Besides, when train your own model, you need to slightly change the code https://github.com/Zhaoyi-Yan/Shift-Net_pytorch/blob/master/models/shift_net/shiftnet_model.py, as it is only for 256256. You'd better generate your own masks for your own dataset as the sizes are not normal 256256. You can offline generate your masks and testing the images with them.
I actually already changed that code to train on my own masks before I submitted this issue but yes, that is also necessary
Thanks again!
from shift-net_pytorch.
yes, even number...
from shift-net_pytorch.
Related Issues (20)
- Why are the size of inpainting models so big? HOT 2
- On what image sizes can Face Shift-net work? HOT 2
- Question regarding neighbor searching. HOT 4
- test HOT 8
- Guidance loss HOT 1
- can't find the guidance loss in the code HOT 1
- Guide Loss: how is target passed to InnerCosFunction HOT 3
- Dataset
- About the parameter 'overlap' HOT 2
- about change mask size HOT 1
- Any help on custom dataset? HOT 4
- Discounting Loss
- random mask HOT 5
- the result is blurred HOT 3
- Error in training HOT 9
- test about face
- How to test with my own mask dataset? HOT 1
- the nearest neighbor searching can be computed as a convolutional layer HOT 2
- I have paired images and use one of them as a mask image, how can I modify the code?
- RuntimeError: cannot reshape tensor of 0 elements into shape [1, 0, -1] because the unspecified dimension size -1 can be any value and is ambiguous HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shift-net_pytorch.