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 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/fooocus"; const data = { "prompt": "cinematic 3D caricature of a woman, smiling, looking happy", "negative_prompt": "lowquality, badquality, sketches", "steps": 30, "samples": 1, "styles": "V2,Enhance,Sharp", "aspect_ratio": "1024*1024", "seed": 1849415, "guidance_scale": 4, "scheduler": "DPM++ 2M SDE Karras", "base_model": "protovisionxl", "faceswap_img": toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/fooocus-face-image.jpg'), "faceswap_cn_stop": 0.9, "faceswap_cn_weight": 0.8, "imageprompt_img": "toB64('https://segmind-sd-models.s3.amazonaws.com/display_images/fooocus-image-prompt.png')", "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


stylesstr ( default: V2,Enhance,Sharp )

Style selection


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

output image aspect ratio

Allowed values:


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: DPM++ SDE )

Type of scheduler.

Allowed values:


base_modelenum:str ( default: juggernaut_v8 )

Model for inference

Allowed values:


faceswap_imgimage ( default: 1 )

faceswap_img


faceswap_cn_stopfloat ( default: 0.9 )

image propmt

min : 0,

max : 1.5


faceswap_cn_weightfloat ( default: 0.8 )

image propmt

min : 0,

max : 1.5


imageprompt_imgimage ( default: 1 )

faceswap_img


imageprompt_cn_stopfloat ( default: 0.5 )

image prompt

min : 0,

max : 1.5


imageprompt_cn_weightfloat ( default: 0.6 )

image propmt

min : 0,

max : 1.5


pyracanny_imgimage ( default: 1 )

pyracanny_img


pyracanny_cn_stopfloat ( default: 0.5 )

image propmt

min : 0,

max : 1.5


pyracanny_cn_weightfloat ( default: 1 )

image propmt

min : 0,

max : 1.5


cpds_imgimage ( default: 1 )

cpds_img


cpds_cn_stopfloat ( default: 0.5 )

image propmt

min : 0,

max : 1.5


cpds_cn_weightfloat ( default: 1 )

image propmt

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

Fooocus is an image generating framework that is based on Stable Diffusion. The goal of Fooocus is to combine the best aspects of Stable Diffusion and Midjourney. It’s designed to reduce the complexity of other Stable Diffusion interfaces, is easy to use and generates high-quality images out of the box.

Here are some key features of Fooocus:

  1. Ease of Use: Fooocus is designed to be user-friendly. It only requires a single prompt for the image generation process.

  2. Quality Images: Fooocus has optimized the Stable Diffusion pipeline to deliver excellent images. It uses a set of default settings that are optimized to give the best results when using SDXL models.

  3. Prompt Expansion: Fooocus expands your prompt with a GPT based prompt engine. This means you don’t need to write long and complicated prompts.

Input Image Types in Fooocus

These are the images you will be using as inputs in Fooocus. You can import various types of images such as an image prompt, Face image, Pyracanny, and CPDS depending on the use-case or desired final image output.

Image prompt

This is a general type of input where an image acts as a reference guide for the AI. It guides the image generation process in the direction of the provided image.

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.

Pyracanny

Pyracanny is a pyramid-based Canny edge control and it excels at detecting edges in high-resolution images. Regular Canny edge detection might miss some details, so PyraCanny tackles this by analyzing the image at various resolutions to create a more comprehensive edge map. This edge map then influences the final image.

CPDS

Contrast Preserving Decolorization (CPDS) is another custom control method used in Fooocus. It works in a way that’s comparable to ControlNet depth conditioning. CPDS helps in understand the depth information within the image, which can be useful for creating a more realistic or nuanced final image output.