huggingface / huggingface/diffusers
Questions Regarding the style_fidelity Parameter
- Lingua principale
- Python
- Stelle
- 34.5k
- Fork
- 7.3k
- Merge medio
- 3g 3h
- PR unite (30g)
- 91
Descrizione
### Discussed in https://github.com/huggingface/diffusers/discussions/10353
Originally posted by **ShowLo** December 23, 2024
In [stable_diffusion_reference.py](https://github.com/huggingface/diffusers/blob/main/examples/community/stable_diffusion_reference.py), there is the following code:
```
var, mean = torch.var_mean(hidden_states, dim=(2, 3), keepdim=True, correction=0)
std = torch.maximum(var, torch.zeros_like(var) + eps) ** 0.5
mean_acc = sum(self.mean_bank[i]) / float(len(self.mean_bank[i]))
var_acc = sum(self.var_bank[i]) / float(len(self.var_bank[i]))
std_acc = torch.maximum(var_acc, torch.zeros_like(var_acc) + eps) ** 0.5
hidden_states_uc = (((hidden_states - mean) / std) * std_acc) + mean_acc
hidden_states_c = hidden_states_uc.clone()
if do_classifier_free_guidance and style_fidelity > 0:
hidden_states_c[uc_mask] = hidden_states[uc_mask]
hidden_states = style_fidelity * hidden_states_c + (1.0 - style_fidelity) * hidden_states_uc
```
And there is a comment:
```
style fidelity of ref_uncond_xt. If style_fidelity=1.0, control more important,
elif style_fidelity=0.0, prompt more important, else balanced.
```
However, when style_fidelity=1.0, hidden_states is set to hidden_states_c. Because of the presence of uc_mask, half of hidden_states_c is unrelated to the reference image. In this case, isn’t the prompt more important? Conversely, when style_fidelity=0.0, hidden_states is set to hidden_states_uc, where both the first and second halves of hidden_states_uc are influenced by the reference image. In this scenario, isn’t the control from the reference image more important?
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da examples/community/stable_diffusion_reference.py ed esamina il blocco style_fidelity, in particolare l’assegnazione di uc_mask e la combinazione finale di hidden_states. Traccia i valori risultanti per style_fidelity=0.0 e 1.0 confrontandoli con il commento associato. Il lavoro è completo quando il comportamento previsto Control-versus-Prompt è stabilito e qualsiasi discrepanza è stata risolta chiaramente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, pytorch
- Ambito
- machine-learning
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 32/100