LoslegenKostenlos loslegen

Finding the most popular text-to-image model

Time to refine your search to find and load the most popular text-to-image Stable Diffusion model from CompVis on the Hugging Face Hub.

Photo of a labrador chasing a ball

The Hugging Face Hub API has been loaded (api), as has the StableDiffusionPipeline module from the diffusers library. With Stable Diffusion models you can generate an image from any prompt you like, e.g., "a black labrador chasing a tennis ball".

Diese Übung ist Teil des Kurses

Multi-Modal Models with Hugging Face

Kurs anzeigen

Anleitung zur Übung

  • Use only models that are for text-to-image tasks.
  • Use an appropriate tag to ensure the model can be loaded by the StableDiffusionPipeline class from the diffusers library.
  • Sort the results according to the number of "likes".
  • Load the most popular model from models using its ID.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

models = api.list_models(
    # Filter for text-to-image tasks
    task="____",
    author="CompVis",
    # Filter for models that can be loaded by the diffusers library
    tags="diffusers:____",
    # Sort according to the most popular
    sort="____"
)

models = list(models)

# Load the most popular model from models
pipe = StableDiffusionPipeline.from_pretrained(models[0].____)
Code bearbeiten und ausführen