pytorch/examples

Neural Style fails if style image has an alpha channel

Open

#738 aberto em 20 de mar. de 2020

Ver no GitHub
 (0 comments) (0 reactions) (0 assignees)Python (9.429 forks)batch import
help wanted

Métricas do repositório

Stars
 (21.634 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

In fast_neural_style/neural_style/neural_style.py line 55, if the style image has an alpha channel, then the generated tensor has 4 dimensions and this causes utils.normalize_batch to throw due to a tensor dimension mismatch a few lines down.

I've fixed this by appending .convert('RGB') so line 55 now reads

style = utils.load_image(args.style_image, size=args.style_size).convert('RGB')

The ImageFolder data loader does the same transformation, however, maybe a warning should be issued since it is the key file.

Guia do colaborador