stability-ai / stable-diffusion

Store, manage, and search images from the text-to-image diffusion model.

First we'll install the HuggingFace Diffusers and Mixpeek libraries.

pip install diffusers transformers accelerate scipy safetensors mixpeek

Next we generate the image using Stable Diffusion

from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler

model_id = "stabilityai/stable-diffusion-2-1"

pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe ="cuda")

image = pipe("a photo of an astronaut riding a horse on mars").images[0]"astronaut_rides_horse.png")

Then we store the file in Mixpeek's AI-storage alongside the prompt and some tags:

from mixpeek import Mixpeek

mix = Mixpeek("YOUR_API_KEY")

# store the stable diffusion output in your own mixpeek cloud store
  description="a photo of an astronaut riding a horse on mars",
  tags="stable-diffusion, space, animal, scifi",

Now that this image (and any others) are stored in our Mixpeek cloud storage, we can search across everything:"space horse")

    "file_id": "63a86c1bf1fc46279ef7614d",
    "filename": "astronaut_rides_horse.png",
    "importance": "95%"
    "file_id": "63a86c21f1fc46279ef7614e",
    "filename": "cowboy_on_mars.png",
    "importance": "72%"

What will you build?

Upgrade your software with an intelligent file store in two lines of code.

Get Started Free