huggingface / huggingface/diffusers
Make the sampling loop of pipelines modular, with designated inputs that can be handled iteratively with functions and a default sampler step function
- Langage dominant
- Python
- Étoiles
- 34.5k
- Forks
- 7.3k
- Merge moyen
- 3 j 3 h
- PR mergées (30 j)
- 91
Description
### Model/Pipeline/Scheduler description
Related to #7761 .
This is an effective replacement for the existing sampling loop function and the many, many kwargs that were made to allow the user to control it or inject callbacks into it.
```py
class SamplingInput:
def __init__(self, img, text_embedding, unet, timestep=None, **kwargs):
self.img = img
self.text_embedding = text_embedding
self.unet = unet
self.timestep = timestep
# ... lots of other code ...
inp = SamplingInput(img, text_embedding, unet)
with self.progress_bar(total=num_inference_steps) as progress_bar:
for i, t in enumerate(timesteps):
inp.timestep = t
for sampling_function in self.sampling_functions:
inp = sampling_function(inp)
output_img = inp.img
```
This will give the end user complete control of the sampling loop, allow the repo to add "official inline sampling functions" like report an image to an endpoint so that the user can view intermediate steps, etc.
We can add an argument sampling_functions: `list[Callable]=[default_sampling_function]` into the `__call__` as a new, backwards compatible kwarg.
This requires a rewrite of all of the pipelines, but as it is a backwards compatible change it can be introduced to any of the more popular pipelines first.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Examinez la boucle de sampling existante dans les pipelines et leurs points d’entrée __call__, puis comparez la manière dont sont gérés les kwargs et callbacks liés au sampling. Définissez les interfaces SamplingInput, sampling_functions et default_sampling_function conformément à l’exemple proposé. La tâche est terminée lorsque la boucle modulaire est introduite de manière compatible et que les pipelines populaires concernées sont mises à jour sans modifier le comportement existant.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- machine-learning
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100