Can I train using .png images?
Zebraslive opened this issue · 0 comments
Zebraslive commented
I wrote a nodejs script to process and resize my images. It removes the background perfectly and saves as png. When I use the image with an existing model trained on .jpg I get an image shape error. it's 4, 512, 256 when it should be 3, 512, 256.
is it even possible to train using .png that have transparency?
This is how I'm cropping and masking images. I start with .jpg and apply mask then save to .png Then resizing to correct dimensions for the model used.
await sharp('adobe_masks/mask_' + saveiumaskfile)
.extractChannel('red')
.toBuffer()
.then((maskBuffer) => {
sharp(imagetomask)
.ensureAlpha()
.joinChannel(maskBuffer)
.png({ palette: true })
.toFile('adobe_bgr/' + saveiumaskfile.replace('.jpg', '') + '_done.png');
});
await sleep(1650);
await sharp('adobe_bgr/' + saveiumaskfile.replace('.jpg', '') + '_done.png').resize(256, 512, { fit: sharp.fit.cover, position: sharp.strategy.attention }).png({ quality: 100 }).toFile('imgs/' + dirent.name.replace('.jpg', '.png'));
Can anyone please clarify the issue here?