ailabtools-sdk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ailabtools/__init__.py +4 -0
- ailabtools/client.py +17 -0
- ailabtools/common.py +26 -0
- ailabtools/cutout.py +71 -0
- ailabtools/endpoints.py +110 -0
- ailabtools/errors.py +17 -0
- ailabtools/generated/__init__.py +0 -0
- ailabtools/generated/endpoints.py +1923 -0
- ailabtools/http.py +64 -0
- ailabtools/image.py +224 -0
- ailabtools/portrait.py +251 -0
- ailabtools/types.py +22 -0
- ailabtools/utils.py +9 -0
- ailabtools_sdk-0.1.0.dist-info/METADATA +50 -0
- ailabtools_sdk-0.1.0.dist-info/RECORD +17 -0
- ailabtools_sdk-0.1.0.dist-info/WHEEL +5 -0
- ailabtools_sdk-0.1.0.dist-info/top_level.txt +1 -0
ailabtools/__init__.py
ADDED
ailabtools/client.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .types import ClientOptions
|
|
2
|
+
from .http import Requester
|
|
3
|
+
from .common import CommonAPI
|
|
4
|
+
from .image import ImageAPI
|
|
5
|
+
from .portrait import PortraitAPI
|
|
6
|
+
from .cutout import CutoutAPI
|
|
7
|
+
|
|
8
|
+
class AILabClient:
|
|
9
|
+
def __init__(self, api_key: str, base_url: str = "https://www.ailabapi.com", timeout: float = 30.0):
|
|
10
|
+
self._requester = Requester(api_key=api_key, base_url=base_url, timeout=timeout)
|
|
11
|
+
self.common = CommonAPI(self._requester)
|
|
12
|
+
self.image = ImageAPI(self._requester)
|
|
13
|
+
self.portrait = PortraitAPI(self._requester)
|
|
14
|
+
self.cutout = CutoutAPI(self._requester)
|
|
15
|
+
|
|
16
|
+
async def aclose(self):
|
|
17
|
+
await self._requester.aclose()
|
ailabtools/common.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from .http import Requester
|
|
2
|
+
from .utils import map_params
|
|
3
|
+
from .generated.endpoints import (
|
|
4
|
+
CommonQueryAsyncTaskResultParams,
|
|
5
|
+
CommonQueryAsyncTaskResultResponse,
|
|
6
|
+
CommonQueryAsyncTaskResultParamMap,
|
|
7
|
+
validate_commonQueryAsyncTaskResult_params,
|
|
8
|
+
CommonQueryCreditsParams,
|
|
9
|
+
CommonQueryCreditsResponse,
|
|
10
|
+
CommonQueryCreditsParamMap,
|
|
11
|
+
validate_commonQueryCredits_params
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
class CommonAPI:
|
|
15
|
+
def __init__(self, requester: Requester):
|
|
16
|
+
self._requester = requester
|
|
17
|
+
|
|
18
|
+
async def commonQueryAsyncTaskResult(self, params: CommonQueryAsyncTaskResultParams) -> CommonQueryAsyncTaskResultResponse:
|
|
19
|
+
validate_commonQueryAsyncTaskResult_params(params)
|
|
20
|
+
mapped = map_params(params, CommonQueryAsyncTaskResultParamMap)
|
|
21
|
+
return await self._requester.request('GET', '/api/common/query-async-task-result', query=mapped)
|
|
22
|
+
|
|
23
|
+
async def commonQueryCredits(self, params: CommonQueryCreditsParams) -> CommonQueryCreditsResponse:
|
|
24
|
+
validate_commonQueryCredits_params(params)
|
|
25
|
+
mapped = map_params(params, CommonQueryCreditsParamMap)
|
|
26
|
+
return await self._requester.request('GET', '/api/common/query-credits', query=mapped)
|
ailabtools/cutout.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from .http import Requester
|
|
2
|
+
from .utils import map_params
|
|
3
|
+
from .generated.endpoints import (
|
|
4
|
+
CutoutClothingBackgroundRemovalParams,
|
|
5
|
+
CutoutClothingBackgroundRemovalResponse,
|
|
6
|
+
CutoutClothingBackgroundRemovalParamMap,
|
|
7
|
+
validate_cutoutClothingBackgroundRemoval_params,
|
|
8
|
+
CutoutProductBackgroundRemovalParams,
|
|
9
|
+
CutoutProductBackgroundRemovalResponse,
|
|
10
|
+
CutoutProductBackgroundRemovalParamMap,
|
|
11
|
+
validate_cutoutProductBackgroundRemoval_params,
|
|
12
|
+
CutoutFoodBackgroundRemovalParams,
|
|
13
|
+
CutoutFoodBackgroundRemovalResponse,
|
|
14
|
+
CutoutFoodBackgroundRemovalParamMap,
|
|
15
|
+
validate_cutoutFoodBackgroundRemoval_params,
|
|
16
|
+
CutoutUniversalBackgroundRemovalParams,
|
|
17
|
+
CutoutUniversalBackgroundRemovalResponse,
|
|
18
|
+
CutoutUniversalBackgroundRemovalParamMap,
|
|
19
|
+
validate_cutoutUniversalBackgroundRemoval_params,
|
|
20
|
+
CutoutAvatarExtractionParams,
|
|
21
|
+
CutoutAvatarExtractionResponse,
|
|
22
|
+
CutoutAvatarExtractionParamMap,
|
|
23
|
+
validate_cutoutAvatarExtraction_params,
|
|
24
|
+
CutoutHairExtractionParams,
|
|
25
|
+
CutoutHairExtractionResponse,
|
|
26
|
+
CutoutHairExtractionParamMap,
|
|
27
|
+
validate_cutoutHairExtraction_params,
|
|
28
|
+
CutoutHumanBackgroundRemovalParams,
|
|
29
|
+
CutoutHumanBackgroundRemovalResponse,
|
|
30
|
+
CutoutHumanBackgroundRemovalParamMap,
|
|
31
|
+
validate_cutoutHumanBackgroundRemoval_params
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
class CutoutAPI:
|
|
35
|
+
def __init__(self, requester: Requester):
|
|
36
|
+
self._requester = requester
|
|
37
|
+
|
|
38
|
+
async def cutoutClothingBackgroundRemoval(self, params: CutoutClothingBackgroundRemovalParams) -> CutoutClothingBackgroundRemovalResponse:
|
|
39
|
+
validate_cutoutClothingBackgroundRemoval_params(params)
|
|
40
|
+
mapped = map_params(params, CutoutClothingBackgroundRemovalParamMap)
|
|
41
|
+
return await self._requester.request('POST', '/api/cutout/general/apparel-background-removal', body=mapped, multipart=True)
|
|
42
|
+
|
|
43
|
+
async def cutoutProductBackgroundRemoval(self, params: CutoutProductBackgroundRemovalParams) -> CutoutProductBackgroundRemovalResponse:
|
|
44
|
+
validate_cutoutProductBackgroundRemoval_params(params)
|
|
45
|
+
mapped = map_params(params, CutoutProductBackgroundRemovalParamMap)
|
|
46
|
+
return await self._requester.request('POST', '/api/cutout/general/commodity-background-removal', body=mapped, multipart=True)
|
|
47
|
+
|
|
48
|
+
async def cutoutFoodBackgroundRemoval(self, params: CutoutFoodBackgroundRemovalParams) -> CutoutFoodBackgroundRemovalResponse:
|
|
49
|
+
validate_cutoutFoodBackgroundRemoval_params(params)
|
|
50
|
+
mapped = map_params(params, CutoutFoodBackgroundRemovalParamMap)
|
|
51
|
+
return await self._requester.request('POST', '/api/cutout/general/food-background-removal', body=mapped, multipart=True)
|
|
52
|
+
|
|
53
|
+
async def cutoutUniversalBackgroundRemoval(self, params: CutoutUniversalBackgroundRemovalParams) -> CutoutUniversalBackgroundRemovalResponse:
|
|
54
|
+
validate_cutoutUniversalBackgroundRemoval_params(params)
|
|
55
|
+
mapped = map_params(params, CutoutUniversalBackgroundRemovalParamMap)
|
|
56
|
+
return await self._requester.request('POST', '/api/cutout/general/universal-background-removal', body=mapped, multipart=True)
|
|
57
|
+
|
|
58
|
+
async def cutoutAvatarExtraction(self, params: CutoutAvatarExtractionParams) -> CutoutAvatarExtractionResponse:
|
|
59
|
+
validate_cutoutAvatarExtraction_params(params)
|
|
60
|
+
mapped = map_params(params, CutoutAvatarExtractionParamMap)
|
|
61
|
+
return await self._requester.request('POST', '/api/cutout/portrait/avatar-extraction', body=mapped, multipart=True)
|
|
62
|
+
|
|
63
|
+
async def cutoutHairExtraction(self, params: CutoutHairExtractionParams) -> CutoutHairExtractionResponse:
|
|
64
|
+
validate_cutoutHairExtraction_params(params)
|
|
65
|
+
mapped = map_params(params, CutoutHairExtractionParamMap)
|
|
66
|
+
return await self._requester.request('POST', '/api/cutout/portrait/hairstyle-extraction', body=mapped, multipart=True)
|
|
67
|
+
|
|
68
|
+
async def cutoutHumanBackgroundRemoval(self, params: CutoutHumanBackgroundRemovalParams) -> CutoutHumanBackgroundRemovalResponse:
|
|
69
|
+
validate_cutoutHumanBackgroundRemoval_params(params)
|
|
70
|
+
mapped = map_params(params, CutoutHumanBackgroundRemovalParamMap)
|
|
71
|
+
return await self._requester.request('POST', '/api/cutout/portrait/portrait-background-removal', body=mapped, multipart=True)
|
ailabtools/endpoints.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
CommonQueryAsyncTaskResultParams = dict
|
|
2
|
+
CommonQueryAsyncTaskResultResponse = dict
|
|
3
|
+
CommonQueryCreditsParams = dict
|
|
4
|
+
CommonQueryCreditsResponse = dict
|
|
5
|
+
ImageLosslessEnlargementParams = dict
|
|
6
|
+
ImageLosslessEnlargementResponse = dict
|
|
7
|
+
ImageDistortionCorrectionParams = dict
|
|
8
|
+
ImageDistortionCorrectionResponse = dict
|
|
9
|
+
ImageClarityEnhancementParams = dict
|
|
10
|
+
ImageClarityEnhancementResponse = dict
|
|
11
|
+
ImageContrastEnhancementParams = dict
|
|
12
|
+
ImageContrastEnhancementResponse = dict
|
|
13
|
+
ImageColorEnhancementParams = dict
|
|
14
|
+
ImageColorEnhancementResponse = dict
|
|
15
|
+
ImageColoringParams = dict
|
|
16
|
+
ImageColoringResponse = dict
|
|
17
|
+
ImageStyleTransferParams = dict
|
|
18
|
+
ImageStyleTransferResponse = dict
|
|
19
|
+
ImageStyleMigrationParams = dict
|
|
20
|
+
ImageStyleMigrationResponse = dict
|
|
21
|
+
ImageColorMigrationParams = dict
|
|
22
|
+
ImageColorMigrationResponse = dict
|
|
23
|
+
ImageHdColorMigrationParams = dict
|
|
24
|
+
ImageHdColorMigrationResponse = dict
|
|
25
|
+
ImageIntelligentCompositionParams = dict
|
|
26
|
+
ImageIntelligentCompositionResponse = dict
|
|
27
|
+
ImagePhotoEditingParams = dict
|
|
28
|
+
ImagePhotoEditingResponse = dict
|
|
29
|
+
ImageInvisibleImageWatermarkParams = dict
|
|
30
|
+
ImageInvisibleImageWatermarkResponse = dict
|
|
31
|
+
ImageInvisibleTextWatermarkParams = dict
|
|
32
|
+
ImageInvisibleTextWatermarkResponse = dict
|
|
33
|
+
ImageErasureParams = dict
|
|
34
|
+
ImageErasureResponse = dict
|
|
35
|
+
ImageRemoveObjectsParams = dict
|
|
36
|
+
ImageRemoveObjectsResponse = dict
|
|
37
|
+
ImageRemoveObjectsAdvancedParams = dict
|
|
38
|
+
ImageRemoveObjectsAdvancedResponse = dict
|
|
39
|
+
ImageRemoveObjectsProParams = dict
|
|
40
|
+
ImageRemoveObjectsProResponse = dict
|
|
41
|
+
ImageAiObjectReplacerParams = dict
|
|
42
|
+
ImageAiObjectReplacerResponse = dict
|
|
43
|
+
ImageAiImageExtenderParams = dict
|
|
44
|
+
ImageAiImageExtenderResponse = dict
|
|
45
|
+
ImageExposureRatingParams = dict
|
|
46
|
+
ImageExposureRatingResponse = dict
|
|
47
|
+
PortraitFaceFusionParams = dict
|
|
48
|
+
PortraitFaceFusionResponse = dict
|
|
49
|
+
PortraitIntelligentBeautificationParams = dict
|
|
50
|
+
PortraitIntelligentBeautificationResponse = dict
|
|
51
|
+
PortraitIntelligentSkinRetouchingParams = dict
|
|
52
|
+
PortraitIntelligentSkinRetouchingResponse = dict
|
|
53
|
+
PortraitIntelligentFaceSlimmingParams = dict
|
|
54
|
+
PortraitIntelligentFaceSlimmingResponse = dict
|
|
55
|
+
PortraitFacialBeautificationParams = dict
|
|
56
|
+
PortraitFacialBeautificationResponse = dict
|
|
57
|
+
PortraitFacialBeautificationAdvancedParams = dict
|
|
58
|
+
PortraitFacialBeautificationAdvancedResponse = dict
|
|
59
|
+
PortraitFacialBeautificationProParams = dict
|
|
60
|
+
PortraitFacialBeautificationProResponse = dict
|
|
61
|
+
PortraitFacialMakeupParams = dict
|
|
62
|
+
PortraitFacialMakeupResponse = dict
|
|
63
|
+
PortraitFacialFiltersParams = dict
|
|
64
|
+
PortraitFacialFiltersResponse = dict
|
|
65
|
+
PortraitFacialShapingParams = dict
|
|
66
|
+
PortraitFacialShapingResponse = dict
|
|
67
|
+
PortraitExpressionEditingParams = dict
|
|
68
|
+
PortraitExpressionEditingResponse = dict
|
|
69
|
+
PortraitHairstyleEditingParams = dict
|
|
70
|
+
PortraitHairstyleEditingResponse = dict
|
|
71
|
+
PortraitHairstyleEditingProParams = dict
|
|
72
|
+
PortraitHairstyleEditingProResponse = dict
|
|
73
|
+
PortraitLivePhotosParams = dict
|
|
74
|
+
PortraitLivePhotosResponse = dict
|
|
75
|
+
PortraitHitchcockEffectParams = dict
|
|
76
|
+
PortraitHitchcockEffectResponse = dict
|
|
77
|
+
PortraitFacialBlurringParams = dict
|
|
78
|
+
PortraitFacialBlurringResponse = dict
|
|
79
|
+
PortraitFaceAttributeEditingParams = dict
|
|
80
|
+
PortraitFaceAttributeEditingResponse = dict
|
|
81
|
+
PortraitFaceRestorationEnhancementParams = dict
|
|
82
|
+
PortraitFaceRestorationEnhancementResponse = dict
|
|
83
|
+
PortraitLipsColorChangerParams = dict
|
|
84
|
+
PortraitLipsColorChangerResponse = dict
|
|
85
|
+
PortraitSkinDiseaseDetectionParams = dict
|
|
86
|
+
PortraitSkinDiseaseDetectionResponse = dict
|
|
87
|
+
PortraitSkinAnalysisBasicParams = dict
|
|
88
|
+
PortraitSkinAnalysisBasicResponse = dict
|
|
89
|
+
PortraitSkinAnalysisAdvancedParams = dict
|
|
90
|
+
PortraitSkinAnalysisAdvancedResponse = dict
|
|
91
|
+
PortraitSkinAnalysisProfessionalParams = dict
|
|
92
|
+
PortraitSkinAnalysisProfessionalResponse = dict
|
|
93
|
+
PortraitFaceAnalyzerParams = dict
|
|
94
|
+
PortraitFaceAnalyzerResponse = dict
|
|
95
|
+
PortraitFaceAnalyzerAdvancedParams = dict
|
|
96
|
+
PortraitFaceAnalyzerAdvancedResponse = dict
|
|
97
|
+
PortraitTryOnClothesProParams = dict
|
|
98
|
+
PortraitTryOnClothesProResponse = dict
|
|
99
|
+
CutoutFoodBackgroundRemovalParams = dict
|
|
100
|
+
CutoutFoodBackgroundRemovalResponse = dict
|
|
101
|
+
CutoutProductBackgroundRemovalParams = dict
|
|
102
|
+
CutoutProductBackgroundRemovalResponse = dict
|
|
103
|
+
CutoutClothingBackgroundRemovalParams = dict
|
|
104
|
+
CutoutClothingBackgroundRemovalResponse = dict
|
|
105
|
+
CutoutHdHumanBodyBackgroundRemovalParams = dict
|
|
106
|
+
CutoutHdHumanBodyBackgroundRemovalResponse = dict
|
|
107
|
+
CutoutAvatarExtractionParams = dict
|
|
108
|
+
CutoutAvatarExtractionResponse = dict
|
|
109
|
+
CutoutHairExtractionParams = dict
|
|
110
|
+
CutoutHairExtractionResponse = dict
|
ailabtools/errors.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional, Any
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class ErrorDetail:
|
|
6
|
+
status_code: Optional[int] = None
|
|
7
|
+
code: Optional[str] = None
|
|
8
|
+
code_message: Optional[str] = None
|
|
9
|
+
message: Optional[str] = None
|
|
10
|
+
|
|
11
|
+
class AILabApiError(Exception):
|
|
12
|
+
def __init__(self, message: str, detail: Optional[ErrorDetail] = None, request_id: Optional[str] = None, log_id: Optional[str] = None, raw: Any = None):
|
|
13
|
+
super().__init__(message)
|
|
14
|
+
self.detail = detail
|
|
15
|
+
self.request_id = request_id
|
|
16
|
+
self.log_id = log_id
|
|
17
|
+
self.raw = raw
|
|
File without changes
|