Skip to content

Replicate API Added!#47

Open
zsxkib wants to merge 1 commit intobytedance:mainfrom
zsxkib:Replicate
Open

Replicate API Added!#47
zsxkib wants to merge 1 commit intobytedance:mainfrom
zsxkib:Replicate

Conversation

@zsxkib
Copy link

@zsxkib zsxkib commented May 16, 2025

Hey @ToTheBeginning & @cabelo 👋

DreamO is a really cool model for customizing images, especially with its different ways to work with faces, objects, and styles.

So people can try DreamO and use it in their own projects, I've set it up to run on Replicate:

Demo & API: https://replicate.com/zsxkib/dream-o

I also posted about it on X/Twitter here: https://x.com/zsakib_/status/1923337566247322039

What's new in this PR:

This PR adds the files and settings needed to run the DreamO model on Replicate:

  • predict.py: This script loads the DreamO model and lets you run it using Cog. It handles the different creative tasks and prepares your input images.
  • cog.yaml: This file tells Replicate about the Python environment, system packages, and GPU needed for DreamO.
  • .dockerignore: This helps make the Docker build faster by telling it to skip files that aren't needed.
  • .gitignore: This makes sure Replicate and Cog files (like .cog/ and /model_cache/) don't get accidentally added to the main project.
  • README.md: I've updated this to include a Replicate badge that links to the demo page, plus a section explaining how to use DreamO with Replicate or run it locally with Cog.

With this setup, you get:

  • A web page where you can try out DreamO without installing anything locally.
  • An API so developers can use DreamO to generate images from their own code.
  • The ability to run the model on your own computer using cog predict, and it will download the necessary weights for you.

How to use it with Replicate's API:

First, install the Python client:

pip install replicate

Then, set your API token (you can find this in your Replicate account settings):

export REPLICATE_API_TOKEN=[YOUR_REPLICATE_API_TOKEN]

Now you can run the model in Python like this:

import replicate

output = replicate.run(
    "zsxkib/dream-o:8f8d84ebe012e94a126b21c953b8dc33be86e4cf92b133b144bda94aa84e616b",
    input={
        "seed": 7698454872441022000,
        "width": 1024,
        "height": 1024,
        "prompt": "the woman wearing a dress, In the banquet hall",
        "ref_res": 512,
        "guidance": 3.5,
        "true_cfg": 1,
        "num_steps": 12,
        "ref_task1": "id",
        "ref_task2": "ip",
        "neg_prompt": "",
        "ref_image1": "https://replicate.delivery/pbxt/MzZo0OcsWW6NBl10nsCZoIRcRP9aGSczwDwVSLW5QRn8zD42/0_1.webp",
        "ref_image2": "https://raw.githubusercontent.com/bytedance/DreamO/main/example_inputs/dress.png",
        "cfg_end_step": 0,
        "neg_guidance": 3.5,
        "output_format": "webp",
        "cfg_start_step": 0,
        "output_quality": 90,
        "first_step_guidance": 0
    }
)
print(output)
# This will print a URL to the generated .webp file

How to run it locally with Cog:

After you've cloned the repository and opened it in your terminal (cd into the directory):

cog predict \
  -i 'seed=7698454872441022000' \
  -i 'width=1024' \
  -i 'height=1024' \
  -i 'prompt="the woman wearing a dress, In the banquet hall"' \
  -i 'ref_res=512' \
  -i 'guidance=3.5' \
  -i 'true_cfg=1' \
  -i 'num_steps=12' \
  -i 'ref_task1="id"' \
  -i 'ref_task2="ip"' \
  -i 'neg_prompt=""' \
  -i 'ref_image1="https://replicate.delivery/pbxt/MzZo0OcsWW6NBl10nsCZoIRcRP9aGSczwDwVSLW5QRn8zD42/0_1.webp"' \
  -i 'ref_image2="https://raw.githubusercontent.com/bytedance/DreamO/main/example_inputs/dress.png"' \
  -i 'cfg_end_step=0' \
  -i 'neg_guidance=3.5' \
  -i 'output_format="webp"' \
  -i 'cfg_start_step=0' \
  -i 'output_quality=90' \
  -i 'first_step_guidance=0'

The weights and other needed files will download automatically the first time you run it.

On Replicate, people using the model pay for their own computer time, which helps keep things available for everyone, even if a model gets popular.

Let me know if you have any questions or ideas for making this better. I'm happy to change things.

Thanks for making DreamO open source!

-- Sakib @ Replicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments