Stable Diffusion Inpainting
stable-diffusion-inpainting
Stable Diffusion Inpainting is a model that can be used to generate and modify images based on text prompts.
Model Information
Input
Configure model parameters
Output
View generated results
Result
Preview, share or download your results with a single click.

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 requestsimport timeAPI_KEY = "YOUR_API_KEY" # Replace with your API keyHEADERS = {"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": "stable-diffusion-inpainting","version": "0.0.1","input": {"mask": "your_file.image/jpeg","seed": null,"image": "your_file.image/jpeg","width": "512","height": "512","prompt": "a vision of paradise. unreal engine","scheduler": "DPMSolverMultistep","num_outputs": "1","guidance_scale": "7.5","negative_prompt": "your negative prompt here","num_inference_steps": "50","disable_safety_checker": false}})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 resultelif 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 predictionprediction_id = create_prediction()print(f"Prediction created: {prediction_id}")# Get resultresult = 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: ~1 seconds
- Rate limit: 60 requests/minute
- Concurrent requests: 10 maximum
- Use long-polling to check prediction status until completion
Overview
Stable Diffusion Inpainting is designed for inpainting tasks, enabling users to seamlessly restore or modify images by filling in missing or altered parts. Leveraging textual descriptions and visual cues, the model produces outputs that integrate naturally with the existing image. It is ideal for tasks like restoration, creative editing, and customized visual projects, offering numerous parameters for precise control.
Technical Specifications
Inpainting Capability: The model specializes in filling masked areas of an image with content that aligns with the provided prompt while maintaining consistency with the surrounding context.
High-Quality Output: Generates detailed and coherent images with realistic textures, lighting, and blending.
Versatile Modifications: Supports a wide range of image edits, including object addition, background changes, and defect correction.
Prompt-Driven Generation: Relies on descriptive text prompts to guide the inpainting process, allowing for creative and specific outputs.
Consistent Reproducibility: Allows for deterministic results through seed-based random number generation.
Content Safety Features: Includes an optional safety checker to ensure outputs adhere to appropriate content guidelines.
Key Considerations
- Image Quality: Use high-resolution base images for optimal results.
- Mask Precision: Ensure the mask accurately defines the area to modify.
- Prompt-Output Alignment: Avoid overly complex or conflicting prompts that may confuse the model.
- Inference Steps: Balance between time and detail; excessive steps may not always yield noticeable improvements.
Tips & Tricks
- Refining Prompts: Start with a general description and gradually add details for better control.
- Negative Prompting: Use the negative_prompt parameter to exclude unwanted elements effectively.
- Custom Resolutions: Match aspect_ratio to the dimensions of your input image for consistency.
Capabilities
- Realistic Inpainting: Seamlessly integrates new elements into existing images.
- Customizable Outputs: Adjust parameters to meet specific project needs.
What can I use for?
- Image Restoration: Repair damaged or incomplete photos and artwork.
- Creative Edits: Add, modify, or remove elements for artistic purposes.
- Design Enhancements: Tailor visuals for presentations, media, or marketing.
- Prototype Visualization: Generate concept visuals quickly for brainstorming.
Things to be aware of
- Restoration Projects: Repair old or damaged images by filling in missing parts.
- Creative Variations: Explore different prompts with the same base image to generate unique outputs.
- Custom Masking: Define intricate areas to edit for precise results.
- Size Testing: Compare results at different sizes to determine the best settings for your use case.
SCHEDULER
- DDIM:
- Use for faster results with smooth transitions.
- Works well with fewer inference steps.
- K_EULER:
- Ideal for sharp and detailed outputs.
- Pair with medium to high guidance scale values for clarity.
- DPMSolverMultistep:
- Best for balancing speed and quality.
- Delivers excellent results with fewer steps.
- K_EULER_ANCESTRAL:
- Great for creative and artistic outputs.
- Experiment with lower guidance scales for diverse results.
- PNDM:
- Ensures high accuracy and consistency.
- Use more steps for highly detailed outputs.
- KLMS:
- Perfect for high-resolution, realistic images.
- Higher guidance scales enhance detailed scenes like landscapes.
Limitations
- Output Consistency: Complex prompts or conflicting inputs may lead to unpredictable results.
- Resolution Constraints: Extremely high resolutions may increase processing time significantly.
- Mask Limitations: Poorly defined masks can lead to unintended modifications.
- Safety Checker: Disabling it may result in outputs that do not meet content guidelines.
Output Format: PNG