Image to 3D
Overview
This endpoint generates 3D image from image while passing appropriate parameters.
Request
--request POST 'https://modelslab.com/api/v3/img_to_3d' \
Make a POST
request to https://modelslab.com/api/v3/img_to_3d endpoint and pass the required parameters as a request body.
Body Attributes
Parameter | Description | Values |
---|---|---|
key | Your API Key used for request authorization. | key |
image | Link to the initial image. | url |
steps | Number of denoising steps. | 21, 31, 41 |
guidance_scale | Scale for classifier-free guidance. | Minimum: 1, Maximum: 20 |
frame_size | Number of frames for the 3D image. | |
seed | Seed used to reproduce results. Pass null for a random number. | integral value |
seconds | Number of seconds for the 3D image animation. | |
batch_size | Number of images per prompt. | |
safety_checker | A checker for NSFW images. If detected, replaces with a blank image. | true or false |
webhook | URL to receive a POST API call once image generation is complete. | url |
track_id | ID returned in the response to the webhook API call for identification. | integral value |
Example
Body
Body
{
"key":"",
"image":"https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg",
"guidance_scale":5,
"steps":31,
"frame_size":128,
"batch_size":10,
"seed":20,
"safety_checker":"no",
"seconds":4,
"webhook": null,
"track_id": null
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "",
"image":"https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg",
"guidance_scale":5,
"steps":31,
"frame_size":128,
"webhook": null,
"track_id": null
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://modelslab.com/api/v3/img_to_3d", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"image" => "https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg",
"guidance_scale" => 5,
"steps" => 31,
"frame_size" => 128,
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v3/img_to_3d',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://modelslab.com/api/v3/img_to_3d',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"image":"https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg",
"guidance_scale":5,
"steps":31,
"frame_size":128,
"webhook": null,
"track_id": null
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://modelslab.com/api/v3/img_to_3d"
payload = json.dumps({
"key": "",
"image":"https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg",
"guidance_scale":5,
"steps":31,
"frame_size":128,
"webhook": None,
"track_id": None
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"key\":\"",\n \"image\":\"https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg\",\n \"guidance_scale\":5,\n \"steps\":31,\n \"frame_size\":128\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v3/img_to_3d")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
{
"status": "success",
"generationTime": 6,
"id": 109656316,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/36b6d54b-4443-49f7-817d-b42511bae879.gif"
],
"meta": {
"batch_size": 4,
"file_prefix": "fbd026b6-5217-4b77-9fa4-dea8438d5ee9",
"frame_size": 128,
"guidance_scale": 15,
"image": "https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg",
"instant_response": "no",
"n_samples": 1,
"outdir": "out",
"output_type": "gif",
"safetychecker": "no",
"seconds": 3,
"seed": 20,
"steps": 31,
"temp": "no"
}
}