Skip to content

Commit

Permalink
Add more Replicate models (take 2) (#1130)
Browse files Browse the repository at this point in the history
This PR adds mappings for more Replicate models, along with tests for
each new model.

```
vitest run --config vitest.config.mts -t "Replicate"

...

✓ Replicate (9) 8666ms
  ✓ textToImage canonical - black-forest-labs/FLUX.1-schnell 1214ms
  ✓ textToImage canonical - black-forest-labs/FLUX.1-dev 3472ms
  ✓ textToImage canonical - stabilityai/stable-diffusion-3.5-large-turbo 1460ms
  ✓ textToImage versioned - ByteDance/SDXL-Lightning 2612ms
  ✓ textToImage versioned - ByteDance/Hyper-SD 4346ms
  ✓ textToImage versioned - playgroundai/playground-v2.5-1024px-aesthetic 4099ms
  ✓ textToImage versioned - stabilityai/stable-diffusion-xl-base-1.0 7205ms
  ↓ textToSpeech versioned [skipped]
  ↓ textToSpeech OuteTTS [skipped]
```

Replaces #1102

cc @julien-c @SBrandeis

---------

Co-authored-by: SBrandeis <[email protected]>
Co-authored-by: Simon Brandeis <[email protected]>
  • Loading branch information
3 people authored Jan 27, 2025
1 parent 284b28e commit bd1fa9e
Show file tree
Hide file tree
Showing 3 changed files with 377 additions and 3 deletions.
10 changes: 10 additions & 0 deletions packages/inference/src/providers/replicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@ type ReplicateId = string;

export const REPLICATE_SUPPORTED_MODEL_IDS: ProviderMapping<ReplicateId> = {
"text-to-image": {
"black-forest-labs/FLUX.1-dev": "black-forest-labs/flux-dev",
"black-forest-labs/FLUX.1-schnell": "black-forest-labs/flux-schnell",
"ByteDance/Hyper-SD":
"bytedance/hyper-flux-16step:382cf8959fb0f0d665b26e7e80b8d6dc3faaef1510f14ce017e8c732bb3d1eb7",
"ByteDance/SDXL-Lightning":
"bytedance/sdxl-lightning-4step:5599ed30703defd1d160a25a63321b4dec97101d98b4674bcc56e41f62f35637",
"playgroundai/playground-v2.5-1024px-aesthetic":
"playgroundai/playground-v2.5-1024px-aesthetic:a45f82a1382bed5c7aeb861dac7c7d191b0fdf74d8d57c4a0e6ed7d4d0bf7d24",
"stabilityai/stable-diffusion-3.5-large-turbo": "stability-ai/stable-diffusion-3.5-large-turbo",
"stabilityai/stable-diffusion-3.5-large": "stability-ai/stable-diffusion-3.5-large",
"stabilityai/stable-diffusion-3.5-medium": "stability-ai/stable-diffusion-3.5-medium",
"stabilityai/stable-diffusion-xl-base-1.0":
"stability-ai/sdxl:7762fd07cf82c948538e41f63f77d685e02b063e37e496e96eefd46c929f9bdc",
},
"text-to-speech": {
"OuteAI/OuteTTS-0.3-500M": "jbilcke/oute-tts:39a59319327b27327fa3095149c5a746e7f2aee18c75055c3368237a6503cd26",
Expand Down
52 changes: 49 additions & 3 deletions packages/inference/test/HfInference.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ describe.concurrent("HfInference", () => {
() => {
const client = new HfInference(env.HF_REPLICATE_KEY);

it("textToImage canonical", async () => {
it("textToImage canonical - black-forest-labs/FLUX.1-schnell", async () => {
const res = await client.textToImage({
model: "black-forest-labs/FLUX.1-schnell",
provider: "replicate",
Expand All @@ -847,11 +847,57 @@ describe.concurrent("HfInference", () => {
expect(res).toBeInstanceOf(Blob);
});

it("textToImage versioned", async () => {
it("textToImage canonical - black-forest-labs/FLUX.1-dev", async () => {
const res = await client.textToImage({
model: "black-forest-labs/FLUX.1-dev",
provider: "replicate",
inputs:
"A tiny laboratory deep in the Black Forest where squirrels in lab coats experiment with mixing chocolate and pine cones",
});
expect(res).toBeInstanceOf(Blob);
});

it("textToImage canonical - stabilityai/stable-diffusion-3.5-large-turbo", async () => {
const res = await client.textToImage({
model: "stabilityai/stable-diffusion-3.5-large-turbo",
provider: "replicate",
inputs: "A confused rubber duck wearing a tiny wizard hat trying to cast spells with a banana wand",
});
expect(res).toBeInstanceOf(Blob);
});

it("textToImage versioned - ByteDance/SDXL-Lightning", async () => {
const res = await client.textToImage({
model: "ByteDance/SDXL-Lightning",
provider: "replicate",
inputs: "black forest gateau cake spelling out the words FLUX SCHNELL, tasty, food photography, dynamic shot",
inputs: "A grumpy storm cloud wearing sunglasses and throwing tiny lightning bolts like confetti",
});
expect(res).toBeInstanceOf(Blob);
});

it("textToImage versioned - ByteDance/Hyper-SD", async () => {
const res = await client.textToImage({
model: "ByteDance/Hyper-SD",
provider: "replicate",
inputs: "A group of dancing bytes wearing tiny party hats doing the macarena in cyberspace",
});
expect(res).toBeInstanceOf(Blob);
});

it("textToImage versioned - playgroundai/playground-v2.5-1024px-aesthetic", async () => {
const res = await client.textToImage({
model: "playgroundai/playground-v2.5-1024px-aesthetic",
provider: "replicate",
inputs: "A playground where slides turn into rainbows and swings launch kids into cotton candy clouds",
});
expect(res).toBeInstanceOf(Blob);
});

it("textToImage versioned - stabilityai/stable-diffusion-xl-base-1.0", async () => {
const res = await client.textToImage({
model: "stabilityai/stable-diffusion-xl-base-1.0",
provider: "replicate",
inputs: "An octopus juggling watermelons underwater while wearing scuba gear",
});
expect(res).toBeInstanceOf(Blob);
});
Expand Down
Loading

0 comments on commit bd1fa9e

Please sign in to comment.