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
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# v1.ai_face_editor
|
|
2
|
+
|
|
3
|
+
## Module Functions
|
|
4
|
+
|
|
5
|
+
<!-- CUSTOM DOCS START -->
|
|
6
|
+
|
|
7
|
+
### Ai Face Editor 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_face_editor.generate(
|
|
35
|
+
assets={"image_file_path": "/path/to/1234.png"},
|
|
36
|
+
style={
|
|
37
|
+
"enhance_face": False,
|
|
38
|
+
"eye_gaze_horizontal": 0.0,
|
|
39
|
+
"eye_gaze_vertical": 0.0,
|
|
40
|
+
"eye_open_ratio": 0.0,
|
|
41
|
+
"eyebrow_direction": 0.0,
|
|
42
|
+
"head_pitch": 0.0,
|
|
43
|
+
"head_roll": 0.0,
|
|
44
|
+
"head_yaw": 0.0,
|
|
45
|
+
"lip_open_ratio": 0.0,
|
|
46
|
+
"mouth_grim": 0.0,
|
|
47
|
+
"mouth_position_horizontal": 0.0,
|
|
48
|
+
"mouth_position_vertical": 0.0,
|
|
49
|
+
"mouth_pout": 0.0,
|
|
50
|
+
"mouth_purse": 0.0,
|
|
51
|
+
"mouth_smile": 0.0,
|
|
52
|
+
},
|
|
53
|
+
name="Face Editor image",
|
|
54
|
+
wait_for_completion=True,
|
|
55
|
+
download_outputs=True,
|
|
56
|
+
download_directory="outputs"
|
|
57
|
+
)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Asynchronous Client
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from magic_hour import AsyncClient
|
|
64
|
+
from os import getenv
|
|
65
|
+
|
|
66
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
67
|
+
res = await client.v1.ai_face_editor.generate(
|
|
68
|
+
assets={"image_file_path": "/path/to/1234.png"},
|
|
69
|
+
style={
|
|
70
|
+
"enhance_face": False,
|
|
71
|
+
"eye_gaze_horizontal": 0.0,
|
|
72
|
+
"eye_gaze_vertical": 0.0,
|
|
73
|
+
"eye_open_ratio": 0.0,
|
|
74
|
+
"eyebrow_direction": 0.0,
|
|
75
|
+
"head_pitch": 0.0,
|
|
76
|
+
"head_roll": 0.0,
|
|
77
|
+
"head_yaw": 0.0,
|
|
78
|
+
"lip_open_ratio": 0.0,
|
|
79
|
+
"mouth_grim": 0.0,
|
|
80
|
+
"mouth_position_horizontal": 0.0,
|
|
81
|
+
"mouth_position_vertical": 0.0,
|
|
82
|
+
"mouth_pout": 0.0,
|
|
83
|
+
"mouth_purse": 0.0,
|
|
84
|
+
"mouth_smile": 0.0,
|
|
85
|
+
},
|
|
86
|
+
name="Face Editor image",
|
|
87
|
+
wait_for_completion=True,
|
|
88
|
+
download_outputs=True,
|
|
89
|
+
download_directory="outputs"
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
<!-- CUSTOM DOCS END -->
|
|
94
|
+
|
|
95
|
+
### AI Face Editor <a name="create"></a>
|
|
96
|
+
|
|
97
|
+
Edit facial features of an image using AI. Each edit costs 1 frame. The height/width of the output image depends on your subscription. Please refer to our [pricing](/pricing) page for more details
|
|
98
|
+
|
|
99
|
+
**API Endpoint**: `POST /v1/ai-face-editor`
|
|
100
|
+
|
|
101
|
+
#### Parameters
|
|
102
|
+
|
|
103
|
+
| Parameter | Required | Description | Example |
|
|
104
|
+
| ------------------------------ | :------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
105
|
+
| `assets` | ✓ | Provide the assets for face editor | `{"image_file_path": "api-assets/id/1234.png"}` |
|
|
106
|
+
| `└─ image_file_path` | ✓ | This is the image whose face will be edited. 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/1234.png"` |
|
|
107
|
+
| `style` | ✓ | Face editing parameters | `{"enhance_face": False, "eye_gaze_horizontal": 0.0, "eye_gaze_vertical": 0.0, "eye_open_ratio": 0.0, "eyebrow_direction": 0.0, "head_pitch": 0.0, "head_roll": 0.0, "head_yaw": 0.0, "lip_open_ratio": 0.0, "mouth_grim": 0.0, "mouth_position_horizontal": 0.0, "mouth_position_vertical": 0.0, "mouth_pout": 0.0, "mouth_purse": 0.0, "mouth_smile": 0.0}` |
|
|
108
|
+
| `└─ enhance_face` | ✗ | Enhance face features | `False` |
|
|
109
|
+
| `└─ eye_gaze_horizontal` | ✗ | Horizontal eye gaze (-100 to 100), in increments of 5 | `0.0` |
|
|
110
|
+
| `└─ eye_gaze_vertical` | ✗ | Vertical eye gaze (-100 to 100), in increments of 5 | `0.0` |
|
|
111
|
+
| `└─ eye_open_ratio` | ✗ | Eye open ratio (-100 to 100), in increments of 5 | `0.0` |
|
|
112
|
+
| `└─ eyebrow_direction` | ✗ | Eyebrow direction (-100 to 100), in increments of 5 | `0.0` |
|
|
113
|
+
| `└─ head_pitch` | ✗ | Head pitch (-100 to 100), in increments of 5 | `0.0` |
|
|
114
|
+
| `└─ head_roll` | ✗ | Head roll (-100 to 100), in increments of 5 | `0.0` |
|
|
115
|
+
| `└─ head_yaw` | ✗ | Head yaw (-100 to 100), in increments of 5 | `0.0` |
|
|
116
|
+
| `└─ lip_open_ratio` | ✗ | Lip open ratio (-100 to 100), in increments of 5 | `0.0` |
|
|
117
|
+
| `└─ mouth_grim` | ✗ | Mouth grim (-100 to 100), in increments of 5 | `0.0` |
|
|
118
|
+
| `└─ mouth_position_horizontal` | ✗ | Horizontal mouth position (-100 to 100), in increments of 5 | `0.0` |
|
|
119
|
+
| `└─ mouth_position_vertical` | ✗ | Vertical mouth position (-100 to 100), in increments of 5 | `0.0` |
|
|
120
|
+
| `└─ mouth_pout` | ✗ | Mouth pout (-100 to 100), in increments of 5 | `0.0` |
|
|
121
|
+
| `└─ mouth_purse` | ✗ | Mouth purse (-100 to 100), in increments of 5 | `0.0` |
|
|
122
|
+
| `└─ mouth_smile` | ✗ | Mouth smile (-100 to 100), in increments of 5 | `0.0` |
|
|
123
|
+
| `name` | ✗ | The name of image. This value is mainly used for your own identification of the image. | `"Face Editor image"` |
|
|
124
|
+
|
|
125
|
+
#### Synchronous Client
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
from magic_hour import Client
|
|
129
|
+
from os import getenv
|
|
130
|
+
|
|
131
|
+
client = Client(token=getenv("API_TOKEN"))
|
|
132
|
+
res = client.v1.ai_face_editor.create(
|
|
133
|
+
assets={"image_file_path": "api-assets/id/1234.png"},
|
|
134
|
+
style={
|
|
135
|
+
"enhance_face": False,
|
|
136
|
+
"eye_gaze_horizontal": 0.0,
|
|
137
|
+
"eye_gaze_vertical": 0.0,
|
|
138
|
+
"eye_open_ratio": 0.0,
|
|
139
|
+
"eyebrow_direction": 0.0,
|
|
140
|
+
"head_pitch": 0.0,
|
|
141
|
+
"head_roll": 0.0,
|
|
142
|
+
"head_yaw": 0.0,
|
|
143
|
+
"lip_open_ratio": 0.0,
|
|
144
|
+
"mouth_grim": 0.0,
|
|
145
|
+
"mouth_position_horizontal": 0.0,
|
|
146
|
+
"mouth_position_vertical": 0.0,
|
|
147
|
+
"mouth_pout": 0.0,
|
|
148
|
+
"mouth_purse": 0.0,
|
|
149
|
+
"mouth_smile": 0.0,
|
|
150
|
+
},
|
|
151
|
+
name="Face Editor image",
|
|
152
|
+
)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### Asynchronous Client
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
from magic_hour import AsyncClient
|
|
159
|
+
from os import getenv
|
|
160
|
+
|
|
161
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
162
|
+
res = await client.v1.ai_face_editor.create(
|
|
163
|
+
assets={"image_file_path": "api-assets/id/1234.png"},
|
|
164
|
+
style={
|
|
165
|
+
"enhance_face": False,
|
|
166
|
+
"eye_gaze_horizontal": 0.0,
|
|
167
|
+
"eye_gaze_vertical": 0.0,
|
|
168
|
+
"eye_open_ratio": 0.0,
|
|
169
|
+
"eyebrow_direction": 0.0,
|
|
170
|
+
"head_pitch": 0.0,
|
|
171
|
+
"head_roll": 0.0,
|
|
172
|
+
"head_yaw": 0.0,
|
|
173
|
+
"lip_open_ratio": 0.0,
|
|
174
|
+
"mouth_grim": 0.0,
|
|
175
|
+
"mouth_position_horizontal": 0.0,
|
|
176
|
+
"mouth_position_vertical": 0.0,
|
|
177
|
+
"mouth_pout": 0.0,
|
|
178
|
+
"mouth_purse": 0.0,
|
|
179
|
+
"mouth_smile": 0.0,
|
|
180
|
+
},
|
|
181
|
+
name="Face Editor image",
|
|
182
|
+
)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### Response
|
|
186
|
+
|
|
187
|
+
##### Type
|
|
188
|
+
|
|
189
|
+
[V1AiFaceEditorCreateResponse](/magic_hour/types/models/v1_ai_face_editor_create_response.py)
|
|
190
|
+
|
|
191
|
+
##### Example
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
{"credits_charged": 1, "frame_cost": 1, "id": "cuid-example"}
|
|
195
|
+
```
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import typing
|
|
2
|
+
|
|
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 (
|
|
11
|
+
AsyncBaseClient,
|
|
12
|
+
RequestOptions,
|
|
13
|
+
SyncBaseClient,
|
|
14
|
+
default_request_options,
|
|
15
|
+
to_encodable,
|
|
16
|
+
type_utils,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
logger = get_sdk_logger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class AiFaceEditorClient:
|
|
24
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
25
|
+
self._base_client = base_client
|
|
26
|
+
|
|
27
|
+
def generate(
|
|
28
|
+
self,
|
|
29
|
+
*,
|
|
30
|
+
assets: params.V1AiFaceEditorGenerateBodyAssets,
|
|
31
|
+
style: params.V1AiFaceEditorCreateBodyStyle,
|
|
32
|
+
name: typing.Union[
|
|
33
|
+
typing.Optional[str], type_utils.NotGiven
|
|
34
|
+
] = type_utils.NOT_GIVEN,
|
|
35
|
+
wait_for_completion: bool = True,
|
|
36
|
+
download_outputs: bool = True,
|
|
37
|
+
download_directory: typing.Optional[str] = None,
|
|
38
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
39
|
+
):
|
|
40
|
+
"""
|
|
41
|
+
Generate face edited image (alias for create with additional functionality).
|
|
42
|
+
|
|
43
|
+
Edit facial features of an image using AI. Each edit costs 1 frame. The height/width of the output image depends on your subscription. Please refer to our [pricing](/pricing) page for more details
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
47
|
+
assets: Provide the assets for face editor
|
|
48
|
+
style: Face editing parameters
|
|
49
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
50
|
+
download_outputs: Whether to download the outputs
|
|
51
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
52
|
+
request_options: Additional options to customize the HTTP request
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI Face Editor API with the downloaded paths if `download_outputs` is True.
|
|
56
|
+
|
|
57
|
+
Examples:
|
|
58
|
+
```py
|
|
59
|
+
response = client.v1.ai_face_editor.generate(
|
|
60
|
+
assets={"image_file_path": "path/to/face.png"},
|
|
61
|
+
style={
|
|
62
|
+
"enhance_face": True,
|
|
63
|
+
"eye_gaze_horizontal": 0.2,
|
|
64
|
+
"eye_gaze_vertical": -0.1,
|
|
65
|
+
"eye_open_ratio": 0.8,
|
|
66
|
+
"eyebrow_direction": 0.3,
|
|
67
|
+
"head_pitch": 0.1,
|
|
68
|
+
"head_roll": 0.0,
|
|
69
|
+
"head_yaw": -0.2,
|
|
70
|
+
"lip_open_ratio": 0.0,
|
|
71
|
+
"mouth_grim": 0.0,
|
|
72
|
+
"mouth_position_horizontal": 0.0,
|
|
73
|
+
"mouth_position_vertical": 0.0,
|
|
74
|
+
"mouth_pout": 0.0,
|
|
75
|
+
"mouth_purse": 0.0,
|
|
76
|
+
"mouth_smile": 0.5,
|
|
77
|
+
},
|
|
78
|
+
name="Face Editor image",
|
|
79
|
+
wait_for_completion=True,
|
|
80
|
+
download_outputs=True,
|
|
81
|
+
download_directory="outputs/",
|
|
82
|
+
)
|
|
83
|
+
```
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
file_client = FilesClient(base_client=self._base_client)
|
|
87
|
+
|
|
88
|
+
image_file_path = assets["image_file_path"]
|
|
89
|
+
assets["image_file_path"] = file_client.upload_file(file=image_file_path)
|
|
90
|
+
|
|
91
|
+
create_response = self.create(
|
|
92
|
+
assets=assets, style=style, name=name, request_options=request_options
|
|
93
|
+
)
|
|
94
|
+
logger.info(f"AI Face Editor response: {create_response}")
|
|
95
|
+
|
|
96
|
+
image_projects_client = ImageProjectsClient(base_client=self._base_client)
|
|
97
|
+
response = image_projects_client.check_result(
|
|
98
|
+
id=create_response.id,
|
|
99
|
+
wait_for_completion=wait_for_completion,
|
|
100
|
+
download_outputs=download_outputs,
|
|
101
|
+
download_directory=download_directory,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
return response
|
|
105
|
+
|
|
106
|
+
def create(
|
|
107
|
+
self,
|
|
108
|
+
*,
|
|
109
|
+
assets: params.V1AiFaceEditorCreateBodyAssets,
|
|
110
|
+
style: params.V1AiFaceEditorCreateBodyStyle,
|
|
111
|
+
name: typing.Union[
|
|
112
|
+
typing.Optional[str], type_utils.NotGiven
|
|
113
|
+
] = type_utils.NOT_GIVEN,
|
|
114
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
115
|
+
) -> models.V1AiFaceEditorCreateResponse:
|
|
116
|
+
"""
|
|
117
|
+
AI Face Editor
|
|
118
|
+
|
|
119
|
+
Edit facial features of an image using AI. Each edit costs 1 frame. The height/width of the output image depends on your subscription. Please refer to our [pricing](/pricing) page for more details
|
|
120
|
+
|
|
121
|
+
POST /v1/ai-face-editor
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
125
|
+
assets: Provide the assets for face editor
|
|
126
|
+
style: Face editing parameters
|
|
127
|
+
request_options: Additional options to customize the HTTP request
|
|
128
|
+
|
|
129
|
+
Returns:
|
|
130
|
+
Success
|
|
131
|
+
|
|
132
|
+
Raises:
|
|
133
|
+
ApiError: A custom exception class that provides additional context
|
|
134
|
+
for API errors, including the HTTP status code and response body.
|
|
135
|
+
|
|
136
|
+
Examples:
|
|
137
|
+
```py
|
|
138
|
+
client.v1.ai_face_editor.create(
|
|
139
|
+
assets={"image_file_path": "api-assets/id/1234.png"},
|
|
140
|
+
style={
|
|
141
|
+
"enhance_face": False,
|
|
142
|
+
"eye_gaze_horizontal": 0.0,
|
|
143
|
+
"eye_gaze_vertical": 0.0,
|
|
144
|
+
"eye_open_ratio": 0.0,
|
|
145
|
+
"eyebrow_direction": 0.0,
|
|
146
|
+
"head_pitch": 0.0,
|
|
147
|
+
"head_roll": 0.0,
|
|
148
|
+
"head_yaw": 0.0,
|
|
149
|
+
"lip_open_ratio": 0.0,
|
|
150
|
+
"mouth_grim": 0.0,
|
|
151
|
+
"mouth_position_horizontal": 0.0,
|
|
152
|
+
"mouth_position_vertical": 0.0,
|
|
153
|
+
"mouth_pout": 0.0,
|
|
154
|
+
"mouth_purse": 0.0,
|
|
155
|
+
"mouth_smile": 0.0,
|
|
156
|
+
},
|
|
157
|
+
name="Face Editor image",
|
|
158
|
+
)
|
|
159
|
+
```
|
|
160
|
+
"""
|
|
161
|
+
_json = to_encodable(
|
|
162
|
+
item={"name": name, "assets": assets, "style": style},
|
|
163
|
+
dump_with=params._SerializerV1AiFaceEditorCreateBody,
|
|
164
|
+
)
|
|
165
|
+
return self._base_client.request(
|
|
166
|
+
method="POST",
|
|
167
|
+
path="/v1/ai-face-editor",
|
|
168
|
+
auth_names=["bearerAuth"],
|
|
169
|
+
json=_json,
|
|
170
|
+
cast_to=models.V1AiFaceEditorCreateResponse,
|
|
171
|
+
request_options=request_options or default_request_options(),
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
class AsyncAiFaceEditorClient:
|
|
176
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
177
|
+
self._base_client = base_client
|
|
178
|
+
|
|
179
|
+
async def generate(
|
|
180
|
+
self,
|
|
181
|
+
*,
|
|
182
|
+
assets: params.V1AiFaceEditorGenerateBodyAssets,
|
|
183
|
+
style: params.V1AiFaceEditorCreateBodyStyle,
|
|
184
|
+
name: typing.Union[
|
|
185
|
+
typing.Optional[str], type_utils.NotGiven
|
|
186
|
+
] = type_utils.NOT_GIVEN,
|
|
187
|
+
wait_for_completion: bool = True,
|
|
188
|
+
download_outputs: bool = True,
|
|
189
|
+
download_directory: typing.Optional[str] = None,
|
|
190
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
191
|
+
):
|
|
192
|
+
"""
|
|
193
|
+
Generate face edited image (alias for create with additional functionality).
|
|
194
|
+
|
|
195
|
+
Edit facial features of an image using AI. Each edit costs 1 frame. The height/width of the output image depends on your subscription. Please refer to our [pricing](/pricing) page for more details
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
199
|
+
assets: Provide the assets for face editor
|
|
200
|
+
style: Face editing parameters
|
|
201
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
202
|
+
download_outputs: Whether to download the outputs
|
|
203
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
204
|
+
request_options: Additional options to customize the HTTP request
|
|
205
|
+
|
|
206
|
+
Returns:
|
|
207
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the AI Face Editor API with the downloaded paths if `download_outputs` is True.
|
|
208
|
+
|
|
209
|
+
Examples:
|
|
210
|
+
```py
|
|
211
|
+
response = await client.v1.ai_face_editor.generate(
|
|
212
|
+
assets={"image_file_path": "path/to/face.png"},
|
|
213
|
+
style={
|
|
214
|
+
"enhance_face": True,
|
|
215
|
+
"eye_gaze_horizontal": 0.2,
|
|
216
|
+
"eye_gaze_vertical": -0.1,
|
|
217
|
+
"eye_open_ratio": 0.8,
|
|
218
|
+
"eyebrow_direction": 0.3,
|
|
219
|
+
"head_pitch": 0.1,
|
|
220
|
+
"head_roll": 0.0,
|
|
221
|
+
"head_yaw": -0.2,
|
|
222
|
+
"lip_open_ratio": 0.0,
|
|
223
|
+
"mouth_grim": 0.0,
|
|
224
|
+
"mouth_position_horizontal": 0.0,
|
|
225
|
+
"mouth_position_vertical": 0.0,
|
|
226
|
+
"mouth_pout": 0.0,
|
|
227
|
+
"mouth_purse": 0.0,
|
|
228
|
+
"mouth_smile": 0.5,
|
|
229
|
+
},
|
|
230
|
+
name="Face Editor image",
|
|
231
|
+
wait_for_completion=True,
|
|
232
|
+
download_outputs=True,
|
|
233
|
+
download_directory="outputs/",
|
|
234
|
+
)
|
|
235
|
+
```
|
|
236
|
+
"""
|
|
237
|
+
|
|
238
|
+
file_client = AsyncFilesClient(base_client=self._base_client)
|
|
239
|
+
|
|
240
|
+
image_file_path = assets["image_file_path"]
|
|
241
|
+
assets["image_file_path"] = await file_client.upload_file(file=image_file_path)
|
|
242
|
+
|
|
243
|
+
create_response = await self.create(
|
|
244
|
+
assets=assets, style=style, name=name, request_options=request_options
|
|
245
|
+
)
|
|
246
|
+
logger.info(f"AI Face Editor response: {create_response}")
|
|
247
|
+
|
|
248
|
+
image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
|
|
249
|
+
response = await image_projects_client.check_result(
|
|
250
|
+
id=create_response.id,
|
|
251
|
+
wait_for_completion=wait_for_completion,
|
|
252
|
+
download_outputs=download_outputs,
|
|
253
|
+
download_directory=download_directory,
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
return response
|
|
257
|
+
|
|
258
|
+
async def create(
|
|
259
|
+
self,
|
|
260
|
+
*,
|
|
261
|
+
assets: params.V1AiFaceEditorCreateBodyAssets,
|
|
262
|
+
style: params.V1AiFaceEditorCreateBodyStyle,
|
|
263
|
+
name: typing.Union[
|
|
264
|
+
typing.Optional[str], type_utils.NotGiven
|
|
265
|
+
] = type_utils.NOT_GIVEN,
|
|
266
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
267
|
+
) -> models.V1AiFaceEditorCreateResponse:
|
|
268
|
+
"""
|
|
269
|
+
AI Face Editor
|
|
270
|
+
|
|
271
|
+
Edit facial features of an image using AI. Each edit costs 1 frame. The height/width of the output image depends on your subscription. Please refer to our [pricing](/pricing) page for more details
|
|
272
|
+
|
|
273
|
+
POST /v1/ai-face-editor
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
277
|
+
assets: Provide the assets for face editor
|
|
278
|
+
style: Face editing parameters
|
|
279
|
+
request_options: Additional options to customize the HTTP request
|
|
280
|
+
|
|
281
|
+
Returns:
|
|
282
|
+
Success
|
|
283
|
+
|
|
284
|
+
Raises:
|
|
285
|
+
ApiError: A custom exception class that provides additional context
|
|
286
|
+
for API errors, including the HTTP status code and response body.
|
|
287
|
+
|
|
288
|
+
Examples:
|
|
289
|
+
```py
|
|
290
|
+
await client.v1.ai_face_editor.create(
|
|
291
|
+
assets={"image_file_path": "api-assets/id/1234.png"},
|
|
292
|
+
style={
|
|
293
|
+
"enhance_face": False,
|
|
294
|
+
"eye_gaze_horizontal": 0.0,
|
|
295
|
+
"eye_gaze_vertical": 0.0,
|
|
296
|
+
"eye_open_ratio": 0.0,
|
|
297
|
+
"eyebrow_direction": 0.0,
|
|
298
|
+
"head_pitch": 0.0,
|
|
299
|
+
"head_roll": 0.0,
|
|
300
|
+
"head_yaw": 0.0,
|
|
301
|
+
"lip_open_ratio": 0.0,
|
|
302
|
+
"mouth_grim": 0.0,
|
|
303
|
+
"mouth_position_horizontal": 0.0,
|
|
304
|
+
"mouth_position_vertical": 0.0,
|
|
305
|
+
"mouth_pout": 0.0,
|
|
306
|
+
"mouth_purse": 0.0,
|
|
307
|
+
"mouth_smile": 0.0,
|
|
308
|
+
},
|
|
309
|
+
name="Face Editor image",
|
|
310
|
+
)
|
|
311
|
+
```
|
|
312
|
+
"""
|
|
313
|
+
_json = to_encodable(
|
|
314
|
+
item={"name": name, "assets": assets, "style": style},
|
|
315
|
+
dump_with=params._SerializerV1AiFaceEditorCreateBody,
|
|
316
|
+
)
|
|
317
|
+
return await self._base_client.request(
|
|
318
|
+
method="POST",
|
|
319
|
+
path="/v1/ai-face-editor",
|
|
320
|
+
auth_names=["bearerAuth"],
|
|
321
|
+
json=_json,
|
|
322
|
+
cast_to=models.V1AiFaceEditorCreateResponse,
|
|
323
|
+
request_options=request_options or default_request_options(),
|
|
324
|
+
)
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# v1.ai_gif_generator
|
|
2
|
+
|
|
3
|
+
## Module Functions
|
|
4
|
+
|
|
5
|
+
<!-- CUSTOM DOCS START -->
|
|
6
|
+
|
|
7
|
+
### Ai Gif Generator 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_gif_generator.generate(
|
|
35
|
+
style={"prompt": "Cute dancing cat, pixel art"},
|
|
36
|
+
name="Ai Gif gif",
|
|
37
|
+
output_format="gif",
|
|
38
|
+
wait_for_completion=True,
|
|
39
|
+
download_outputs=True,
|
|
40
|
+
download_directory="outputs"
|
|
41
|
+
)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### Asynchronous Client
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from magic_hour import AsyncClient
|
|
48
|
+
from os import getenv
|
|
49
|
+
|
|
50
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
51
|
+
res = await client.v1.ai_gif_generator.generate(
|
|
52
|
+
style={"prompt": "Cute dancing cat, pixel art"},
|
|
53
|
+
name="Ai Gif gif",
|
|
54
|
+
output_format="gif",
|
|
55
|
+
wait_for_completion=True,
|
|
56
|
+
download_outputs=True,
|
|
57
|
+
download_directory="outputs"
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
<!-- CUSTOM DOCS END -->
|
|
62
|
+
|
|
63
|
+
### AI GIF Generator <a name="create"></a>
|
|
64
|
+
|
|
65
|
+
Create an AI GIF. Each GIF costs 50 credits.
|
|
66
|
+
|
|
67
|
+
**API Endpoint**: `POST /v1/ai-gif-generator`
|
|
68
|
+
|
|
69
|
+
#### Parameters
|
|
70
|
+
|
|
71
|
+
| Parameter | Required | Description | Example |
|
|
72
|
+
| --------------- | :------: | ---------------------------------------------------------------------------------- | ------------------------------------------- |
|
|
73
|
+
| `style` | ✓ | | `{"prompt": "Cute dancing cat, pixel art"}` |
|
|
74
|
+
| `└─ prompt` | ✓ | The prompt used for the GIF. | `"Cute dancing cat, pixel art"` |
|
|
75
|
+
| `name` | ✗ | The name of gif. This value is mainly used for your own identification of the gif. | `"Ai Gif gif"` |
|
|
76
|
+
| `output_format` | ✗ | The output file format for the generated animation. | `"gif"` |
|
|
77
|
+
|
|
78
|
+
#### Synchronous Client
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from magic_hour import Client
|
|
82
|
+
from os import getenv
|
|
83
|
+
|
|
84
|
+
client = Client(token=getenv("API_TOKEN"))
|
|
85
|
+
res = client.v1.ai_gif_generator.create(
|
|
86
|
+
style={"prompt": "Cute dancing cat, pixel art"},
|
|
87
|
+
name="Ai Gif gif",
|
|
88
|
+
output_format="gif",
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Asynchronous Client
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from magic_hour import AsyncClient
|
|
96
|
+
from os import getenv
|
|
97
|
+
|
|
98
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
99
|
+
res = await client.v1.ai_gif_generator.create(
|
|
100
|
+
style={"prompt": "Cute dancing cat, pixel art"},
|
|
101
|
+
name="Ai Gif gif",
|
|
102
|
+
output_format="gif",
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### Response
|
|
107
|
+
|
|
108
|
+
##### Type
|
|
109
|
+
|
|
110
|
+
[V1AiGifGeneratorCreateResponse](/magic_hour/types/models/v1_ai_gif_generator_create_response.py)
|
|
111
|
+
|
|
112
|
+
##### Example
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
{"credits_charged": 50, "frame_cost": 50, "id": "cuid-example"}
|
|
116
|
+
```
|