Editing Image Background

realistic-background

Realistic Background is an AI model designed for removing backgrounds in images.

L40S 45GB
Fast Inference
REST API

Model Information

Response Time~42 sec
StatusActive
Version
0.0.1
Updated16 days ago

Prerequisites

  • Create an API Key from the Eachlabs Console
  • Install the required dependencies for your chosen language (e.g., requests for Python)

API Integration Steps

1. Create a Prediction

Send a POST request to create a new prediction. This will return a prediction ID that you'll use to check the result. The request should include your model inputs and API key.

import requests
import time
API_KEY = "YOUR_API_KEY" # Replace with your API key
HEADERS = {
"X-API-Key": API_KEY,
"Content-Type": "application/json"
}
def create_prediction():
response = requests.post(
"https://api.eachlabs.ai/v1/prediction/",
headers=HEADERS,
json={
"model": "realistic-background",
"version": "0.0.1",
"input": {
"seed": "-1",
"image": "your_file.image/jpeg",
"steps": "20",
"prompt": "RAW photo, 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm XT3",
"cfg_scale": "7",
"max_width": "1024",
"max_height": "1024",
"sampler_name": "DPM++ SDE Karras",
"negative_prompt": "(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, mutated hands and fingers:1.4), (deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, disconnected limbs, mutation, mutated, ugly, disgusting, amputation",
"denoising_strength": "0.75",
"only_masked_padding_pixels": "4"
}
}
)
prediction = response.json()
if prediction["status"] != "success":
raise Exception(f"Prediction failed: {prediction}")
return prediction["predictionID"]

2. Get Prediction Result

Poll the prediction endpoint with the prediction ID until the result is ready. The API uses long-polling, so you'll need to repeatedly check until you receive a success status.

def get_prediction(prediction_id):
while True:
result = requests.get(
f"https://api.eachlabs.ai/v1/prediction/{prediction_id}",
headers=HEADERS
).json()
if result["status"] == "success":
return result
elif result["status"] == "error":
raise Exception(f"Prediction failed: {result}")
time.sleep(1) # Wait before polling again

3. Complete Example

Here's a complete example that puts it all together, including error handling and result processing. This shows how to create a prediction and wait for the result in a production environment.

try:
# Create prediction
prediction_id = create_prediction()
print(f"Prediction created: {prediction_id}")
# Get result
result = get_prediction(prediction_id)
print(f"Output URL: {result['output']}")
print(f"Processing time: {result['metrics']['predict_time']}s")
except Exception as e:
print(f"Error: {e}")

Additional Information

  • The API uses a two-step process: create prediction and poll for results
  • Response time: ~42 seconds
  • Rate limit: 60 requests/minute
  • Concurrent requests: 10 maximum
  • Use long-polling to check prediction status until completion

Overview

Realistic Background is designed to create high-quality and visually compelling backgrounds based on input prompts. The model is particularly suitable for generating photorealistic environments and settings, making it an ideal choice for projects requiring professional and realistic image generation.

Technical Specifications

Realistic Background employs advanced diffusion techniques and optimized sampling algorithms to generate high-resolution images with minimal artifacts.

Key Considerations

Input Quality: Low-quality or ambiguous prompts may lead to undesirable results.

Processing Time: Higher resolutions and more steps can significantly increase generation time.

Sampler Selection: Different samplers produce varying artistic styles. Experiment with the sampler_name input to identify the best option for your needs.

Seed Dependence: Outputs are tied to the seed value. Changing the seed alters the randomness of the output.

Tips & Tricks

  • Prompt Crafting: Use detailed and specific descriptions in the prompt to achieve the desired style and realism. For example, "a serene beach at sunset with gentle waves and golden sand" generates more refined results than "a beach."
  • Negative Prompt Refinement: If unwanted elements appear frequently, refine the negative_prompt. Example: "no people, no buildings, no blur."
  • Sampler Tuning:
    • For smoother results: Use DPM++ SDE or Euler a.
    • For detailed outputs: Choose DPM++ 2M SDE Heun.
    • For artistic freedom: Experiment with LMS or DPM adaptive.
  • Denoising Strength:
    • Set between 0.6 - 0.8 for balanced creativity and structure.
    • Avoid extremes unless you are targeting highly abstract or minimal changes.
  • Steps: Start with a moderate value, such as 25-30, for fast yet refined results. For more intricate details, increase to 50-60.
  • Resolution Settings:
    • Use max_width and max_height values proportional to your desired output. For example, 1920x1080 for standard HD backgrounds.
    • Avoid excessively high resolutions unless necessary to reduce processing time.
  • Seed Consistency: Use a fixed seed when you need reproducible outputs, especially for iterative adjustments.

Capabilities

Generates high-quality, realistic backgrounds tailored to user-provided prompts.

Offers fine-tuned control over image details using various input parameters.

Supports style transfer and enhancement through the image input.

What can I use for?

  • Creating photorealistic backgrounds for projects, presentations, or media content.
  • Enhancing existing visuals with consistent and coherent backgrounds.
  • Generating creative assets for design and artistic endeavors.

Things to be aware of

Combine a detailed prompt with negative_prompt to achieve highly customized results.

Experiment with different samplers, such as Euler a or DPM++ 2S a, for diverse stylistic outputs.

Use specific seeds to recreate and refine previously generated backgrounds.

Adjust the cfg_scale to find the perfect balance between creativity and prompt adherence.

Limitations

Complex Scenes: Overly detailed prompts may lead to cluttered outputs.

Resolution Limits: Extremely high resolutions can strain processing resources and increase generation time.

Sampler Variability: Results can differ significantly between samplers; testing may be required to find the optimal choice.

Output Format: PNG

Related AI Models

eachlabs-couple

Couple Image Generation

eachlabs-couple

Image to Image
bytedance

Style Changer by ByteDance

bytedance

Image to Image
sdxl-controlnet-lora

SDXL Controlnet Lora

sdxl-controlnet-lora

Image to Image
flux-redux-schnell

Flux Redux Schnell

flux-redux-schnell

Image to Image