huggingface / huggingface/diffusers
Questions Regarding the style_fidelity Parameter
- Lenguaje dominante
- Python
- Estrellas
- 34.5k
- Forks
- 7.3k
- Merge medio
- 3 d 3 h
- PR fusionados (30 d)
- 91
Descripción
### 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?
Guía de contribución
Línea de trabajo
Comienza con examples/community/stable_diffusion_reference.py e inspecciona el bloque style_fidelity, especialmente la asignación de uc_mask y la combinación final de hidden_states. Traza los valores resultantes para style_fidelity=0.0 y 1.0 según el comentario correspondiente. Se considera terminado cuando el comportamiento previsto de Control-versus-Prompt esté establecido y cualquier discrepancia se haya resuelto claramente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python, pytorch
- Área
- machine-learning
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 32/100