magic_hour 0.9.5__py3-none-any.whl → 0.44.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.
- magic_hour/README.md +34 -0
- magic_hour/__init__.py +1 -1
- magic_hour/client.py +8 -17
- magic_hour/environment.py +13 -1
- magic_hour/helpers/__init__.py +4 -0
- magic_hour/helpers/download.py +77 -0
- magic_hour/helpers/logger.py +8 -0
- magic_hour/resources/v1/README.md +32 -0
- magic_hour/resources/v1/ai_clothes_changer/README.md +94 -5
- magic_hour/resources/v1/ai_clothes_changer/client.py +161 -16
- magic_hour/resources/v1/ai_face_editor/README.md +195 -0
- magic_hour/resources/v1/ai_face_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_face_editor/client.py +324 -0
- magic_hour/resources/v1/ai_gif_generator/README.md +116 -0
- magic_hour/resources/v1/ai_gif_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_gif_generator/client.py +257 -0
- magic_hour/resources/v1/ai_headshot_generator/README.md +81 -3
- magic_hour/resources/v1/ai_headshot_generator/client.py +167 -18
- magic_hour/resources/v1/ai_image_editor/README.md +125 -0
- magic_hour/resources/v1/ai_image_editor/__init__.py +4 -0
- magic_hour/resources/v1/ai_image_editor/client.py +290 -0
- magic_hour/resources/v1/ai_image_generator/README.md +99 -5
- magic_hour/resources/v1/ai_image_generator/client.py +170 -24
- magic_hour/resources/v1/ai_image_upscaler/README.md +89 -3
- magic_hour/resources/v1/ai_image_upscaler/client.py +173 -20
- magic_hour/resources/v1/ai_meme_generator/README.md +129 -0
- magic_hour/resources/v1/ai_meme_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_meme_generator/client.py +253 -0
- magic_hour/resources/v1/ai_photo_editor/README.md +119 -4
- magic_hour/resources/v1/ai_photo_editor/client.py +199 -18
- magic_hour/resources/v1/ai_qr_code_generator/README.md +84 -3
- magic_hour/resources/v1/ai_qr_code_generator/client.py +140 -18
- magic_hour/resources/v1/ai_talking_photo/README.md +137 -0
- magic_hour/resources/v1/ai_talking_photo/__init__.py +4 -0
- magic_hour/resources/v1/ai_talking_photo/client.py +326 -0
- magic_hour/resources/v1/ai_voice_cloner/README.md +62 -0
- magic_hour/resources/v1/ai_voice_cloner/__init__.py +4 -0
- magic_hour/resources/v1/ai_voice_cloner/client.py +272 -0
- magic_hour/resources/v1/ai_voice_generator/README.md +112 -0
- magic_hour/resources/v1/ai_voice_generator/__init__.py +4 -0
- magic_hour/resources/v1/ai_voice_generator/client.py +241 -0
- magic_hour/resources/v1/animation/README.md +128 -6
- magic_hour/resources/v1/animation/client.py +247 -22
- magic_hour/resources/v1/audio_projects/README.md +135 -0
- magic_hour/resources/v1/audio_projects/__init__.py +12 -0
- magic_hour/resources/v1/audio_projects/client.py +310 -0
- magic_hour/resources/v1/audio_projects/client_test.py +520 -0
- magic_hour/resources/v1/auto_subtitle_generator/README.md +128 -0
- magic_hour/resources/v1/auto_subtitle_generator/__init__.py +4 -0
- magic_hour/resources/v1/auto_subtitle_generator/client.py +346 -0
- magic_hour/resources/v1/client.py +75 -1
- magic_hour/resources/v1/face_detection/README.md +157 -0
- magic_hour/resources/v1/face_detection/__init__.py +12 -0
- magic_hour/resources/v1/face_detection/client.py +380 -0
- magic_hour/resources/v1/face_swap/README.md +137 -9
- magic_hour/resources/v1/face_swap/client.py +329 -38
- magic_hour/resources/v1/face_swap_photo/README.md +118 -3
- magic_hour/resources/v1/face_swap_photo/client.py +199 -14
- magic_hour/resources/v1/files/README.md +39 -0
- magic_hour/resources/v1/files/client.py +351 -1
- magic_hour/resources/v1/files/client_test.py +414 -0
- magic_hour/resources/v1/files/upload_urls/README.md +38 -17
- magic_hour/resources/v1/files/upload_urls/client.py +38 -34
- magic_hour/resources/v1/image_background_remover/README.md +96 -5
- magic_hour/resources/v1/image_background_remover/client.py +151 -16
- magic_hour/resources/v1/image_projects/README.md +82 -10
- magic_hour/resources/v1/image_projects/__init__.py +10 -2
- magic_hour/resources/v1/image_projects/client.py +154 -16
- magic_hour/resources/v1/image_projects/client_test.py +527 -0
- magic_hour/resources/v1/image_to_video/README.md +96 -11
- magic_hour/resources/v1/image_to_video/client.py +282 -38
- magic_hour/resources/v1/lip_sync/README.md +112 -9
- magic_hour/resources/v1/lip_sync/client.py +288 -34
- magic_hour/resources/v1/photo_colorizer/README.md +107 -0
- magic_hour/resources/v1/photo_colorizer/__init__.py +4 -0
- magic_hour/resources/v1/photo_colorizer/client.py +248 -0
- magic_hour/resources/v1/text_to_video/README.md +96 -7
- magic_hour/resources/v1/text_to_video/client.py +204 -18
- magic_hour/resources/v1/video_projects/README.md +81 -9
- magic_hour/resources/v1/video_projects/__init__.py +10 -2
- magic_hour/resources/v1/video_projects/client.py +151 -14
- magic_hour/resources/v1/video_projects/client_test.py +527 -0
- magic_hour/resources/v1/video_to_video/README.md +119 -15
- magic_hour/resources/v1/video_to_video/client.py +299 -46
- magic_hour/types/models/__init__.py +92 -56
- magic_hour/types/models/v1_ai_clothes_changer_create_response.py +33 -0
- magic_hour/types/models/v1_ai_face_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_gif_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_headshot_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_image_upscaler_create_response.py +33 -0
- magic_hour/types/models/v1_ai_meme_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_photo_editor_create_response.py +33 -0
- magic_hour/types/models/v1_ai_qr_code_generator_create_response.py +33 -0
- magic_hour/types/models/v1_ai_talking_photo_create_response.py +35 -0
- magic_hour/types/models/v1_ai_voice_cloner_create_response.py +27 -0
- magic_hour/types/models/v1_ai_voice_generator_create_response.py +27 -0
- magic_hour/types/models/v1_animation_create_response.py +35 -0
- magic_hour/types/models/v1_audio_projects_get_response.py +72 -0
- magic_hour/types/models/v1_audio_projects_get_response_downloads_item.py +19 -0
- magic_hour/types/models/{get_v1_image_projects_id_response_error.py → v1_audio_projects_get_response_error.py} +2 -2
- magic_hour/types/models/v1_auto_subtitle_generator_create_response.py +35 -0
- magic_hour/types/models/v1_face_detection_create_response.py +25 -0
- magic_hour/types/models/v1_face_detection_get_response.py +45 -0
- magic_hour/types/models/v1_face_detection_get_response_faces_item.py +25 -0
- magic_hour/types/models/v1_face_swap_create_response.py +35 -0
- magic_hour/types/models/v1_face_swap_photo_create_response.py +33 -0
- magic_hour/types/models/v1_files_upload_urls_create_response.py +24 -0
- magic_hour/types/models/{post_v1_files_upload_urls_response_items_item.py → v1_files_upload_urls_create_response_items_item.py} +2 -2
- magic_hour/types/models/v1_image_background_remover_create_response.py +33 -0
- magic_hour/types/models/{get_v1_image_projects_id_response.py → v1_image_projects_get_response.py} +20 -18
- magic_hour/types/models/{get_v1_video_projects_id_response_downloads_item.py → v1_image_projects_get_response_downloads_item.py} +1 -1
- magic_hour/types/models/{get_v1_video_projects_id_response_error.py → v1_image_projects_get_response_error.py} +2 -2
- magic_hour/types/models/v1_image_to_video_create_response.py +35 -0
- magic_hour/types/models/v1_lip_sync_create_response.py +35 -0
- magic_hour/types/models/v1_photo_colorizer_create_response.py +33 -0
- magic_hour/types/models/v1_text_to_video_create_response.py +35 -0
- magic_hour/types/models/{get_v1_video_projects_id_response.py → v1_video_projects_get_response.py} +26 -23
- magic_hour/types/models/{get_v1_video_projects_id_response_download.py → v1_video_projects_get_response_download.py} +1 -1
- magic_hour/types/models/{get_v1_image_projects_id_response_downloads_item.py → v1_video_projects_get_response_downloads_item.py} +1 -1
- magic_hour/types/models/v1_video_projects_get_response_error.py +25 -0
- magic_hour/types/models/v1_video_to_video_create_response.py +35 -0
- magic_hour/types/params/__init__.py +422 -176
- magic_hour/types/params/v1_ai_clothes_changer_create_body.py +40 -0
- magic_hour/types/params/v1_ai_clothes_changer_create_body_assets.py +58 -0
- magic_hour/types/params/v1_ai_clothes_changer_generate_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_face_editor_create_body.py +52 -0
- magic_hour/types/params/v1_ai_face_editor_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_face_editor_create_body_style.py +137 -0
- magic_hour/types/params/v1_ai_face_editor_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_gif_generator_create_body.py +47 -0
- magic_hour/types/params/{post_v1_ai_image_generator_body_style.py → v1_ai_gif_generator_create_body_style.py} +5 -5
- magic_hour/types/params/v1_ai_headshot_generator_create_body.py +49 -0
- magic_hour/types/params/v1_ai_headshot_generator_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_headshot_generator_create_body_style.py +27 -0
- magic_hour/types/params/v1_ai_headshot_generator_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_image_editor_create_body.py +49 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_assets.py +47 -0
- magic_hour/types/params/v1_ai_image_editor_create_body_style.py +41 -0
- magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +28 -0
- magic_hour/types/params/{post_v1_ai_image_generator_body.py → v1_ai_image_generator_create_body.py} +17 -11
- magic_hour/types/params/v1_ai_image_generator_create_body_style.py +127 -0
- magic_hour/types/params/v1_ai_image_upscaler_create_body.py +59 -0
- magic_hour/types/params/v1_ai_image_upscaler_create_body_assets.py +33 -0
- magic_hour/types/params/{post_v1_ai_image_upscaler_body_style.py → v1_ai_image_upscaler_create_body_style.py} +4 -4
- magic_hour/types/params/v1_ai_image_upscaler_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_meme_generator_create_body.py +37 -0
- magic_hour/types/params/v1_ai_meme_generator_create_body_style.py +73 -0
- magic_hour/types/params/{post_v1_ai_photo_editor_body.py → v1_ai_photo_editor_create_body.py} +15 -15
- magic_hour/types/params/v1_ai_photo_editor_create_body_assets.py +33 -0
- magic_hour/types/params/{post_v1_ai_photo_editor_body_style.py → v1_ai_photo_editor_create_body_style.py} +20 -4
- magic_hour/types/params/v1_ai_photo_editor_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_ai_qr_code_generator_create_body.py +45 -0
- magic_hour/types/params/{post_v1_ai_qr_code_generator_body_style.py → v1_ai_qr_code_generator_create_body_style.py} +4 -4
- magic_hour/types/params/v1_ai_talking_photo_create_body.py +68 -0
- magic_hour/types/params/v1_ai_talking_photo_create_body_assets.py +46 -0
- magic_hour/types/params/v1_ai_talking_photo_create_body_style.py +44 -0
- magic_hour/types/params/v1_ai_talking_photo_generate_body_assets.py +26 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body.py +49 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body_assets.py +33 -0
- magic_hour/types/params/v1_ai_voice_cloner_create_body_style.py +28 -0
- magic_hour/types/params/v1_ai_voice_cloner_generate_body_assets.py +28 -0
- magic_hour/types/params/v1_ai_voice_generator_create_body.py +40 -0
- magic_hour/types/params/v1_ai_voice_generator_create_body_style.py +440 -0
- magic_hour/types/params/{post_v1_animation_body.py → v1_animation_create_body.py} +16 -16
- magic_hour/types/params/{post_v1_animation_body_assets.py → v1_animation_create_body_assets.py} +15 -5
- magic_hour/types/params/{post_v1_animation_body_style.py → v1_animation_create_body_style.py} +13 -10
- magic_hour/types/params/v1_animation_generate_body_assets.py +39 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body.py +78 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_assets.py +33 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_style.py +56 -0
- magic_hour/types/params/v1_auto_subtitle_generator_create_body_style_custom_config.py +86 -0
- magic_hour/types/params/v1_auto_subtitle_generator_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_face_detection_create_body.py +44 -0
- magic_hour/types/params/v1_face_detection_create_body_assets.py +33 -0
- magic_hour/types/params/v1_face_detection_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_face_swap_create_body.py +92 -0
- magic_hour/types/params/v1_face_swap_create_body_assets.py +91 -0
- magic_hour/types/params/v1_face_swap_create_body_assets_face_mappings_item.py +44 -0
- magic_hour/types/params/v1_face_swap_create_body_style.py +33 -0
- magic_hour/types/params/v1_face_swap_generate_body_assets.py +56 -0
- magic_hour/types/params/v1_face_swap_generate_body_assets_face_mappings_item.py +25 -0
- magic_hour/types/params/v1_face_swap_photo_create_body.py +40 -0
- magic_hour/types/params/v1_face_swap_photo_create_body_assets.py +76 -0
- magic_hour/types/params/v1_face_swap_photo_create_body_assets_face_mappings_item.py +44 -0
- magic_hour/types/params/v1_face_swap_photo_generate_body_assets.py +47 -0
- magic_hour/types/params/v1_face_swap_photo_generate_body_assets_face_mappings_item.py +25 -0
- magic_hour/types/params/v1_files_upload_urls_create_body.py +36 -0
- magic_hour/types/params/v1_files_upload_urls_create_body_items_item.py +38 -0
- magic_hour/types/params/v1_image_background_remover_create_body.py +40 -0
- magic_hour/types/params/v1_image_background_remover_create_body_assets.py +49 -0
- magic_hour/types/params/v1_image_background_remover_generate_body_assets.py +27 -0
- magic_hour/types/params/v1_image_to_video_create_body.py +101 -0
- magic_hour/types/params/v1_image_to_video_create_body_assets.py +33 -0
- magic_hour/types/params/v1_image_to_video_create_body_style.py +53 -0
- magic_hour/types/params/v1_image_to_video_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_lip_sync_create_body.py +100 -0
- magic_hour/types/params/{post_v1_lip_sync_body_assets.py → v1_lip_sync_create_body_assets.py} +15 -5
- magic_hour/types/params/v1_lip_sync_create_body_style.py +37 -0
- magic_hour/types/params/v1_lip_sync_generate_body_assets.py +36 -0
- magic_hour/types/params/v1_photo_colorizer_create_body.py +40 -0
- magic_hour/types/params/v1_photo_colorizer_create_body_assets.py +33 -0
- magic_hour/types/params/v1_photo_colorizer_generate_body_assets.py +17 -0
- magic_hour/types/params/v1_text_to_video_create_body.py +78 -0
- magic_hour/types/params/v1_text_to_video_create_body_style.py +43 -0
- magic_hour/types/params/v1_video_to_video_create_body.py +101 -0
- magic_hour/types/params/{post_v1_video_to_video_body_assets.py → v1_video_to_video_create_body_assets.py} +9 -4
- magic_hour/types/params/{post_v1_video_to_video_body_style.py → v1_video_to_video_create_body_style.py} +68 -26
- magic_hour/types/params/v1_video_to_video_generate_body_assets.py +27 -0
- magic_hour-0.44.0.dist-info/METADATA +328 -0
- magic_hour-0.44.0.dist-info/RECORD +231 -0
- magic_hour/core/__init__.py +0 -52
- magic_hour/core/api_error.py +0 -56
- magic_hour/core/auth.py +0 -314
- magic_hour/core/base_client.py +0 -618
- magic_hour/core/binary_response.py +0 -23
- magic_hour/core/query.py +0 -106
- magic_hour/core/request.py +0 -156
- magic_hour/core/response.py +0 -293
- magic_hour/core/type_utils.py +0 -28
- magic_hour/core/utils.py +0 -55
- magic_hour/types/models/post_v1_ai_clothes_changer_response.py +0 -25
- magic_hour/types/models/post_v1_ai_headshot_generator_response.py +0 -25
- magic_hour/types/models/post_v1_ai_image_generator_response.py +0 -25
- magic_hour/types/models/post_v1_ai_image_upscaler_response.py +0 -25
- magic_hour/types/models/post_v1_ai_photo_editor_response.py +0 -25
- magic_hour/types/models/post_v1_ai_qr_code_generator_response.py +0 -25
- magic_hour/types/models/post_v1_animation_response.py +0 -25
- magic_hour/types/models/post_v1_face_swap_photo_response.py +0 -25
- magic_hour/types/models/post_v1_face_swap_response.py +0 -25
- magic_hour/types/models/post_v1_files_upload_urls_response.py +0 -21
- magic_hour/types/models/post_v1_image_background_remover_response.py +0 -25
- magic_hour/types/models/post_v1_image_to_video_response.py +0 -25
- magic_hour/types/models/post_v1_lip_sync_response.py +0 -25
- magic_hour/types/models/post_v1_text_to_video_response.py +0 -25
- magic_hour/types/models/post_v1_video_to_video_response.py +0 -25
- magic_hour/types/params/post_v1_ai_clothes_changer_body.py +0 -40
- magic_hour/types/params/post_v1_ai_clothes_changer_body_assets.py +0 -45
- magic_hour/types/params/post_v1_ai_headshot_generator_body.py +0 -40
- magic_hour/types/params/post_v1_ai_headshot_generator_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_image_upscaler_body.py +0 -57
- magic_hour/types/params/post_v1_ai_image_upscaler_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_photo_editor_body_assets.py +0 -28
- magic_hour/types/params/post_v1_ai_qr_code_generator_body.py +0 -45
- magic_hour/types/params/post_v1_face_swap_body.py +0 -72
- magic_hour/types/params/post_v1_face_swap_body_assets.py +0 -52
- magic_hour/types/params/post_v1_face_swap_photo_body.py +0 -40
- magic_hour/types/params/post_v1_face_swap_photo_body_assets.py +0 -36
- magic_hour/types/params/post_v1_files_upload_urls_body.py +0 -31
- magic_hour/types/params/post_v1_files_upload_urls_body_items_item.py +0 -38
- magic_hour/types/params/post_v1_image_background_remover_body.py +0 -40
- magic_hour/types/params/post_v1_image_background_remover_body_assets.py +0 -28
- magic_hour/types/params/post_v1_image_to_video_body.py +0 -73
- magic_hour/types/params/post_v1_image_to_video_body_assets.py +0 -28
- magic_hour/types/params/post_v1_image_to_video_body_style.py +0 -37
- magic_hour/types/params/post_v1_lip_sync_body.py +0 -80
- magic_hour/types/params/post_v1_text_to_video_body.py +0 -57
- magic_hour/types/params/post_v1_text_to_video_body_style.py +0 -28
- magic_hour/types/params/post_v1_video_to_video_body.py +0 -93
- magic_hour-0.9.5.dist-info/METADATA +0 -133
- magic_hour-0.9.5.dist-info/RECORD +0 -132
- {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/LICENSE +0 -0
- {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/WHEEL +0 -0
magic_hour/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Base Client
|
|
2
|
+
|
|
3
|
+
## Submodules
|
|
4
|
+
|
|
5
|
+
- [ai_clothes_changer](resources/v1/ai_clothes_changer/README.md) - ai_clothes_changer
|
|
6
|
+
- [ai_face_editor](resources/v1/ai_face_editor/README.md) - ai_face_editor
|
|
7
|
+
- [ai_gif_generator](resources/v1/ai_gif_generator/README.md) - ai_gif_generator
|
|
8
|
+
- [ai_headshot_generator](resources/v1/ai_headshot_generator/README.md) - ai_headshot_generator
|
|
9
|
+
- [ai_image_editor](resources/v1/ai_image_editor/README.md) - ai_image_editor
|
|
10
|
+
- [ai_image_generator](resources/v1/ai_image_generator/README.md) - ai_image_generator
|
|
11
|
+
- [ai_image_upscaler](resources/v1/ai_image_upscaler/README.md) - ai_image_upscaler
|
|
12
|
+
- [ai_meme_generator](resources/v1/ai_meme_generator/README.md) - ai_meme_generator
|
|
13
|
+
- [ai_photo_editor](resources/v1/ai_photo_editor/README.md) - ai_photo_editor
|
|
14
|
+
- [ai_qr_code_generator](resources/v1/ai_qr_code_generator/README.md) - ai_qr_code_generator
|
|
15
|
+
- [ai_talking_photo](resources/v1/ai_talking_photo/README.md) - ai_talking_photo
|
|
16
|
+
- [ai_voice_cloner](resources/v1/ai_voice_cloner/README.md) - ai_voice_cloner
|
|
17
|
+
- [ai_voice_generator](resources/v1/ai_voice_generator/README.md) - ai_voice_generator
|
|
18
|
+
- [animation](resources/v1/animation/README.md) - animation
|
|
19
|
+
- [audio_projects](resources/v1/audio_projects/README.md) - audio_projects
|
|
20
|
+
- [auto_subtitle_generator](resources/v1/auto_subtitle_generator/README.md) - auto_subtitle_generator
|
|
21
|
+
- [face_detection](resources/v1/face_detection/README.md) - face_detection
|
|
22
|
+
- [face_swap](resources/v1/face_swap/README.md) - face_swap
|
|
23
|
+
- [face_swap_photo](resources/v1/face_swap_photo/README.md) - face_swap_photo
|
|
24
|
+
- [upload_urls](resources/v1/files/upload_urls/README.md) - upload_urls
|
|
25
|
+
- [files](resources/v1/files/README.md) - files
|
|
26
|
+
- [image_background_remover](resources/v1/image_background_remover/README.md) - image_background_remover
|
|
27
|
+
- [image_projects](resources/v1/image_projects/README.md) - image_projects
|
|
28
|
+
- [image_to_video](resources/v1/image_to_video/README.md) - image_to_video
|
|
29
|
+
- [lip_sync](resources/v1/lip_sync/README.md) - lip_sync
|
|
30
|
+
- [photo_colorizer](resources/v1/photo_colorizer/README.md) - photo_colorizer
|
|
31
|
+
- [text_to_video](resources/v1/text_to_video/README.md) - text_to_video
|
|
32
|
+
- [video_projects](resources/v1/video_projects/README.md) - video_projects
|
|
33
|
+
- [video_to_video](resources/v1/video_to_video/README.md) - video_to_video
|
|
34
|
+
- [v1](resources/v1/README.md) - v1
|
magic_hour/__init__.py
CHANGED
magic_hour/client.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import httpx
|
|
2
2
|
import typing
|
|
3
3
|
|
|
4
|
-
from magic_hour.
|
|
5
|
-
from magic_hour.environment import Environment
|
|
4
|
+
from magic_hour.environment import Environment, _get_base_url
|
|
6
5
|
from magic_hour.resources.v1 import AsyncV1Client, V1Client
|
|
6
|
+
from make_api_request import AsyncBaseClient, AuthBearer, SyncBaseClient
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
class Client:
|
|
10
10
|
def __init__(
|
|
11
11
|
self,
|
|
12
12
|
*,
|
|
13
|
-
base_url: typing.Optional[str] = None,
|
|
14
13
|
timeout: typing.Optional[float] = 60,
|
|
15
14
|
httpx_client: typing.Optional[httpx.Client] = None,
|
|
15
|
+
base_url: typing.Optional[str] = None,
|
|
16
16
|
environment: Environment = Environment.ENVIRONMENT,
|
|
17
17
|
token: typing.Optional[str] = None,
|
|
18
18
|
):
|
|
@@ -22,8 +22,9 @@ class Client:
|
|
|
22
22
|
httpx_client=httpx.Client(timeout=timeout)
|
|
23
23
|
if httpx_client is None
|
|
24
24
|
else httpx_client,
|
|
25
|
+
auths={"bearerAuth": AuthBearer(token=token)},
|
|
25
26
|
)
|
|
26
|
-
|
|
27
|
+
|
|
27
28
|
self.v1 = V1Client(base_client=self._base_client)
|
|
28
29
|
|
|
29
30
|
|
|
@@ -31,9 +32,9 @@ class AsyncClient:
|
|
|
31
32
|
def __init__(
|
|
32
33
|
self,
|
|
33
34
|
*,
|
|
34
|
-
base_url: typing.Optional[str] = None,
|
|
35
35
|
timeout: typing.Optional[float] = 60,
|
|
36
36
|
httpx_client: typing.Optional[httpx.AsyncClient] = None,
|
|
37
|
+
base_url: typing.Optional[str] = None,
|
|
37
38
|
environment: Environment = Environment.ENVIRONMENT,
|
|
38
39
|
token: typing.Optional[str] = None,
|
|
39
40
|
):
|
|
@@ -43,17 +44,7 @@ class AsyncClient:
|
|
|
43
44
|
httpx_client=httpx.AsyncClient(timeout=timeout)
|
|
44
45
|
if httpx_client is None
|
|
45
46
|
else httpx_client,
|
|
47
|
+
auths={"bearerAuth": AuthBearer(token=token)},
|
|
46
48
|
)
|
|
47
|
-
self._base_client.register_auth("bearerAuth", AuthBearer(val=token))
|
|
48
|
-
self.v1 = AsyncV1Client(base_client=self._base_client)
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
def _get_base_url(
|
|
52
|
-
*, base_url: typing.Optional[str] = None, environment: Environment
|
|
53
|
-
) -> str:
|
|
54
|
-
if base_url is not None:
|
|
55
|
-
return base_url
|
|
56
|
-
elif environment is not None:
|
|
57
|
-
return environment.value
|
|
58
|
-
else:
|
|
59
|
-
raise Exception("Must include a base_url or environment arguments")
|
|
50
|
+
self.v1 = AsyncV1Client(base_client=self._base_client)
|
magic_hour/environment.py
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import enum
|
|
2
|
+
import typing
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class Environment(enum.Enum):
|
|
5
6
|
"""Pre-defined base URLs for the API"""
|
|
6
7
|
|
|
7
8
|
ENVIRONMENT = "https://api.magichour.ai"
|
|
8
|
-
MOCK_SERVER = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.
|
|
9
|
+
MOCK_SERVER = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.43.1"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _get_base_url(
|
|
13
|
+
*, base_url: typing.Optional[str] = None, environment: Environment
|
|
14
|
+
) -> str:
|
|
15
|
+
if base_url is not None:
|
|
16
|
+
return base_url
|
|
17
|
+
elif environment is not None:
|
|
18
|
+
return environment.value
|
|
19
|
+
else:
|
|
20
|
+
raise Exception("Must include a base_url or environment arguments")
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Union, List
|
|
4
|
+
from urllib.parse import urlparse
|
|
5
|
+
import httpx
|
|
6
|
+
from magic_hour.types import models
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _compute_download_path(
|
|
13
|
+
url: str, download_directory: Union[str, None] = None
|
|
14
|
+
) -> str:
|
|
15
|
+
url_path = urlparse(url).path
|
|
16
|
+
filename = Path(url_path).name
|
|
17
|
+
if download_directory:
|
|
18
|
+
return os.path.join(download_directory, filename)
|
|
19
|
+
return filename
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def download_files_sync(
|
|
23
|
+
downloads: Union[
|
|
24
|
+
List[models.V1ImageProjectsGetResponseDownloadsItem],
|
|
25
|
+
List[models.V1VideoProjectsGetResponseDownloadsItem],
|
|
26
|
+
List[models.V1AudioProjectsGetResponseDownloadsItem],
|
|
27
|
+
],
|
|
28
|
+
download_directory: Union[str, None] = None,
|
|
29
|
+
) -> List[str]:
|
|
30
|
+
downloaded_paths: List[str] = []
|
|
31
|
+
|
|
32
|
+
for download in downloads:
|
|
33
|
+
with httpx.Client() as http_client:
|
|
34
|
+
download_response = http_client.get(download.url)
|
|
35
|
+
download_response.raise_for_status()
|
|
36
|
+
|
|
37
|
+
download_path = _compute_download_path(
|
|
38
|
+
download.url, download_directory=download_directory
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
with open(download_path, "wb") as f:
|
|
42
|
+
f.write(download_response.content)
|
|
43
|
+
|
|
44
|
+
downloaded_paths.append(download_path)
|
|
45
|
+
|
|
46
|
+
logger.info(f"Downloaded file saved as: {download_path}")
|
|
47
|
+
|
|
48
|
+
return downloaded_paths
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
async def download_files_async(
|
|
52
|
+
downloads: Union[
|
|
53
|
+
List[models.V1ImageProjectsGetResponseDownloadsItem],
|
|
54
|
+
List[models.V1VideoProjectsGetResponseDownloadsItem],
|
|
55
|
+
List[models.V1AudioProjectsGetResponseDownloadsItem],
|
|
56
|
+
],
|
|
57
|
+
download_directory: Union[str, None] = None,
|
|
58
|
+
) -> List[str]:
|
|
59
|
+
downloaded_paths: List[str] = []
|
|
60
|
+
|
|
61
|
+
for download in downloads:
|
|
62
|
+
async with httpx.AsyncClient() as http_client:
|
|
63
|
+
download_response = await http_client.get(download.url)
|
|
64
|
+
download_response.raise_for_status()
|
|
65
|
+
|
|
66
|
+
download_path = _compute_download_path(
|
|
67
|
+
download.url, download_directory=download_directory
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
with open(download_path, "wb") as f:
|
|
71
|
+
f.write(download_response.content)
|
|
72
|
+
|
|
73
|
+
downloaded_paths.append(download_path)
|
|
74
|
+
|
|
75
|
+
logger.info(f"Downloaded file saved as: {download_path}")
|
|
76
|
+
|
|
77
|
+
return downloaded_paths
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# v1
|
|
2
|
+
|
|
3
|
+
## Submodules
|
|
4
|
+
|
|
5
|
+
- [ai_clothes_changer](ai_clothes_changer/README.md) - ai_clothes_changer
|
|
6
|
+
- [ai_face_editor](ai_face_editor/README.md) - ai_face_editor
|
|
7
|
+
- [ai_gif_generator](ai_gif_generator/README.md) - ai_gif_generator
|
|
8
|
+
- [ai_headshot_generator](ai_headshot_generator/README.md) - ai_headshot_generator
|
|
9
|
+
- [ai_image_editor](ai_image_editor/README.md) - ai_image_editor
|
|
10
|
+
- [ai_image_generator](ai_image_generator/README.md) - ai_image_generator
|
|
11
|
+
- [ai_image_upscaler](ai_image_upscaler/README.md) - ai_image_upscaler
|
|
12
|
+
- [ai_meme_generator](ai_meme_generator/README.md) - ai_meme_generator
|
|
13
|
+
- [ai_photo_editor](ai_photo_editor/README.md) - ai_photo_editor
|
|
14
|
+
- [ai_qr_code_generator](ai_qr_code_generator/README.md) - ai_qr_code_generator
|
|
15
|
+
- [ai_talking_photo](ai_talking_photo/README.md) - ai_talking_photo
|
|
16
|
+
- [ai_voice_cloner](ai_voice_cloner/README.md) - ai_voice_cloner
|
|
17
|
+
- [ai_voice_generator](ai_voice_generator/README.md) - ai_voice_generator
|
|
18
|
+
- [animation](animation/README.md) - animation
|
|
19
|
+
- [audio_projects](audio_projects/README.md) - audio_projects
|
|
20
|
+
- [auto_subtitle_generator](auto_subtitle_generator/README.md) - auto_subtitle_generator
|
|
21
|
+
- [face_detection](face_detection/README.md) - face_detection
|
|
22
|
+
- [face_swap](face_swap/README.md) - face_swap
|
|
23
|
+
- [face_swap_photo](face_swap_photo/README.md) - face_swap_photo
|
|
24
|
+
- [files](files/README.md) - files
|
|
25
|
+
- [image_background_remover](image_background_remover/README.md) - image_background_remover
|
|
26
|
+
- [image_projects](image_projects/README.md) - image_projects
|
|
27
|
+
- [image_to_video](image_to_video/README.md) - image_to_video
|
|
28
|
+
- [lip_sync](lip_sync/README.md) - lip_sync
|
|
29
|
+
- [photo_colorizer](photo_colorizer/README.md) - photo_colorizer
|
|
30
|
+
- [text_to_video](text_to_video/README.md) - text_to_video
|
|
31
|
+
- [video_projects](video_projects/README.md) - video_projects
|
|
32
|
+
- [video_to_video](video_to_video/README.md) - video_to_video
|
|
@@ -1,11 +1,88 @@
|
|
|
1
|
+
# v1.ai_clothes_changer
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
AI Clothes Changer
|
|
3
|
+
## Module Functions
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<!-- CUSTOM DOCS START -->
|
|
6
|
+
|
|
7
|
+
### AI Clothes Changer Generate Workflow <a name="generate"></a>
|
|
8
|
+
|
|
9
|
+
The workflow performs the following action
|
|
10
|
+
|
|
11
|
+
1. upload local assets to Magic Hour storage. So you can pass in a local path instead of having to upload files yourself
|
|
12
|
+
2. trigger a generation
|
|
13
|
+
3. poll for a completion status. This is configurable
|
|
14
|
+
4. if success, download the output to local directory
|
|
15
|
+
|
|
16
|
+
> [!TIP]
|
|
17
|
+
> This is the recommended way to use the SDK unless you have specific needs where it is necessary to split up the actions.
|
|
18
|
+
|
|
19
|
+
#### Parameters
|
|
20
|
+
|
|
21
|
+
In Additional to the parameters listed in the `.create` section below, `.generate` introduces 3 new parameters:
|
|
22
|
+
|
|
23
|
+
- `wait_for_completion` (bool, default True): Whether to wait for the project to complete.
|
|
24
|
+
- `download_outputs` (bool, default True): Whether to download the generated files
|
|
25
|
+
- `download_directory` (str, optional): Directory to save downloaded files (defaults to current directory)
|
|
26
|
+
|
|
27
|
+
#### Synchronous Client
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from magic_hour import Client
|
|
31
|
+
from os import getenv
|
|
32
|
+
|
|
33
|
+
client = Client(token=getenv("API_TOKEN"))
|
|
34
|
+
res = client.v1.ai_clothes_changer.generate(
|
|
35
|
+
assets={
|
|
36
|
+
"garment_file_path": "/path/to/outfit.png",
|
|
37
|
+
"garment_type": "upper_body",
|
|
38
|
+
"person_file_path": "/path/to/model.png",
|
|
39
|
+
},
|
|
40
|
+
name="Clothes Changer image",
|
|
41
|
+
wait_for_completion=True,
|
|
42
|
+
download_outputs=True,
|
|
43
|
+
download_directory="outputs",
|
|
44
|
+
)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Asynchronous Client
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from magic_hour import AsyncClient
|
|
51
|
+
from os import getenv
|
|
52
|
+
|
|
53
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
54
|
+
res = await client.v1.ai_clothes_changer.generate(
|
|
55
|
+
assets={
|
|
56
|
+
"garment_file_path": "/path/to/outfit.png",
|
|
57
|
+
"garment_type": "upper_body",
|
|
58
|
+
"person_file_path": "/path/to/model.png",
|
|
59
|
+
},
|
|
60
|
+
name="Clothes Changer image",
|
|
61
|
+
download_directory="outputs",
|
|
62
|
+
wait_for_completion=True,
|
|
63
|
+
download_outputs=True,
|
|
64
|
+
download_directory="outputs",
|
|
65
|
+
)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
<!-- CUSTOM DOCS END -->
|
|
69
|
+
|
|
70
|
+
### AI Clothes Changer <a name="create"></a>
|
|
71
|
+
|
|
72
|
+
Change outfits in photos in seconds with just a photo reference. Each photo costs 25 credits.
|
|
6
73
|
|
|
7
74
|
**API Endpoint**: `POST /v1/ai-clothes-changer`
|
|
8
75
|
|
|
76
|
+
#### Parameters
|
|
77
|
+
|
|
78
|
+
| Parameter | Required | Description | Example |
|
|
79
|
+
| ---------------------- | :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| `assets` | ✓ | Provide the assets for clothes changer | `{"garment_file_path": "api-assets/id/outfit.png", "garment_type": "upper_body", "person_file_path": "api-assets/id/model.png"}` |
|
|
81
|
+
| `└─ garment_file_path` | ✓ | The image of the outfit. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more. | `"api-assets/id/outfit.png"` |
|
|
82
|
+
| `└─ garment_type` | ✓ | The type of the outfit. | `"upper_body"` |
|
|
83
|
+
| `└─ person_file_path` | ✓ | The image with the person. This value is either - a direct URL to the video file - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls). Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more. | `"api-assets/id/model.png"` |
|
|
84
|
+
| `name` | ✗ | The name of image. This value is mainly used for your own identification of the image. | `"Clothes Changer image"` |
|
|
85
|
+
|
|
9
86
|
#### Synchronous Client
|
|
10
87
|
|
|
11
88
|
```python
|
|
@@ -16,7 +93,7 @@ client = Client(token=getenv("API_TOKEN"))
|
|
|
16
93
|
res = client.v1.ai_clothes_changer.create(
|
|
17
94
|
assets={
|
|
18
95
|
"garment_file_path": "api-assets/id/outfit.png",
|
|
19
|
-
"garment_type": "
|
|
96
|
+
"garment_type": "upper_body",
|
|
20
97
|
"person_file_path": "api-assets/id/model.png",
|
|
21
98
|
},
|
|
22
99
|
name="Clothes Changer image",
|
|
@@ -33,9 +110,21 @@ client = AsyncClient(token=getenv("API_TOKEN"))
|
|
|
33
110
|
res = await client.v1.ai_clothes_changer.create(
|
|
34
111
|
assets={
|
|
35
112
|
"garment_file_path": "api-assets/id/outfit.png",
|
|
36
|
-
"garment_type": "
|
|
113
|
+
"garment_type": "upper_body",
|
|
37
114
|
"person_file_path": "api-assets/id/model.png",
|
|
38
115
|
},
|
|
39
116
|
name="Clothes Changer image",
|
|
40
117
|
)
|
|
41
118
|
```
|
|
119
|
+
|
|
120
|
+
#### Response
|
|
121
|
+
|
|
122
|
+
##### Type
|
|
123
|
+
|
|
124
|
+
[V1AiClothesChangerCreateResponse](/magic_hour/types/models/v1_ai_clothes_changer_create_response.py)
|
|
125
|
+
|
|
126
|
+
##### Example
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
{"credits_charged": 25, "frame_cost": 25, "id": "cuid-example"}
|
|
130
|
+
```
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import typing
|
|
2
2
|
|
|
3
|
-
from magic_hour.
|
|
3
|
+
from magic_hour.helpers.logger import get_sdk_logger
|
|
4
|
+
from magic_hour.resources.v1.files.client import AsyncFilesClient, FilesClient
|
|
5
|
+
from magic_hour.resources.v1.image_projects.client import (
|
|
6
|
+
AsyncImageProjectsClient,
|
|
7
|
+
ImageProjectsClient,
|
|
8
|
+
)
|
|
9
|
+
from magic_hour.types import models, params
|
|
10
|
+
from make_api_request import (
|
|
4
11
|
AsyncBaseClient,
|
|
5
12
|
RequestOptions,
|
|
6
13
|
SyncBaseClient,
|
|
@@ -8,31 +15,99 @@ from magic_hour.core import (
|
|
|
8
15
|
to_encodable,
|
|
9
16
|
type_utils,
|
|
10
17
|
)
|
|
11
|
-
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
logger = get_sdk_logger(__name__)
|
|
12
21
|
|
|
13
22
|
|
|
14
23
|
class AiClothesChangerClient:
|
|
15
24
|
def __init__(self, *, base_client: SyncBaseClient):
|
|
16
25
|
self._base_client = base_client
|
|
17
26
|
|
|
27
|
+
def generate(
|
|
28
|
+
self,
|
|
29
|
+
*,
|
|
30
|
+
assets: params.V1AiClothesChangerGenerateBodyAssets,
|
|
31
|
+
name: typing.Union[
|
|
32
|
+
typing.Optional[str], type_utils.NotGiven
|
|
33
|
+
] = type_utils.NOT_GIVEN,
|
|
34
|
+
wait_for_completion: bool = True,
|
|
35
|
+
download_outputs: bool = True,
|
|
36
|
+
download_directory: typing.Optional[str] = None,
|
|
37
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
38
|
+
):
|
|
39
|
+
"""
|
|
40
|
+
Generate clothes changed image (alias for create with additional functionality).
|
|
41
|
+
|
|
42
|
+
Change clothes in an image using AI. Each change costs 5 credits.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
46
|
+
assets: Provide the assets for clothes changer
|
|
47
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
48
|
+
download_outputs: Whether to download the outputs
|
|
49
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
50
|
+
request_options: Additional options to customize the HTTP request
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI Clothes Changer API with the downloaded paths if `download_outputs` is True.
|
|
54
|
+
|
|
55
|
+
Examples:
|
|
56
|
+
```py
|
|
57
|
+
response = client.v1.ai_clothes_changer.generate(
|
|
58
|
+
assets={
|
|
59
|
+
"garment_file_path": "path/to/outfit.png",
|
|
60
|
+
"garment_type": "upper_body",
|
|
61
|
+
"person_file_path": "path/to/model.png",
|
|
62
|
+
},
|
|
63
|
+
name="Clothes Changer image",
|
|
64
|
+
wait_for_completion=True,
|
|
65
|
+
download_outputs=True,
|
|
66
|
+
download_directory="outputs/",
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
file_client = FilesClient(base_client=self._base_client)
|
|
72
|
+
|
|
73
|
+
garment_file_path = assets["garment_file_path"]
|
|
74
|
+
person_file_path = assets["person_file_path"]
|
|
75
|
+
assets["garment_file_path"] = file_client.upload_file(file=garment_file_path)
|
|
76
|
+
assets["person_file_path"] = file_client.upload_file(file=person_file_path)
|
|
77
|
+
|
|
78
|
+
create_response = self.create(
|
|
79
|
+
assets=assets, name=name, request_options=request_options
|
|
80
|
+
)
|
|
81
|
+
logger.info(f"AI Clothes Changer response: {create_response}")
|
|
82
|
+
|
|
83
|
+
image_projects_client = ImageProjectsClient(base_client=self._base_client)
|
|
84
|
+
response = image_projects_client.check_result(
|
|
85
|
+
id=create_response.id,
|
|
86
|
+
wait_for_completion=wait_for_completion,
|
|
87
|
+
download_outputs=download_outputs,
|
|
88
|
+
download_directory=download_directory,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
return response
|
|
92
|
+
|
|
18
93
|
def create(
|
|
19
94
|
self,
|
|
20
95
|
*,
|
|
21
|
-
assets: params.
|
|
96
|
+
assets: params.V1AiClothesChangerCreateBodyAssets,
|
|
22
97
|
name: typing.Union[
|
|
23
98
|
typing.Optional[str], type_utils.NotGiven
|
|
24
99
|
] = type_utils.NOT_GIVEN,
|
|
25
100
|
request_options: typing.Optional[RequestOptions] = None,
|
|
26
|
-
) -> models.
|
|
101
|
+
) -> models.V1AiClothesChangerCreateResponse:
|
|
27
102
|
"""
|
|
28
103
|
AI Clothes Changer
|
|
29
104
|
|
|
30
|
-
Change outfits in photos in seconds with just a photo reference. Each photo costs 25
|
|
105
|
+
Change outfits in photos in seconds with just a photo reference. Each photo costs 25 credits.
|
|
31
106
|
|
|
32
107
|
POST /v1/ai-clothes-changer
|
|
33
108
|
|
|
34
109
|
Args:
|
|
35
|
-
name: The name of image
|
|
110
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
36
111
|
assets: Provide the assets for clothes changer
|
|
37
112
|
request_options: Additional options to customize the HTTP request
|
|
38
113
|
|
|
@@ -48,7 +123,7 @@ class AiClothesChangerClient:
|
|
|
48
123
|
client.v1.ai_clothes_changer.create(
|
|
49
124
|
assets={
|
|
50
125
|
"garment_file_path": "api-assets/id/outfit.png",
|
|
51
|
-
"garment_type": "
|
|
126
|
+
"garment_type": "upper_body",
|
|
52
127
|
"person_file_path": "api-assets/id/model.png",
|
|
53
128
|
},
|
|
54
129
|
name="Clothes Changer image",
|
|
@@ -57,14 +132,14 @@ class AiClothesChangerClient:
|
|
|
57
132
|
"""
|
|
58
133
|
_json = to_encodable(
|
|
59
134
|
item={"name": name, "assets": assets},
|
|
60
|
-
dump_with=params.
|
|
135
|
+
dump_with=params._SerializerV1AiClothesChangerCreateBody,
|
|
61
136
|
)
|
|
62
137
|
return self._base_client.request(
|
|
63
138
|
method="POST",
|
|
64
139
|
path="/v1/ai-clothes-changer",
|
|
65
140
|
auth_names=["bearerAuth"],
|
|
66
141
|
json=_json,
|
|
67
|
-
cast_to=models.
|
|
142
|
+
cast_to=models.V1AiClothesChangerCreateResponse,
|
|
68
143
|
request_options=request_options or default_request_options(),
|
|
69
144
|
)
|
|
70
145
|
|
|
@@ -73,24 +148,94 @@ class AsyncAiClothesChangerClient:
|
|
|
73
148
|
def __init__(self, *, base_client: AsyncBaseClient):
|
|
74
149
|
self._base_client = base_client
|
|
75
150
|
|
|
151
|
+
async def generate(
|
|
152
|
+
self,
|
|
153
|
+
*,
|
|
154
|
+
assets: params.V1AiClothesChangerGenerateBodyAssets,
|
|
155
|
+
name: typing.Union[
|
|
156
|
+
typing.Optional[str], type_utils.NotGiven
|
|
157
|
+
] = type_utils.NOT_GIVEN,
|
|
158
|
+
wait_for_completion: bool = True,
|
|
159
|
+
download_outputs: bool = True,
|
|
160
|
+
download_directory: typing.Optional[str] = None,
|
|
161
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
162
|
+
):
|
|
163
|
+
"""
|
|
164
|
+
Generate clothes changed image (alias for create with additional functionality).
|
|
165
|
+
|
|
166
|
+
Change clothes in an image using AI. Each change costs 5 credits.
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
170
|
+
assets: Provide the assets for clothes changer
|
|
171
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
172
|
+
download_outputs: Whether to download the outputs
|
|
173
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
174
|
+
request_options: Additional options to customize the HTTP request
|
|
175
|
+
|
|
176
|
+
Returns:
|
|
177
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI Clothes Changer API with the downloaded paths if `download_outputs` is True.
|
|
178
|
+
|
|
179
|
+
Examples:
|
|
180
|
+
```py
|
|
181
|
+
response = await client.v1.ai_clothes_changer.generate(
|
|
182
|
+
assets={
|
|
183
|
+
"garment_file_path": "path/to/outfit.png",
|
|
184
|
+
"garment_type": "upper_body",
|
|
185
|
+
"person_file_path": "path/to/model.png",
|
|
186
|
+
},
|
|
187
|
+
name="Clothes Changer image",
|
|
188
|
+
wait_for_completion=True,
|
|
189
|
+
download_outputs=True,
|
|
190
|
+
download_directory="outputs/",
|
|
191
|
+
)
|
|
192
|
+
```
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
file_client = AsyncFilesClient(base_client=self._base_client)
|
|
196
|
+
|
|
197
|
+
garment_file_path = assets["garment_file_path"]
|
|
198
|
+
person_file_path = assets["person_file_path"]
|
|
199
|
+
assets["garment_file_path"] = await file_client.upload_file(
|
|
200
|
+
file=garment_file_path
|
|
201
|
+
)
|
|
202
|
+
assets["person_file_path"] = await file_client.upload_file(
|
|
203
|
+
file=person_file_path
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
create_response = await self.create(
|
|
207
|
+
assets=assets, name=name, request_options=request_options
|
|
208
|
+
)
|
|
209
|
+
logger.info(f"AI Clothes Changer response: {create_response}")
|
|
210
|
+
|
|
211
|
+
image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
|
|
212
|
+
response = await image_projects_client.check_result(
|
|
213
|
+
id=create_response.id,
|
|
214
|
+
wait_for_completion=wait_for_completion,
|
|
215
|
+
download_outputs=download_outputs,
|
|
216
|
+
download_directory=download_directory,
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
return response
|
|
220
|
+
|
|
76
221
|
async def create(
|
|
77
222
|
self,
|
|
78
223
|
*,
|
|
79
|
-
assets: params.
|
|
224
|
+
assets: params.V1AiClothesChangerCreateBodyAssets,
|
|
80
225
|
name: typing.Union[
|
|
81
226
|
typing.Optional[str], type_utils.NotGiven
|
|
82
227
|
] = type_utils.NOT_GIVEN,
|
|
83
228
|
request_options: typing.Optional[RequestOptions] = None,
|
|
84
|
-
) -> models.
|
|
229
|
+
) -> models.V1AiClothesChangerCreateResponse:
|
|
85
230
|
"""
|
|
86
231
|
AI Clothes Changer
|
|
87
232
|
|
|
88
|
-
Change outfits in photos in seconds with just a photo reference. Each photo costs 25
|
|
233
|
+
Change outfits in photos in seconds with just a photo reference. Each photo costs 25 credits.
|
|
89
234
|
|
|
90
235
|
POST /v1/ai-clothes-changer
|
|
91
236
|
|
|
92
237
|
Args:
|
|
93
|
-
name: The name of image
|
|
238
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
94
239
|
assets: Provide the assets for clothes changer
|
|
95
240
|
request_options: Additional options to customize the HTTP request
|
|
96
241
|
|
|
@@ -106,7 +251,7 @@ class AsyncAiClothesChangerClient:
|
|
|
106
251
|
await client.v1.ai_clothes_changer.create(
|
|
107
252
|
assets={
|
|
108
253
|
"garment_file_path": "api-assets/id/outfit.png",
|
|
109
|
-
"garment_type": "
|
|
254
|
+
"garment_type": "upper_body",
|
|
110
255
|
"person_file_path": "api-assets/id/model.png",
|
|
111
256
|
},
|
|
112
257
|
name="Clothes Changer image",
|
|
@@ -115,13 +260,13 @@ class AsyncAiClothesChangerClient:
|
|
|
115
260
|
"""
|
|
116
261
|
_json = to_encodable(
|
|
117
262
|
item={"name": name, "assets": assets},
|
|
118
|
-
dump_with=params.
|
|
263
|
+
dump_with=params._SerializerV1AiClothesChangerCreateBody,
|
|
119
264
|
)
|
|
120
265
|
return await self._base_client.request(
|
|
121
266
|
method="POST",
|
|
122
267
|
path="/v1/ai-clothes-changer",
|
|
123
268
|
auth_names=["bearerAuth"],
|
|
124
269
|
json=_json,
|
|
125
|
-
cast_to=models.
|
|
270
|
+
cast_to=models.V1AiClothesChangerCreateResponse,
|
|
126
271
|
request_options=request_options or default_request_options(),
|
|
127
272
|
)
|