typefile
{
"caption": "A woman is working on her computer at the desk",
"image": "https://replicate.delivery/mgxm/35b42a21-a482-4b8b-b248-e19b2c084b31/image0.jpg"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_ePd**********************************
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 salesforce/albef using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"salesforce/albef:9bb3d447bc362a395964917daaadd34a64f0579d75ed4cd33963151e8b6c6d9a",
{
input: {
caption: "A woman is working on her computer at the desk",
image: "https://replicate.delivery/mgxm/35b42a21-a482-4b8b-b248-e19b2c084b31/image0.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_ePd**********************************
This is your API token. Keep it to yourself.
import replicate
Run salesforce/albef using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"salesforce/albef:9bb3d447bc362a395964917daaadd34a64f0579d75ed4cd33963151e8b6c6d9a",
input={
"caption": "A woman is working on her computer at the desk",
"image": "https://replicate.delivery/mgxm/35b42a21-a482-4b8b-b248-e19b2c084b31/image0.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_ePd**********************************
This is your API token. Keep it to yourself.
Run salesforce/albef 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": "salesforce/albef:9bb3d447bc362a395964917daaadd34a64f0579d75ed4cd33963151e8b6c6d9a",
"input": {
"caption": "A woman is working on her computer at the desk",
"image": "https://replicate.delivery/mgxm/35b42a21-a482-4b8b-b248-e19b2c084b31/image0.jpg"
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "okvjtihw4raipfkdtox7jsdabi",
"model": "salesforce/albef",
"version": "9bb3d447bc362a395964917daaadd34a64f0579d75ed4cd33963151e8b6c6d9a",
"input": {
"caption": "A woman is working on her computer at the desk",
"image": "https://replicate.delivery/mgxm/35b42a21-a482-4b8b-b248-e19b2c084b31/image0.jpg"
},
"logs": "Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).\nClipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).\nClipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).\nClipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).\nClipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).",
"output": "https://replicate.delivery/mgxm/689cc579-5421-4737-96cb-8291d9d71a75/output.png",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2022-03-01T23:48:34.126843Z",
"started_at": "2022-03-01T23:49:39.257798Z",
"completed_at": "2022-03-01T23:49:47.939596Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/okvjtihw4raipfkdtox7jsdabi/cancel",
"get": "https://api.replicate.com/v1/predictions/okvjtihw4raipfkdtox7jsdabi"
},
"metrics": {
"predict_time": 8.681798,
"total_time": 73.812753
}
}
