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.
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".
This exercise is part of the course
Multi-Modal Models with Hugging Face
Exercise instructions
- 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 thediffusers
library. - Sort the results according to the number of
"likes"
. - Load the most popular model using its ID.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
models = api.list_models(
# Use only models that are for text-to-image tasks.
____=____,
author="CompVis",
# Use an appropriate tag to ensure the model can be loaded by the Diffusers library
____="____",
# Sort according to the most popular
____="____"
)
models = list(models)
# Load the most popular model
pipe = StableDiffusionPipeline.from_pretrained(models[0].____)