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 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/flux-inpaint" # Request payload data = { "base64": False, "guidance_scale": 3.5, "image": image_url_to_base64("https://segmind-sd-models.s3.amazonaws.com/display_images/flux-inapint-ip.jpg"), # Or use image_file_to_base64("IMAGE_PATH") "image_format": "jpeg", "mask": image_url_to_base64("https://segmind-sd-models.s3.amazonaws.com/display_images/flux-inpaint-mask.jpeg"), # Or use image_file_to_base64("IMAGE_PATH") "negative_prompt": "bad quality, painting, blur", "num_inference_steps": 25, "prompt": "huge ship sailing", "quality": 95, "sampler": "euler", "samples": 1, "scheduler": "simple", "seed": 12467, "strength": 0.9 } 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


base64bool ( default: 1 )

Output as base64 encoded string


guidance_scalefloat ( default: 3.5 )

Guidance scale for the generation

min : 1,

max : 10


imageimage *

Input image


image_formatenum:str ( default: jpeg )

Output image format

Allowed values:


maskimage *

Mask image


negative_promptstr ( default: bad quality, painting, blur )

Description of what to avoid in the image


num_inference_stepsint ( default: 25 )

Number of inference steps

min : 10,

max : 75


promptstr *

Description of the image to be generated


qualityint ( default: 95 )

Image quality setting for output

min : 10,

max : 100


samplerenum:str ( default: euler )

Sampling method for image generation

Allowed values:


samplesint ( default: 1 )

Number of samples to generate

min : 1,

max : 4


schedulerenum:str ( default: simple )

Scheduler for image generation

Allowed values:


seedint ( default: 12467 )

Random seed for generation


strengthfloat ( default: 0.9 )

Strength of the effect applied

min : 0,

max : 1

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.

Flux Inpainting

Flux Inpainting allows you to selectively edit and enhance images. Whether you’re restoring old photographs, removing unwanted objects, or filling in missing regions.

Key Features of Flux Inpainting

  • High-Quality Inpainting: Flux Inpainting excels in maintaining the visual integrity of images. It uses sophisticated algorithms to analyze the surrounding pixels and generate content that matches the original texture and color.

  • User-Friendly Interface: The tool is designed with ease of use in mind, making it accessible for both professionals and beginners. The intuitive interface allows users to quickly select areas for inpainting and apply changes with minimal effort.

  • Versatile Applications: Whether you need to remove unwanted objects, repair old photos, or enhance digital artwork, Flux Inpainting provides versatile solutions for a wide range of image editing needs.

How to Use Flux Inpainting

  • Upload Your Image: Start by uploading the image you want to edit.

  • Select the Area to Inpaint: Use the inpaint brush to highlight the area of the image that needs inpainting.

  • Apply Inpainting: Click the generate button to let the AI work its magic. The model will analyze the surrounding pixels and generate a seamless fill for the selected area. Once the inpainting process is complete, review the changes and save the edited image to your device.

Use cases

  • Repairing Damaged Photos: Flux Inpainting can restore old or damaged photographs by filling in missing or deteriorated parts, bringing them back to their original glory. It can also effectively remove scratches, blemishes, and other imperfections from photos, making them look as good as new.

  • Artistic Enhancements: Artists and designers can use Flux Inpainting to add or modify elements in their artwork, enhancing creativity and visual appeal.

  • Unwanted Objects: Whether it’s an unwanted object in the background or an object that disrupts the composition, Flux Inpainting can seamlessly remove these elements from images.

Flux Inpainting is a powerful tool that brings advanced image editing capabilities to users of all skill levels. Its combination of high-quality results, user-friendly interface, and fast processing times make it an essential tool for anyone looking to enhance their images effortlessly.