replicate部署.md 1.1 KB

github托管项目

训练模型

调用api



npm install replicate

export REPLICATE_API_TOKEN=<paste-your-token-here>


import Replicate from "replicate";

const replicate = new Replicate({
  auth: process.env.REPLICATE_API_TOKEN,
});

const model = "stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf";
const input = { prompt: "an astronaut riding a horse on mars, hd, dramatic lighting, detailed" };
const output = await replicate.run(model, { input });

console.log(output);



node index.js

pip install replicate

export REPLICATE_API_TOKEN=<paste-your-token-here>


import replicate
replicate.run(
  "stability-ai/stable-diffusion:27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478",
  input={"prompt": "a 19th century portrait of a wombat gentleman"}
)



image = open("mystery.jpg", "rb")
# or...
image = "https://example.com/mystery.jpg"

replicate.run(
  "replicate/resnet:dd782a3d531b61af491d1026434392e8afb40bfb53b8af35f727e80661489767",
  input={"image": image}
)


Vercel 部署前端 WebUI