typefile
{
"min_score": 0.1,
"path": "https://replicate.delivery/mgxm/481bd24e-db4a-4aaa-9962-e45edba2e1f9/IMG_0122.JPG"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_B96**********************************
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 bencevans/megadetector-v4.1 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"bencevans/megadetector-v4.1:c489a092915d846110c9c7eb690b3a36e70e154aadf63b6fa3d81de99f60a18f",
{
input: {
min_score: 0.1,
path: "https://replicate.delivery/mgxm/481bd24e-db4a-4aaa-9962-e45edba2e1f9/IMG_0122.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_B96**********************************
This is your API token. Keep it to yourself.
import replicate
Run bencevans/megadetector-v4.1 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"bencevans/megadetector-v4.1:c489a092915d846110c9c7eb690b3a36e70e154aadf63b6fa3d81de99f60a18f",
input={
"min_score": 0.1,
"path": "https://replicate.delivery/mgxm/481bd24e-db4a-4aaa-9962-e45edba2e1f9/IMG_0122.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_B96**********************************
This is your API token. Keep it to yourself.
Run bencevans/megadetector-v4.1 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": "bencevans/megadetector-v4.1:c489a092915d846110c9c7eb690b3a36e70e154aadf63b6fa3d81de99f60a18f",
"input": {
"min_score": 0.1,
"path": "https://replicate.delivery/mgxm/481bd24e-db4a-4aaa-9962-e45edba2e1f9/IMG_0122.JPG"
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "wius5uizcrfupombuopfa7o7sa",
"model": "bencevans/megadetector-v4.1",
"version": "c489a092915d846110c9c7eb690b3a36e70e154aadf63b6fa3d81de99f60a18f",
"input": {
"min_score": 0.1,
"path": "https://replicate.delivery/mgxm/481bd24e-db4a-4aaa-9962-e45edba2e1f9/IMG_0122.JPG"
},
"logs": "",
"output": "https://replicate.delivery/mgxm/5991a612-f0f3-43b4-ab27-79735d3dd3cc/output.jpg",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2022-05-10T16:30:28.358265Z",
"started_at": "2022-05-10T16:30:28.574561Z",
"completed_at": "2022-05-10T16:30:33.212499Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/wius5uizcrfupombuopfa7o7sa/cancel",
"get": "https://api.replicate.com/v1/predictions/wius5uizcrfupombuopfa7o7sa"
},
"metrics": {
"predict_time": 4.637938,
"total_time": 4.854234
}
}