API
If you're looking for an API, you can choose from your desired programming language.
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
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/seg-swap"
# Request payload
data = {
"prompt": "photo of a wooden table in center of living room",
"main_image": image_url_to_base64("https://segmind-resources.s3.amazonaws.com/others/b855aade-9114-4554-9530-088f1eb1e32d-livingroom.png"), # Or use image_file_to_base64("IMAGE_PATH")
"object_image": image_url_to_base64("https://segmind-resources.s3.amazonaws.com/others/69ceda90-7c13-48e2-a436-a4e0f733d136-table2.png"), # Or use image_file_to_base64("IMAGE_PATH")
"mask_image": image_url_to_base64("https://segmind-resources.s3.amazonaws.com/others/b2c6b355-07be-4edc-b6ce-ec05fd6a03f2-mask_room2.png"), # Or use image_file_to_base64("IMAGE_PATH")
"steps": 30,
"seed": 42,
"growmask": 5,
"horizontal_repeat": 1,
"vertical_repeat": 1,
"image_format": "png",
"image_quality": 95,
"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
Attributes
The main prompt describing the scene or subject
The URL of the main image
The URL of the overlay image
The URL of the main image mask
The number of steps for image processing
min : 10,
max : 100
Random seed for reproducibility
Grow mask parameter for adjusting mask size
min : 0,
max : 20
No of horizontal tiling of object (useful when object is a pattern)
min : 1,
max : 10
No of vertical tiling of object (useful when object is a pattern)
min : 1,
max : 10
The output image format
Allowed values:
The quality of the output image
min : 10,
max : 100
Return image as base64 string
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.
Seg Swap
The Seg-Swap model from Segmind empowers users to dynamically alter images by removing, replacing, adding objects, and transferring patterns. This innovative image manipulation model is designed for content creators and businesses seeking advanced and intuitive image editing capabilities, offering a unique way to transform visual content.
Key Features of Seg Swap
-
Object Removal and Replacement: Seamlessly remove an existing object in an image and replace it with a new object, providing powerful editing flexibility.
-
Object Addition: Introduce new elements into an image, expanding creative possibilities and allowing for complex scene construction.
-
Pattern Transfer: Apply the visual pattern from one object onto another, such as transferring a textile pattern to a sofa, unlocking unique design options.
-
Mask-Based Control: Utilize a mask image to precisely define the area of the main image that will be affected by the object manipulation.
-
Adjustable Processing Steps: Control the level of detail and refinement in the image processing with a configurable number of steps.
-
Mask Size Adjustment: Fine-tune the mask size using the growmask parameter to ensure smooth integration of new or modified objects.
-
Pattern Tiling: Repeat the overlay object horizontally and vertically, ideal for applying repeating patterns across surfaces
Use Cases
-
E-commerce Product Visualization: Easily swap product variations (e.g., different colored chairs) in a lifestyle image without re-shooting, enhancing online catalogs.
-
Interior Design Mockups: Experiment with different furniture styles and patterns in a room scene by replacing existing items, aiding in design decisions.
-
Graphic Design and Content Creation: Quickly add or replace elements in marketing materials or social media visuals, streamlining the content creation process.
-
Fashion and Textile Design: Visualize fabric patterns on different garment silhouettes or transfer patterns between items, accelerating the design workflow
The Seg-Swap model offers a powerful and versatile solution for advanced image manipulation, enabling users to effortlessly remove, replace, add objects, and transfer patterns. Its intuitive parameters and diverse applications make it an invaluable tool for enhancing creative workflows and achieving unique visual transformation.
Other Popular Models
sdxl-controlnet
SDXL ControlNet gives unprecedented control over text-to-image generation. SDXL ControlNet models Introduces the concept of conditioning inputs, which provide additional information to guide the image generation process

faceswap-v2
Take a picture/gif and replace the face in it with a face of your choice. You only need one image of the desired face. No dataset, no training

sdxl1.0-txt2img
The SDXL model is the official upgrade to the v1.5 model. The model is released as open-source software

sd2.1-faceswapper
Take a picture/gif and replace the face in it with a face of your choice. You only need one image of the desired face. No dataset, no training
