💡 [REQUEST] - Neural Style Transfer: change layers to compute style/content

Aperta
#3,732 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
55/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Inizia con il tutorial collegato su Neural Style Transfer e con le relative definizioni dei layer di profondità desiderati. Confronta i nomi continui dei layer del tutorial con i layer VGG raggruppati dell’articolo, quindi verifica che le selezioni documentate dei layer di stile e contenuto corrispondano all’articolo citato e producano il comportamento previsto del tutorial.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

core
🚀 Describe the improvement or the new tutorial

I tried using code from Neural Style Transfer tutorial to apply a van Gogh style to my photo, and results were way poorer copared to what I've seen on DeepArt.io.

Luckily, I found what's the issue, and how to improve quality.

Original paper states:

Thus, the visually
most appealing images are usually created by matching the
style representation up to high layers in the network, which
is why for all images shown we match the style features
in layers ‘conv1_1’, ‘conv2_1’, ‘conv3_1’, ‘conv4_1’ and
‘conv5_1’ of the network.

and also:

The images shown in Fig 3
were synthesised by matching the content representation
on layer ‘conv4_2’ and the style representation on layers
‘conv1_1’, ‘conv2_1’, ‘conv3_1’, ‘conv4_1’ and ‘conv5_1’

In the tutorial, layer conv_4 is used for content and layers from conv_1 to conv_5 for style.:

# desired depth layers to compute style/content losses :
content_layers_default = ['conv_4']
style_layers_default = ['conv_1', 'conv_2', 'conv_3', 'conv_4', 'conv_5']

At first glance everything looks fine, but indexing patterns are different: in the article (and original VGG model) layers were split into groups between poolings, and in the tutorial a continuous numbering is used.

Article Tutorial
conv1_1 conv_1
conv1_2 conv_2
--- ---
conv2_1 conv_3
conv2_2 conv_4
--- ---
conv3_1 conv_5
conv3_2 conv_6
conv3_3 conv_7
conv3_4 conv_8
--- ---
conv4_1 conv_9
conv4_2 conv_10
conv4_3 conv_11
conv4_4 conv_12
--- ---
conv5_1 conv_13
conv5_2 conv_14
conv5_3 conv_15
conv5_4 conv_16

So layers conv_1, conv_3, conv_5, conv_9 and conv_13 should be used for style and layer conv_10 for content.

That produces way better results.

Suggested change
# desired depth layers to compute style/content losses :
content_layers_default = ['conv_10']
style_layers_default = ['conv_1', 'conv_3', 'conv_5', 'conv_9', 'conv_13']
Existing tutorials on this topic

https://docs.pytorch.org/tutorials/advanced/neural_style_tutorial.html

Additional context

Another suggestion to improve quality: #3731

cc @albanD @jbschlosser

Lingua principale
Python
Stelle
9.5k
Fork
4.5k
Merge medio
1g 20h
PR unite (30g)
2

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pytorch/tutorials

Tutte le issue di pytorch/tutorials

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.