pytorch/examples

Neural Style fails if style image has an alpha channel

開放

#738 建立於 2020年3月20日

 (0 則留言) (0 個反應) (0 位負責人)Python (9,429 個分叉)batch import
help wanted

倉庫指標

星標
 (21,634 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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.

貢獻者指南