POST
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 import requests import base64 # Use this function to convert an image file from the filesystem to base64 def image_file_to_base64(image_path): with open(image_path, 'rb') as f: image_data = f.read() return base64.b64encode(image_data).decode('utf-8') # Use this function to fetch an image from a URL and convert it to base64 def image_url_to_base64(image_url): response = requests.get(image_url) image_data = response.content return base64.b64encode(image_data).decode('utf-8') api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/fooocus" # Request payload 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": image_url_to_base64("https://segmind-sd-models.s3.amazonaws.com/display_images/fooocus-face-image.jpg"), # Or use image_file_to_base64("IMAGE_PATH") "faceswap_cn_stop": 0.9, "faceswap_cn_weight": 0.8, "imageprompt_img": image_url_to_base64("https://segmind-sd-models.s3.amazonaws.com/display_images/fooocus-image-prompt.png"), # Or use image_file_to_base64("IMAGE_PATH") "imageprompt_cn_stop": 0.5, "imageprompt_cn_weight": 0.6, "pyracanny_cn_stop": 0.5, "pyracanny_cn_weight": 1, "cpds_cn_stop": 0.5, "cpds_cn_weight": 1, "base64": False } headers = {'x-api-key': api_key} response = requests.post(url, json=data, headers=headers) print(response.content) # The response is the generated image
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.