POST
javascript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 const axios = require('axios'); const fs = require('fs'); const path = require('path'); async function toB64(imgPath) { const data = fs.readFileSync(path.resolve(imgPath)); return Buffer.from(data).toString('base64'); } const api_key = "YOUR API-KEY"; const url = "https://api.segmind.com/v1/focus-inpaint"; const data = { "prompt": "Photo of a car on a road in a hill station", "negative_prompt": "lowquality, badquality, sketches", "steps": 30, "samples": 1, "styles": [ "Fooocus V2", "Fooocus Sharp", "Fooocus Enhance" ], "aspect_ratios": "1024*1024", "seed": 354849415, "guidance_scale": 4, "scheduler": "karras", "base_model": "juggernaut_v8", "sampler": "dpmpp_2m_sde_gpu", "input_image": toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/focus-inpaint-input.jpg'), "input_mask": "toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/focus-inpaint-mask.jpg')", "inpaint_erode_or_dilate": 1, "inpaint_respective_field": 0.618, "inpaint_strength": 1, "invert_mask_checkbox": "false", "mixing_image_prompt_and_inpaint": "true", "faceswap_img": "toB64('undefined')", "faceswap_cn_stop": 0.9, "faceswap_cn_weight": 0.8, "imageprompt_img": "toB64('undefined')", "imageprompt_cn_stop": 0.5, "imageprompt_cn_weight": 0.6, "pyracanny_img": "toB64('undefined')", "pyracanny_cn_stop": 0.5, "pyracanny_cn_weight": 1, "cpds_img": "toB64('undefined')", "cpds_cn_stop": 0.5, "cpds_cn_weight": 1, "base64": false }; (async function() { try { const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } }); console.log(response.data); } catch (error) { console.error('Error:', error.response.data); } })();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


promptstr *

Prompt to render


negative_promptstr ( default: None )

Prompts to exclude, eg. bad anatomy, bad hands, missing fingers


stepsint ( default: 30 ) Affects Pricing

Number of denoising steps.

min : 20,

max : 100


samplesint ( default: 1 ) Affects Pricing

Number images to generate.

min : 1,

max : 4


stylesarray ( default: Fooocus V2, Fooocus Photograph )

Style selection


aspect_ratiosenum:str ( default: 1024*1024 ) Affects Pricing

Output image aspect ratio

Allowed values:


inpaint_additional_promptstr ( default: 1 )

Additional Prompt for Inpainting


seedint ( default: -1 )

Seed for image generation.

min : -1,

max : 999999999999999


guidance_scalefloat ( default: 4 )

Scale for classifier-free guidance

min : 1,

max : 25


schedulerenum:str ( default: karras )

Type of scheduler.

Allowed values:


base_modelenum:str ( default: juggernaut_v8 )

Base model for inference

Allowed values:


samplerenum:str ( default: dpmpp_2m_sde_gpu )

Type of sampler

Allowed values:


input_imageimage *

Input image


input_maskimage *

Input Mask


inpaint_erode_or_dilatefloat ( default: 1 )

Erode or Dilate values. Negative implies Erode and vice versa

min : -50,

max : 50


inpaint_respective_fieldfloat ( default: 0.618 )

Inpaint Respective Field

min : 0,

max : 1


inpaint_strengthfloat ( default: 1 )

Inpaint strength

min : 0,

max : 1


invert_mask_checkboxbool ( default: false )

Invert mask checkbox


mixing_image_prompt_and_inpaintbool ( default: true )

Mixing image prompt and inpaint


faceswap_imgimage ( default: 1 )

Face image for swapping


faceswap_cn_stopfloat ( default: 0.9 )

Face swap stop value

min : 0,

max : 1.5


faceswap_cn_weightfloat ( default: 0.8 )

Face swap weight value

min : 0,

max : 1.5


imageprompt_imgimage ( default: 1 )

Image prompt image


imageprompt_cn_stopfloat ( default: 0.5 )

Ip controlnet stop value

min : 0,

max : 1.5


imageprompt_cn_weightfloat ( default: 0.6 )

Ip controlnet weight

min : 0,

max : 1.5


pyracanny_imgimage ( default: 1 )

Pyracanny image


pyracanny_cn_stopfloat ( default: 0.5 )

Controlnet stop value

min : 0,

max : 1.5


pyracanny_cn_weightfloat ( default: 1 )

Controlnet weight value

min : 0,

max : 1.5


cpds_imgimage ( default: 1 )

CPDS image


cpds_cn_stopfloat ( default: 0.5 )

Controlnet stop value

min : 0,

max : 1.5


cpds_cn_weightfloat ( default: 1 )

Controlnet weight value

min : 0,

max : 1.5


base64boolean ( default: 1 )

Base64 encoding of the output image.

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

Fooocus Inpainting

Fooocus Inpainting is a powerful image generation model that allows you to selectively edit and enhance images. Whether you’re restoring old photographs, removing unwanted objects, or filling in missing regions, Fooocus Inpainting provides a versatile solution.

  1. Input Image: Please upload the image you’d like to inpaint. Make sure it’s in a common image format (such as JPEG or PNG). If there are specific regions you want to inpaint, consider providing a mask as well.

  2. Mask: If you have a mask indicating the areas that need inpainting (e.g., the scratched portion of an old photo), please upload it. The mask helps guide the inpainting process.

  3. Text Prompt: Describe your desired outcome or any specific instructions related to the inpainting. For example, if you want to restore missing parts of an old family portrait, mention that.

When working with Fooocus Inpainting, providing reference images and using specific techniques can indeed enhance your control over image manipulation. Here’s how you can leverage these tools:

Reference Images for Image Prompt: If you have specific visual references or examples of the desired inpainting outcome, consider including them. These reference images can guide the model by providing context, style, and content cues.

Pyracanny: Pyracanny is a powerful edge detection technique. By applying Pyracanny to your input image, you can extract precise edge information. Use this edge map as an additional input to Fooocus Inpainting. It helps the model understand object boundaries and ensures smoother transitions between inpainted and original regions.

Face Image: This is a specific kind of image prompt where the provided image focuses on a face. It’s useful when you want to specifically modify or generate an image centered around a face.

CPDS (Contour-Preserved Dense Sampling): CPDS is a technique that preserves contours during image manipulation. If you want to maintain sharp edges or specific contours (e.g., architectural details, tree branches, or intricate patterns), use CPDS. It ensures that the inpainted regions blend seamlessly while retaining essential features.