typefile
{
"image": "https://replicate.delivery/pbxt/LLcFnHRq5MfjLpWbnLXZEtZIVn1io5sKf2lDnfQrh6tmcFK9/dog.jpg"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_9R7**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
import fs from "node:fs";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run men1scus/birefnet using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"men1scus/birefnet:f74986db0355b58403ed20963af156525e2891ea3c2d499bfbfb2a28cd87c5d7",
{
input: {
image: "https://replicate.delivery/pbxt/LLcFnHRq5MfjLpWbnLXZEtZIVn1io5sKf2lDnfQrh6tmcFK9/dog.jpg"
}
}
);
// To access the file URL:
console.log(output.url()); //=> "http://example.com"
// To write the file to disk:
fs.writeFile("my-image.png", output);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_9R7**********************************
This is your API token. Keep it to yourself.
import replicate
Run men1scus/birefnet using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"men1scus/birefnet:f74986db0355b58403ed20963af156525e2891ea3c2d499bfbfb2a28cd87c5d7",
input={
"image": "https://replicate.delivery/pbxt/LLcFnHRq5MfjLpWbnLXZEtZIVn1io5sKf2lDnfQrh6tmcFK9/dog.jpg"
}
)
# To access the file URL:
print(output.url())
#=> "http://example.com"
# To write the file to disk:
with open("my-image.png", "wb") as file:
file.write(output.read())
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_9R7**********************************
This is your API token. Keep it to yourself.
Run men1scus/birefnet using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: wait" \
-d $'{
"version": "men1scus/birefnet:f74986db0355b58403ed20963af156525e2891ea3c2d499bfbfb2a28cd87c5d7",
"input": {
"image": "https://replicate.delivery/pbxt/LLcFnHRq5MfjLpWbnLXZEtZIVn1io5sKf2lDnfQrh6tmcFK9/dog.jpg"
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "2jhrjx6e95rj20cgz859sygkt4",
"model": "men1scus/birefnet",
"version": "f74986db0355b58403ed20963af156525e2891ea3c2d499bfbfb2a28cd87c5d7",
"input": {
"image": "https://replicate.delivery/pbxt/LLcFnHRq5MfjLpWbnLXZEtZIVn1io5sKf2lDnfQrh6tmcFK9/dog.jpg"
},
"logs": "",
"output": "https://replicate.delivery/yhqm/s1n7BgKLTc6YOpVCodkV6w943fUKOCo7eqI4Nbm4wJuvtBNTA/output.png",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-07-28T15:52:10.569Z",
"started_at": "2024-07-28T15:53:08.188331Z",
"completed_at": "2024-07-28T15:53:19.733737Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/2jhrjx6e95rj20cgz859sygkt4/cancel",
"get": "https://api.replicate.com/v1/predictions/2jhrjx6e95rj20cgz859sygkt4",
"web": "https://replicate.com/p/2jhrjx6e95rj20cgz859sygkt4"
},
"metrics": {
"predict_time": 11.545406328,
"total_time": 69.164737
}
}
