typefile
{
"alpha": 0.4,
"api_key": "19333c9a6ec349ec90bd394c9f47ca67",
"image": "https://replicate.delivery/pbxt/LxnTnoWrQ8iu16scY2o4bBuGV5snz3cwzLW4rWjHQV57qaBF/room1.jpg"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_1IO**********************************
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 remodela-ai/scaling-model-v2 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"remodela-ai/scaling-model-v2:4c520357410cd8fc0bfee3b8688e47f215318d0faa717fdcb9fa5ffbe90602e3",
{
input: {
alpha: 0.4,
api_key: "19333c9a6ec349ec90bd394c9f47ca67",
image: "https://replicate.delivery/pbxt/LxnTnoWrQ8iu16scY2o4bBuGV5snz3cwzLW4rWjHQV57qaBF/room1.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_1IO**********************************
This is your API token. Keep it to yourself.
import replicate
Run remodela-ai/scaling-model-v2 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"remodela-ai/scaling-model-v2:4c520357410cd8fc0bfee3b8688e47f215318d0faa717fdcb9fa5ffbe90602e3",
input={
"alpha": 0.4,
"api_key": "19333c9a6ec349ec90bd394c9f47ca67",
"image": "https://replicate.delivery/pbxt/LxnTnoWrQ8iu16scY2o4bBuGV5snz3cwzLW4rWjHQV57qaBF/room1.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_1IO**********************************
This is your API token. Keep it to yourself.
Run remodela-ai/scaling-model-v2 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": "remodela-ai/scaling-model-v2:4c520357410cd8fc0bfee3b8688e47f215318d0faa717fdcb9fa5ffbe90602e3",
"input": {
"alpha": 0.4,
"api_key": "19333c9a6ec349ec90bd394c9f47ca67",
"image": "https://replicate.delivery/pbxt/LxnTnoWrQ8iu16scY2o4bBuGV5snz3cwzLW4rWjHQV57qaBF/room1.jpg"
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
{
"id": "tw7gj5xry1rj60ck4fy8whgs0g",
"model": "remodela-ai/scaling-model-v2",
"version": "4c520357410cd8fc0bfee3b8688e47f215318d0faa717fdcb9fa5ffbe90602e3",
"input": {
"alpha": 0.4,
"api_key": "19333c9a6ec349ec90bd394c9f47ca67",
"image": "https://replicate.delivery/pbxt/LxnTnoWrQ8iu16scY2o4bBuGV5snz3cwzLW4rWjHQV57qaBF/room1.jpg"
},
"logs": "2024-11-13 05:26:25.587 | INFO | predict:predict:82 - The image is already in JPG format. No conversion needed.\n2024-11-13 05:26:25.588 | DEBUG | predict:predict:96 - Image resized and converted to tensor\n2024-11-13 05:26:25.589 | INFO | predict:feed:115 - Starting feed method\n2024-11-13 05:26:25.597 | DEBUG | predict:feed:118 - Model forward pass completed\n2024-11-13 05:26:25.606 | DEBUG | predict:feed:122 - Image labeling completed\n2024-11-13 05:26:25.607 | DEBUG | predict:feed:127 - Image blending completed\n2024-11-13 05:26:25.612 | INFO | predict:feed:133 - Blended image saved to output_image.jpg\n2024-11-13 05:26:25.617 | INFO | predict:feed:140 - Saturation enhanced image saved to output_saturation.jpg\n2024-11-13 05:26:25.617 | INFO | predict:feed:143 - Applying MaskProcessor.filters_colors\n2024-11-13 05:26:25.618 | INFO | predict:feed:147 - Smooth image saved to smooth_output.jpg\n2024-11-13 05:26:25.619 | INFO | predict:feed:150 - Applying SAM model\nimage 1/1 /src/smooth_output.jpg: 1024x1024 1 0, 1 1, 1 2, 1 3, 1 4, 1 5, 1 6, 1109.9ms\nSpeed: 4.0ms preprocess, 1109.9ms inference, 0.3ms postprocess per image at shape (1, 3, 1024, 1024)\n2024-11-13 05:26:26.737 | INFO | predict:feed:152 - Inference masks of image\n2024-11-13 05:26:26.738 | INFO | predict:feed:156 - Processing 1 inference results and applying MaskProcessor\n2024-11-13 05:26:26.738 | DEBUG | predict:feed:158 - Processing result 1\n2024-11-13 05:26:26.739 | INFO | MaskProcessor:plot_separate_and_joined_masks:50 - Plotting separate and joined masks\n2024-11-13 05:26:26.742 | INFO | MaskProcessor:plot_separate_and_joined_masks:60 - Number of masks: 7\n2024-11-13 05:26:26.742 | INFO | MaskProcessor:convert_mask_to_linear_edges:30 - Converting mask to linear edges\n2024-11-13 05:26:26.743 | DEBUG | MaskProcessor:convert_mask_to_linear_edges:40 - Mask converted to linear edges\n2024-11-13 05:26:26.749 | DEBUG | MaskProcessor:plot_separate_and_joined_masks:79 - Processed mask 1\n2024-11-13 05:26:26.750 | INFO | MaskProcessor:convert_mask_to_linear_edges:30 - Converting mask to linear edges\n2024-11-13 05:26:26.750 | DEBUG | MaskProcessor:convert_mask_to_linear_edges:40 - Mask converted to linear edges\n2024-11-13 05:26:26.756 | DEBUG | MaskProcessor:plot_separate_and_joined_masks:79 - Processed mask 2\n2024-11-13 05:26:26.756 | INFO | MaskProcessor:convert_mask_to_linear_edges:30 - Converting mask to linear edges\n2024-11-13 05:26:26.757 | DEBUG | MaskProcessor:convert_mask_to_linear_edges:40 - Mask converted to linear edges\n2024-11-13 05:26:26.762 | DEBUG | MaskProcessor:plot_separate_and_joined_masks:79 - Processed mask 3\n2024-11-13 05:26:26.763 | INFO | MaskProcessor:convert_mask_to_linear_edges:30 - Converting mask to linear edges\n2024-11-13 05:26:26.763 | DEBUG | MaskProcessor:convert_mask_to_linear_edges:40 - Mask converted to linear edges\n2024-11-13 05:26:26.769 | DEBUG | MaskProcessor:plot_separate_and_joined_masks:79 - Processed mask 4\n2024-11-13 05:26:26.770 | INFO | MaskProcessor:convert_mask_to_linear_edges:30 - Converting mask to linear edges\n2024-11-13 05:26:26.770 | DEBUG | MaskProcessor:convert_mask_to_linear_edges:40 - Mask converted to linear edges\n2024-11-13 05:26:26.776 | DEBUG | MaskProcessor:plot_separate_and_joined_masks:79 - Processed mask 5\n2024-11-13 05:26:26.777 | INFO | MaskProcessor:convert_mask_to_linear_edges:30 - Converting mask to linear edges\n2024-11-13 05:26:26.777 | DEBUG | MaskProcessor:convert_mask_to_linear_edges:40 - Mask converted to linear edges\n2024-11-13 05:26:26.784 | DEBUG | MaskProcessor:plot_separate_and_joined_masks:79 - Processed mask 6\n2024-11-13 05:26:26.784 | INFO | MaskProcessor:convert_mask_to_linear_edges:30 - Converting mask to linear edges\n2024-11-13 05:26:26.784 | DEBUG | MaskProcessor:convert_mask_to_linear_edges:40 - Mask converted to linear edges\n2024-11-13 05:26:26.790 | DEBUG | MaskProcessor:plot_separate_and_joined_masks:79 - Processed mask 7\n2024-11-13 05:26:26.797 | INFO | MaskProcessor:save_mask_as_image:44 - Saving mask as image: Joined_Masks_room.png\n2024-11-13 05:26:26.856 | DEBUG | MaskProcessor:save_mask_as_image:47 - Mask saved as Joined_Masks_room.png\n2024-11-13 05:26:26.857 | INFO | MaskProcessor:plot_separate_and_joined_masks:84 - Joined masks plotted successfully\n2024-11-13 05:26:26.857 | INFO | predict:feed:164 - Feed method completed\n2024-11-13 05:26:26.867 | INFO | predict:upload_to_imgbb:19 - Starting the upload process for file: original_pil.jpg\n2024-11-13 05:26:26.867 | DEBUG | predict:upload_to_imgbb:22 - Opened file successfully, sending request to imgBB API.\n2024-11-13 05:26:27.690 | SUCCESS | predict:upload_to_imgbb:34 - Image uploaded successfully to imgBB. URL: https://i.ibb.co/n64DrRQ/original-pil.jpg\nINFO:httpx:HTTP Request: POST https://api.replicate.com/v1/predictions \"HTTP/1.1 201 Created\"\nINFO:httpx:HTTP Request: GET https://api.replicate.com/v1/models/idea-research/ram-grounded-sam/versions/80a2aede4cf8e3c9f26e96c308d45b23c350dd36f1c381de790715007f1ac0ad \"HTTP/1.1 200 OK\"\n2024-11-13 05:26:29.782 | INFO | predict:predict:108 - Image saved to output_label_image.jpg",
"output": "https://replicate.delivery/yhqm/3uMUCJKpWA48K92aW2rOd2l4VfGe3oA0ZcFxEXeMj31LU9gnA/output_label_image.jpg",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-11-13T05:26:25.264Z",
"started_at": "2024-11-13T05:26:25.273113Z",
"completed_at": "2024-11-13T05:26:29.790654Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/tw7gj5xry1rj60ck4fy8whgs0g/cancel",
"get": "https://api.replicate.com/v1/predictions/tw7gj5xry1rj60ck4fy8whgs0g",
"stream": "https://stream.replicate.com/v1/files/qoxq-n6y65y2mvuppluq33mpgyq3f66garkf3a4awxcwfcbtbywtljg7a",
"web": "https://replicate.com/p/tw7gj5xry1rj60ck4fy8whgs0g"
},
"metrics": {
"predict_time": 4.517541782,
"total_time": 4.526654
}
}
