### Installation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Install the SDK using Go modules. ```APIDOC ## Installation Install the SDK using Go modules. ```go go get github.com/alibabacloud-go/imageseg-20191230/v4 ``` ``` -------------------------------- ### Install Image Segmentation SDK for Go Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Install the SDK using Go modules. ```go go get github.com/alibabacloud-go/imageseg-20191230/v4 ``` -------------------------------- ### Install imageseg SDK for Go Source: https://github.com/alibabacloud-go/imageseg-20191230/blob/master/README.md Use this command to install the Alibaba Cloud imageseg SDK for Go if you are managing dependencies with go mod. Ensure your Go environment is version 1.12.0 or greater. ```sh $ go get github.com/alibabacloud-go/imageseg-20191230/v4 ``` -------------------------------- ### Segment Body with Context and Timeout in Go Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Use context-aware methods for better cancellation and timeout control when performing image segmentation. This example demonstrates setting a 30-second timeout for the SegmentBody operation. ```go package main import ( "context" "fmt" "time" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentBodyWithContext(client *imageseg.Client) { ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() request := &imageseg.SegmentBodyRequest{ ImageURL: dara.String("https://example.com/person.jpg"), } runtime := &dara.RuntimeOptions{} response, err := client.SegmentBodyWithContext(ctx, request, runtime) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### Process Local Image File with Advance Method in Go Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Processes a local image file using an advance method, which automatically uploads the file to OSS. This example demonstrates segmenting the body from a local file. ```go package main import ( "fmt" "os" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentBodyFromLocalFile(client *imageseg.Client) { file, err := os.Open("/path/to/local/image.jpg") if err != nil { fmt.Printf("Error opening file: %v\n", err) return } defer file.Close() request := &imageseg.SegmentBodyAdvanceRequest{ ImageURLObject: file, ReturnForm: dara.String("mask"), } runtime := &dara.RuntimeOptions{} response, err := client.SegmentBodyAdvance(request, runtime) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Result Image URL: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### Client Initialization Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Create and configure the image segmentation client with your Alibaba Cloud credentials. ```APIDOC ## Client Initialization Create and configure the image segmentation client with your Alibaba Cloud credentials. ```go package main import ( "fmt" openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client" openapiutil "github.com/alibabacloud-go/darabonba-openapi/v2/utils" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func createClient() (*imageseg.Client, error) { config := &openapiutil.Config{ AccessKeyId: dara.String("your-access-key-id"), AccessKeySecret: dara.String("your-access-key-secret"), RegionId: dara.String("cn-shanghai"), } return imageseg.NewClient(config) } func main() { client, err := createClient() if err != nil { panic(err) } fmt.Println("Client initialized successfully") } ``` ``` -------------------------------- ### Initialize Image Segmentation Client Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Create and configure the image segmentation client with your Alibaba Cloud credentials. Ensure your AccessKeyId, AccessKeySecret, and RegionId are correctly set. ```go package main import ( "fmt" openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client" openapiutil "github.com/alibabacloud-go/darabonba-openapi/v2/utils" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func createClient() (*imageseg.Client, error) { config := &openapiutil.Config{ AccessKeyId: dara.String("your-access-key-id"), AccessKeySecret: dara.String("your-access-key-secret"), RegionId: dara.String("cn-shanghai"), } return imageseg.NewClient(config) } func main() { client, err := createClient() if err != nil { panic(err) } fmt.Println("Client initialized successfully") } ``` -------------------------------- ### Replace Sky with Go SDK Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Replaces the sky in an image with a specified sky image. This function requires the original image URL and the replacement sky image URL. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func changeSky(client *imageseg.Client) { request := &imageseg.ChangeSkyRequest{ ImageURL: dara.String("https://example.com/landscape.jpg"), ReplaceImageURL: dara.String("https://example.com/sunset-sky.jpg"), } response, err := client.ChangeSky(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Sky Replacement Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### Segment Human Body with Runtime Options Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Performs human body segmentation with custom runtime options for timeout and retry. Ensure the ImageURL is valid. ```go // With runtime options for custom timeout and retry func segmentBodyWithOptions(client *imageseg.Client) { request := &imageseg.SegmentBodyRequest{ ImageURL: dara.String("https://example.com/person.jpg"), } runtime := &dara.RuntimeOptions{ ReadTimeout: dara.Int(30000), ConnectTimeout: dara.Int(10000), } response, err := client.SegmentBodyWithOptions(request, runtime) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Result Image URL: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### Segment Sky with Go SDK Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments the sky region from landscape or outdoor images using the imageseg client. Ensure the client is properly initialized before use. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentSky(client *imageseg.Client) { request := &imageseg.SegmentSkyRequest{ ImageURL: dara.String("https://example.com/landscape.jpg"), } response, err := client.SegmentSky(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Sky Segmentation Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### Segment HD Sky with Go SDK Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Performs high-definition sky segmentation for high-resolution images. This function requires an initialized imageseg client. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentHDSky(client *imageseg.Client) { request := &imageseg.SegmentHDSkyRequest{ ImageURL: dara.String("https://example.com/hd-landscape.jpg"), } response, err := client.SegmentHDSky(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("HD Sky Segmentation Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### Segment Cloth - Go Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments clothing items from an image. Supports specifying clothing classes and output modes. Requires an image URL. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentCloth(client *imageseg.Client) { request := &imageseg.SegmentClothRequest{ ImageURL: dara.String("https://example.com/fashion.jpg"), ClothClass: []*string{dara.String("tops"), dara.String("bottoms")}, OutMode: dara.Int64(0), // Output mode option ReturnForm: dara.String("mask"), } response, err := client.SegmentCloth(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Cloth Segmentation Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### SegmentBodyAdvance - Process Local Files Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Processes an image from a local file using advance methods, automatically uploading it to OSS. ```APIDOC ## SegmentBodyAdvance - Process Local Files ### Description Processes an image from a local file using advance methods, automatically uploading it to OSS. ### Method POST ### Endpoint /segmentBodyAdvance ### Parameters #### Request Body - **ImageURLObject** (file) - Required - The local image file to upload and process. - **ReturnForm** (string) - Optional - The desired output format (e.g., "mask"). ### Request Example ``` POST /segmentBodyAdvance Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="ImageURLObject"; filename="image.jpg" Content-Type: image/jpeg [binary data of the image file] ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="ReturnForm" mask ------WebKitFormBoundary7MA4YWxkTrZu0gW-- ``` ### Response #### Success Response (200) - **Data.ImageURL** (string) - The URL of the processed image. #### Response Example ```json { "RequestId": "some-request-id", "Data": { "ImageURL": "https://example.com/processed-image.jpg" } } ``` ``` -------------------------------- ### Segment Hair - Go Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments hair regions from an image. Requires an image URL. Use for hair color changing or styling applications. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentHair(client *imageseg.Client) { request := &imageseg.SegmentHairRequest{ ImageURL: dara.String("https://example.com/portrait.jpg"), } response, err := client.SegmentHair(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Hair Segmentation Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### Segment Common Image - Go Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Performs general-purpose foreground segmentation on any image type. Requires an image URL and specifies the return form as 'mask'. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentCommonImage(client *imageseg.Client) { request := &imageseg.SegmentCommonImageRequest{ ImageURL: dara.String("https://example.com/image.jpg"), ReturnForm: dara.String("mask"), } response, err := client.SegmentCommonImage(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Common Image Segmentation Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### Segment HD Common Image - Go Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Performs high-definition general-purpose foreground segmentation. Requires an image URL. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentHDCommonImage(client *imageseg.Client) { request := &imageseg.SegmentHDCommonImageRequest{ ImageUrl: dara.String("https://example.com/high-res-image.jpg"), } response, err := client.SegmentHDCommonImage(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("HD Common Image Segmentation Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### Parse Face with Go SDK Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Parses facial features and regions from an image. Provide the image URL to the ParseFaceRequest. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func parseFace(client *imageseg.Client) { request := &imageseg.ParseFaceRequest{ ImageURL: dara.String("https://example.com/face.jpg"), } response, err := client.ParseFace(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Face Parsing Result: %+v\n", response.Body.Data) } ``` -------------------------------- ### Segment Skin - Go Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments skin regions from an image. Requires an image URL. Suitable for beauty and cosmetic applications. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentSkin(client *imageseg.Client) { request := &imageseg.SegmentSkinRequest{ URL: dara.String("https://example.com/face.jpg"), } response, err := client.SegmentSkin(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Skin Segmentation Result: %s\n", *response.Body.Data.URL) } ``` -------------------------------- ### Segment Commodity - Go Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments product items from an image, ideal for e-commerce. Requires an image URL and specifies the return form as 'mask'. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentCommodity(client *imageseg.Client) { request := &imageseg.SegmentCommodityRequest{ ImageURL: dara.String("https://example.com/product.jpg"), ReturnForm: dara.String("mask"), } response, err := client.SegmentCommodity(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Commodity Segmentation Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### SegmentCloth - Clothing Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments clothing items from images with options for specific clothing classes and output modes. ```APIDOC ## SegmentCloth - Clothing Segmentation ### Description Segments clothing items from images with options for specific clothing classes and output modes. ### Method POST ### Endpoint /api/segment/cloth ### Parameters #### Request Body - **ImageURL** (string) - Required - The URL of the image to process. - **ClothClass** (array of strings) - Optional - Specifies the clothing classes to segment (e.g., "tops", "bottoms"). - **OutMode** (integer) - Optional - Output mode option (e.g., 0 for default). - **ReturnForm** (string) - Optional - The format of the returned segmentation (e.g., "mask"). ### Request Example { "ImageURL": "https://example.com/fashion.jpg", "ClothClass": ["tops", "bottoms"], "OutMode": 0, "ReturnForm": "mask" } ### Response #### Success Response (200) - **Data** (object) - Contains the segmentation result. - **ImageURL** (string) - The URL of the segmented image. #### Response Example { "Data": { "ImageURL": "https://example.com/segmented_cloth.png" } } ``` -------------------------------- ### SegmentSkin - Skin Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments skin regions from an image for beauty and cosmetic applications. ```APIDOC ## SegmentSkin - Skin Segmentation ### Description Segments skin regions from an image for beauty and cosmetic applications. ### Method POST ### Endpoint /api/segment/skin ### Parameters #### Request Body - **URL** (string) - Required - The URL of the image to process. ### Request Example { "URL": "https://example.com/face.jpg" } ### Response #### Success Response (200) - **Data** (object) - Contains the segmentation result. - **URL** (string) - The URL of the segmented image. #### Response Example { "Data": { "URL": "https://example.com/segmented_skin.png" } } ``` -------------------------------- ### Segment Human Body Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments human body from the background. Use 'mask' for mask image output, otherwise, a transparent PNG is returned. Handles errors and prints the result image URL. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentBody(client *imageseg.Client) { request := &imageseg.SegmentBodyRequest{ ImageURL: dara.String("https://example.com/person.jpg"), ReturnForm: dara.String("mask"), // "mask" for mask image, omit for transparent PNG } response, err := client.SegmentBody(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Request ID: %s\n", *response.Body.RequestId) fmt.Printf("Result Image URL: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### Segment Food - Go Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments food items from an image, suitable for food photography and menus. Requires an image URL and specifies the return form as 'mask'. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentFood(client *imageseg.Client) { request := &imageseg.SegmentFoodRequest{ ImageURL: dara.String("https://example.com/food.jpg"), ReturnForm: dara.String("mask"), } response, err := client.SegmentFood(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Food Segmentation Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### SegmentCommonImage - General Image Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Performs general-purpose foreground segmentation on any type of image. ```APIDOC ## SegmentCommonImage - General Image Segmentation ### Description Performs general-purpose foreground segmentation on any type of image. ### Method POST ### Endpoint /api/segment/common-image ### Parameters #### Request Body - **ImageURL** (string) - Required - The URL of the image to process. - **ReturnForm** (string) - Optional - The format of the returned segmentation (e.g., "mask"). ### Request Example { "ImageURL": "https://example.com/image.jpg", "ReturnForm": "mask" } ### Response #### Success Response (200) - **Data** (object) - Contains the segmentation result. - **ImageURL** (string) - The URL of the segmented image. #### Response Example { "Data": { "ImageURL": "https://example.com/segmented_common_image.png" } } ``` -------------------------------- ### Refine Segmentation Mask with Go SDK Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Refines a segmentation mask to improve edge quality and accuracy. This requires both the original image URL and the mask image URL. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func refineMask(client *imageseg.Client) { request := &imageseg.RefineMaskRequest{ ImageURL: dara.String("https://example.com/original.jpg"), MaskImageURL: dara.String("https://example.com/mask.jpg"), } response, err := client.RefineMask(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Refined Mask Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### ChangeSky - Sky Replacement Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Replaces the sky in an image with another sky image. ```APIDOC ## ChangeSky - Sky Replacement ### Description Replaces the sky in an image with another sky image. ### Method POST ### Endpoint /changeSky ### Parameters #### Request Body - **ImageURL** (string) - Required - The URL of the original image. - **ReplaceImageURL** (string) - Required - The URL of the replacement sky image. ### Request Example ```json { "ImageURL": "https://example.com/landscape.jpg", "ReplaceImageURL": "https://example.com/sunset-sky.jpg" } ``` ### Response #### Success Response (200) - **Data.ImageURL** (string) - The URL of the image with the replaced sky. #### Response Example ```json { "RequestId": "some-request-id", "Data": { "ImageURL": "https://example.com/sky-replaced-image.jpg" } } ``` ``` -------------------------------- ### SegmentCommodity - Product/Commodity Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments product items from images, ideal for e-commerce product photography. ```APIDOC ## SegmentCommodity - Product/Commodity Segmentation ### Description Segments product items from images, ideal for e-commerce product photography. ### Method POST ### Endpoint /api/segment/commodity ### Parameters #### Request Body - **ImageURL** (string) - Required - The URL of the image to process. - **ReturnForm** (string) - Optional - The format of the returned segmentation (e.g., "mask"). ### Request Example { "ImageURL": "https://example.com/product.jpg", "ReturnForm": "mask" } ### Response #### Success Response (200) - **Data** (object) - Contains the segmentation result. - **ImageURL** (string) - The URL of the segmented image. #### Response Example { "Data": { "ImageURL": "https://example.com/segmented_commodity.png" } } ``` -------------------------------- ### ParseFace - Face Parsing Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Parses facial features and regions from an image. ```APIDOC ## ParseFace - Face Parsing ### Description Parses facial features and regions from an image. ### Method POST ### Endpoint /parseFace ### Parameters #### Request Body - **ImageURL** (string) - Required - The URL of the image containing a face. ### Request Example ```json { "ImageURL": "https://example.com/face.jpg" } ``` ### Response #### Success Response (200) - **Data** (object) - Contains parsed facial data. #### Response Example ```json { "RequestId": "some-request-id", "Data": { "face_parsing_result": "some-data" } } ``` ``` -------------------------------- ### Check Async Job Status with Go SDK Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Retrieves the status and result of an asynchronous segmentation job using its Job ID. Handles potential errors during the status check. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func getAsyncJobResult(client *imageseg.Client) { request := &imageseg.GetAsyncJobResultRequest{ JobId: dara.String("E75FE679-0303-4DD1-8252-1143B4FA8A27"), } response, err := client.GetAsyncJobResult(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Job Status: %s\n", *response.Body.Data.Status) if response.Body.Data.Result != nil { fmt.Printf("Job Result: %s\n", *response.Body.Data.Result) } } ``` -------------------------------- ### SegmentFood - Food Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments food items from images for food photography and menu applications. ```APIDOC ## SegmentFood - Food Segmentation ### Description Segments food items from images for food photography and menu applications. ### Method POST ### Endpoint /api/segment/food ### Parameters #### Request Body - **ImageURL** (string) - Required - The URL of the image to process. - **ReturnForm** (string) - Optional - The format of the returned segmentation (e.g., "mask"). ### Request Example { "ImageURL": "https://example.com/food.jpg", "ReturnForm": "mask" } ### Response #### Success Response (200) - **Data** (object) - Contains the segmentation result. - **ImageURL** (string) - The URL of the segmented image. #### Response Example { "Data": { "ImageURL": "https://example.com/segmented_food.png" } } ``` -------------------------------- ### SegmentHair - Hair Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments hair regions from an image for hair color changing or styling applications. ```APIDOC ## SegmentHair - Hair Segmentation ### Description Segments hair regions from an image for hair color changing or styling applications. ### Method POST ### Endpoint /api/segment/hair ### Parameters #### Request Body - **ImageURL** (string) - Required - The URL of the image to process. ### Request Example { "ImageURL": "https://example.com/portrait.jpg" } ### Response #### Success Response (200) - **Data** (object) - Contains the segmentation result. - **ImageURL** (string) - The URL of the segmented image. #### Response Example { "Data": { "ImageURL": "https://example.com/segmented_hair.png" } } ``` -------------------------------- ### Segment Human Head Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments the human head from an image. Use 'mask' for mask output. Handles errors and prints the result image URL. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentHead(client *imageseg.Client) { request := &imageseg.SegmentHeadRequest{ ImageURL: dara.String("https://example.com/portrait.jpg"), ReturnForm: dara.String("mask"), // Optional: "mask" for mask output } response, err := client.SegmentHead(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("Head Segmentation Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### SegmentBody - Human Body Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments human body from the background in an image, returning a transparent PNG or mask image. ```APIDOC ## SegmentBody - Human Body Segmentation Segments human body from the background in an image, returning a transparent PNG or mask image. ### Method POST ### Endpoint /api/segment/body ### Parameters #### Query Parameters - **ImageURL** (string) - Required - The URL of the image to segment. - **ReturnForm** (string) - Optional - Specifies the return format. Use "mask" for a mask image, omit for a transparent PNG. ### Request Example ```json { "ImageURL": "https://example.com/person.jpg", "ReturnForm": "mask" } ``` ### Response #### Success Response (200) - **RequestId** (string) - The ID of the request. - **Data** (object) - Contains the segmentation result. - **ImageURL** (string) - The URL of the resulting segmented image. ### Response Example ```json { "RequestId": "ABCDEF123456", "Data": { "ImageURL": "https://example.com/segmented-person.png" } } ``` ## SegmentBodyWithOptions - Human Body Segmentation with Runtime Options Performs human body segmentation with custom runtime options for timeout and retry. ### Method POST ### Endpoint /api/segment/body ### Parameters #### Query Parameters - **ImageURL** (string) - Required - The URL of the image to segment. #### Request Body (No specific request body fields mentioned beyond ImageURL, assuming it's part of the request parameters) ### Request Example ```go request := &imageseg.SegmentBodyRequest{ ImageURL: dara.String("https://example.com/person.jpg"), } runtime := &dara.RuntimeOptions{ ReadTimeout: dara.Int(30000), ConnectTimeout: dara.Int(10000), } ``` ### Response #### Success Response (200) - **Data** (object) - Contains the segmentation result. - **ImageURL** (string) - The URL of the resulting segmented image. ### Response Example ```json { "Data": { "ImageURL": "https://example.com/segmented-person.png" } } ``` ``` -------------------------------- ### SegmentHDCommonImage - HD Common Image Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Performs high-definition general-purpose foreground segmentation. ```APIDOC ## SegmentHDCommonImage - HD Common Image Segmentation ### Description Performs high-definition general-purpose foreground segmentation. ### Method POST ### Endpoint /api/segment/hd-common-image ### Parameters #### Request Body - **ImageUrl** (string) - Required - The URL of the image to process. ### Request Example { "ImageUrl": "https://example.com/high-res-image.jpg" } ### Response #### Success Response (200) - **Data** (object) - Contains the segmentation result. - **ImageURL** (string) - The URL of the segmented image. #### Response Example { "Data": { "ImageURL": "https://example.com/segmented_hd_common_image.png" } } ``` -------------------------------- ### SegmentHDSky - HD Sky Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Performs high-definition sky segmentation for high-resolution images. ```APIDOC ## SegmentHDSky - HD Sky Segmentation ### Description Performs high-definition sky segmentation for high-resolution images. ### Method POST ### Endpoint /segmentHDSky ### Parameters #### Request Body - **ImageURL** (string) - Required - The URL of the high-resolution image to process. ### Request Example ```json { "ImageURL": "https://example.com/hd-landscape.jpg" } ``` ### Response #### Success Response (200) - **Data.ImageURL** (string) - The URL of the HD segmented sky image. #### Response Example ```json { "RequestId": "some-request-id", "Data": { "ImageURL": "https://example.com/hd-segmented-sky.jpg" } } ``` ``` -------------------------------- ### SegmentSky - Sky Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments the sky region from landscape or outdoor images. ```APIDOC ## SegmentSky - Sky Segmentation ### Description Segments the sky region from landscape or outdoor images. ### Method POST ### Endpoint /segmentSky ### Parameters #### Request Body - **ImageURL** (string) - Required - The URL of the image to process. ### Request Example ```json { "ImageURL": "https://example.com/landscape.jpg" } ``` ### Response #### Success Response (200) - **Data.ImageURL** (string) - The URL of the segmented sky image. #### Response Example ```json { "RequestId": "some-request-id", "Data": { "ImageURL": "https://example.com/segmented-sky.jpg" } } ``` ``` -------------------------------- ### GetAsyncJobResult - Check Async Job Status Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Retrieves the result of an asynchronous segmentation job. ```APIDOC ## GetAsyncJobResult - Check Async Job Status ### Description Retrieves the result of an asynchronous segmentation job. ### Method GET ### Endpoint /getAsyncJobResult ### Parameters #### Query Parameters - **JobId** (string) - Required - The ID of the asynchronous job. ### Request Example ``` GET /getAsyncJobResult?JobId=E75FE679-0303-4DD1-8252-1143B4FA8A27 ``` ### Response #### Success Response (200) - **Data.Status** (string) - The status of the job (e.g., Processing, Succeeded, Failed). - **Data.Result** (string) - The result of the job if completed. #### Response Example ```json { "RequestId": "some-request-id", "Data": { "Status": "Succeeded", "Result": "https://example.com/job-result.jpg" } } ``` ``` -------------------------------- ### SegmentHead - Head Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Segments the human head from an image, useful for portrait editing and avatar creation. ```APIDOC ## SegmentHead - Head Segmentation Segments the human head from an image, useful for portrait editing and avatar creation. ### Method POST ### Endpoint /api/segment/head ### Parameters #### Query Parameters - **ImageURL** (string) - Required - The URL of the image to segment. - **ReturnForm** (string) - Optional - Specifies the return format. Use "mask" for a mask output. ### Request Example ```go request := &imageseg.SegmentHeadRequest{ ImageURL: dara.String("https://example.com/portrait.jpg"), ReturnForm: dara.String("mask"), // Optional: "mask" for mask output } ``` ### Response #### Success Response (200) - **Data** (object) - Contains the segmentation result. - **ImageURL** (string) - The URL of the resulting head segmentation image. ### Response Example ```json { "Data": { "ImageURL": "https://example.com/segmented-head.png" } } ``` ``` -------------------------------- ### Segment High Definition Human Body Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Performs high-definition human body segmentation for images requiring higher quality output. Handles errors and prints the result image URL. ```go package main import ( "fmt" imageseg "github.com/alibabacloud-go/imageseg-20191230/v4/client" "github.com/alibabacloud-go/tea/dara" ) func segmentHDBody(client *imageseg.Client) { request := &imageseg.SegmentHDBodyRequest{ ImageURL: dara.String("https://example.com/high-res-person.jpg"), } response, err := client.SegmentHDBody(request) if err != nil { fmt.Printf("Error: %v\n", err) return } fmt.Printf("HD Body Segmentation Result: %s\n", *response.Body.Data.ImageURL) } ``` -------------------------------- ### RefineMask - Mask Refinement Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Refines a segmentation mask to improve edge quality and accuracy. ```APIDOC ## RefineMask - Mask Refinement ### Description Refines a segmentation mask to improve edge quality and accuracy. ### Method POST ### Endpoint /refineMask ### Parameters #### Request Body - **ImageURL** (string) - Required - The URL of the original image. - **MaskImageURL** (string) - Required - The URL of the segmentation mask image. ### Request Example ```json { "ImageURL": "https://example.com/original.jpg", "MaskImageURL": "https://example.com/mask.jpg" } ``` ### Response #### Success Response (200) - **Data.ImageURL** (string) - The URL of the refined mask image. #### Response Example ```json { "RequestId": "some-request-id", "Data": { "ImageURL": "https://example.com/refined-mask.jpg" } } ``` ``` -------------------------------- ### SegmentHDBody - High Definition Body Segmentation Source: https://context7.com/alibabacloud-go/imageseg-20191230/llms.txt Performs high-definition human body segmentation for images requiring higher quality output. ```APIDOC ## SegmentHDBody - High Definition Body Segmentation Performs high-definition human body segmentation for images requiring higher quality output. ### Method POST ### Endpoint /api/segment/hdbody ### Parameters #### Query Parameters - **ImageURL** (string) - Required - The URL of the high-resolution image to segment. ### Request Example ```go request := &imageseg.SegmentHDBodyRequest{ ImageURL: dara.String("https://example.com/high-res-person.jpg"), } ``` ### Response #### Success Response (200) - **Data** (object) - Contains the segmentation result. - **ImageURL** (string) - The URL of the resulting HD segmented image. ### Response Example ```json { "Data": { "ImageURL": "https://example.com/segmented-hd-person.png" } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.