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,248 @@
|
|
|
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 PhotoColorizerClient:
|
|
24
|
+
def __init__(self, *, base_client: SyncBaseClient):
|
|
25
|
+
self._base_client = base_client
|
|
26
|
+
|
|
27
|
+
def generate(
|
|
28
|
+
self,
|
|
29
|
+
*,
|
|
30
|
+
assets: params.V1PhotoColorizerGenerateBodyAssets,
|
|
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 colorized photo (alias for create with additional functionality).
|
|
41
|
+
|
|
42
|
+
Colorize image. Each image 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 photo colorization
|
|
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 Photo Colorizer API with the downloaded paths if `download_outputs` is True.
|
|
54
|
+
|
|
55
|
+
Examples:
|
|
56
|
+
```py
|
|
57
|
+
response = client.v1.photo_colorizer.generate(
|
|
58
|
+
assets={"image_file_path": "path/to/black_white_photo.jpg"},
|
|
59
|
+
name="Colorized Photo",
|
|
60
|
+
wait_for_completion=True,
|
|
61
|
+
download_outputs=True,
|
|
62
|
+
download_directory="outputs/",
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
file_client = FilesClient(base_client=self._base_client)
|
|
68
|
+
|
|
69
|
+
image_file_path = assets["image_file_path"]
|
|
70
|
+
assets["image_file_path"] = file_client.upload_file(file=image_file_path)
|
|
71
|
+
|
|
72
|
+
create_response = self.create(
|
|
73
|
+
assets=assets, name=name, request_options=request_options
|
|
74
|
+
)
|
|
75
|
+
logger.info(f"Photo Colorizer response: {create_response}")
|
|
76
|
+
|
|
77
|
+
image_projects_client = ImageProjectsClient(base_client=self._base_client)
|
|
78
|
+
response = image_projects_client.check_result(
|
|
79
|
+
id=create_response.id,
|
|
80
|
+
wait_for_completion=wait_for_completion,
|
|
81
|
+
download_outputs=download_outputs,
|
|
82
|
+
download_directory=download_directory,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
return response
|
|
86
|
+
|
|
87
|
+
def create(
|
|
88
|
+
self,
|
|
89
|
+
*,
|
|
90
|
+
assets: params.V1PhotoColorizerCreateBodyAssets,
|
|
91
|
+
name: typing.Union[
|
|
92
|
+
typing.Optional[str], type_utils.NotGiven
|
|
93
|
+
] = type_utils.NOT_GIVEN,
|
|
94
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
95
|
+
) -> models.V1PhotoColorizerCreateResponse:
|
|
96
|
+
"""
|
|
97
|
+
Photo Colorizer
|
|
98
|
+
|
|
99
|
+
Colorize image. Each image costs 5 credits.
|
|
100
|
+
|
|
101
|
+
POST /v1/photo-colorizer
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
105
|
+
assets: Provide the assets for photo colorization
|
|
106
|
+
request_options: Additional options to customize the HTTP request
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
Success
|
|
110
|
+
|
|
111
|
+
Raises:
|
|
112
|
+
ApiError: A custom exception class that provides additional context
|
|
113
|
+
for API errors, including the HTTP status code and response body.
|
|
114
|
+
|
|
115
|
+
Examples:
|
|
116
|
+
```py
|
|
117
|
+
client.v1.photo_colorizer.create(
|
|
118
|
+
assets={"image_file_path": "api-assets/id/1234.png"},
|
|
119
|
+
name="Photo Colorizer image",
|
|
120
|
+
)
|
|
121
|
+
```
|
|
122
|
+
"""
|
|
123
|
+
_json = to_encodable(
|
|
124
|
+
item={"name": name, "assets": assets},
|
|
125
|
+
dump_with=params._SerializerV1PhotoColorizerCreateBody,
|
|
126
|
+
)
|
|
127
|
+
return self._base_client.request(
|
|
128
|
+
method="POST",
|
|
129
|
+
path="/v1/photo-colorizer",
|
|
130
|
+
auth_names=["bearerAuth"],
|
|
131
|
+
json=_json,
|
|
132
|
+
cast_to=models.V1PhotoColorizerCreateResponse,
|
|
133
|
+
request_options=request_options or default_request_options(),
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class AsyncPhotoColorizerClient:
|
|
138
|
+
def __init__(self, *, base_client: AsyncBaseClient):
|
|
139
|
+
self._base_client = base_client
|
|
140
|
+
|
|
141
|
+
async def generate(
|
|
142
|
+
self,
|
|
143
|
+
*,
|
|
144
|
+
assets: params.V1PhotoColorizerGenerateBodyAssets,
|
|
145
|
+
name: typing.Union[
|
|
146
|
+
typing.Optional[str], type_utils.NotGiven
|
|
147
|
+
] = type_utils.NOT_GIVEN,
|
|
148
|
+
wait_for_completion: bool = True,
|
|
149
|
+
download_outputs: bool = True,
|
|
150
|
+
download_directory: typing.Optional[str] = None,
|
|
151
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
152
|
+
):
|
|
153
|
+
"""
|
|
154
|
+
Generate colorized photo (alias for create with additional functionality).
|
|
155
|
+
|
|
156
|
+
Colorize image. Each image costs 5 credits.
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
160
|
+
assets: Provide the assets for photo colorization
|
|
161
|
+
wait_for_completion: Whether to wait for the image project to complete
|
|
162
|
+
download_outputs: Whether to download the outputs
|
|
163
|
+
download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
|
|
164
|
+
request_options: Additional options to customize the HTTP request
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
V1ImageProjectsGetResponseWithDownloads: The response from the Photo Colorizer API with the downloaded paths if `download_outputs` is True.
|
|
168
|
+
|
|
169
|
+
Examples:
|
|
170
|
+
```py
|
|
171
|
+
response = await client.v1.photo_colorizer.generate(
|
|
172
|
+
assets={"image_file_path": "path/to/black_white_photo.jpg"},
|
|
173
|
+
name="Colorized Photo",
|
|
174
|
+
wait_for_completion=True,
|
|
175
|
+
download_outputs=True,
|
|
176
|
+
download_directory="outputs/",
|
|
177
|
+
)
|
|
178
|
+
```
|
|
179
|
+
"""
|
|
180
|
+
|
|
181
|
+
file_client = AsyncFilesClient(base_client=self._base_client)
|
|
182
|
+
|
|
183
|
+
image_file_path = assets["image_file_path"]
|
|
184
|
+
assets["image_file_path"] = await file_client.upload_file(file=image_file_path)
|
|
185
|
+
|
|
186
|
+
create_response = await self.create(
|
|
187
|
+
assets=assets, name=name, request_options=request_options
|
|
188
|
+
)
|
|
189
|
+
logger.info(f"Photo Colorizer response: {create_response}")
|
|
190
|
+
|
|
191
|
+
image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
|
|
192
|
+
response = await image_projects_client.check_result(
|
|
193
|
+
id=create_response.id,
|
|
194
|
+
wait_for_completion=wait_for_completion,
|
|
195
|
+
download_outputs=download_outputs,
|
|
196
|
+
download_directory=download_directory,
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
return response
|
|
200
|
+
|
|
201
|
+
async def create(
|
|
202
|
+
self,
|
|
203
|
+
*,
|
|
204
|
+
assets: params.V1PhotoColorizerCreateBodyAssets,
|
|
205
|
+
name: typing.Union[
|
|
206
|
+
typing.Optional[str], type_utils.NotGiven
|
|
207
|
+
] = type_utils.NOT_GIVEN,
|
|
208
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
209
|
+
) -> models.V1PhotoColorizerCreateResponse:
|
|
210
|
+
"""
|
|
211
|
+
Photo Colorizer
|
|
212
|
+
|
|
213
|
+
Colorize image. Each image costs 5 credits.
|
|
214
|
+
|
|
215
|
+
POST /v1/photo-colorizer
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
name: The name of image. This value is mainly used for your own identification of the image.
|
|
219
|
+
assets: Provide the assets for photo colorization
|
|
220
|
+
request_options: Additional options to customize the HTTP request
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
Success
|
|
224
|
+
|
|
225
|
+
Raises:
|
|
226
|
+
ApiError: A custom exception class that provides additional context
|
|
227
|
+
for API errors, including the HTTP status code and response body.
|
|
228
|
+
|
|
229
|
+
Examples:
|
|
230
|
+
```py
|
|
231
|
+
await client.v1.photo_colorizer.create(
|
|
232
|
+
assets={"image_file_path": "api-assets/id/1234.png"},
|
|
233
|
+
name="Photo Colorizer image",
|
|
234
|
+
)
|
|
235
|
+
```
|
|
236
|
+
"""
|
|
237
|
+
_json = to_encodable(
|
|
238
|
+
item={"name": name, "assets": assets},
|
|
239
|
+
dump_with=params._SerializerV1PhotoColorizerCreateBody,
|
|
240
|
+
)
|
|
241
|
+
return await self._base_client.request(
|
|
242
|
+
method="POST",
|
|
243
|
+
path="/v1/photo-colorizer",
|
|
244
|
+
auth_names=["bearerAuth"],
|
|
245
|
+
json=_json,
|
|
246
|
+
cast_to=models.V1PhotoColorizerCreateResponse,
|
|
247
|
+
request_options=request_options or default_request_options(),
|
|
248
|
+
)
|
|
@@ -1,14 +1,89 @@
|
|
|
1
|
+
# v1.text_to_video
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
## Module Functions
|
|
4
|
+
|
|
5
|
+
<!-- CUSTOM DOCS START -->
|
|
6
|
+
|
|
7
|
+
### Text To Video 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.text_to_video.generate(
|
|
35
|
+
end_seconds=5.0,
|
|
36
|
+
orientation="landscape",
|
|
37
|
+
style={"prompt": "a dog running"},
|
|
38
|
+
name="Text To Video video",
|
|
39
|
+
resolution="720p",
|
|
40
|
+
wait_for_completion=True,
|
|
41
|
+
download_outputs=True,
|
|
42
|
+
download_directory="outputs"
|
|
43
|
+
)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Asynchronous Client
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from magic_hour import AsyncClient
|
|
50
|
+
from os import getenv
|
|
51
|
+
|
|
52
|
+
client = AsyncClient(token=getenv("API_TOKEN"))
|
|
53
|
+
res = await client.v1.text_to_video.generate(
|
|
54
|
+
end_seconds=5.0,
|
|
55
|
+
orientation="landscape",
|
|
56
|
+
style={"prompt": "a dog running"},
|
|
57
|
+
name="Text To Video video",
|
|
58
|
+
resolution="720p",
|
|
59
|
+
wait_for_completion=True,
|
|
60
|
+
download_outputs=True,
|
|
61
|
+
download_directory="outputs"
|
|
62
|
+
)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
<!-- CUSTOM DOCS END -->
|
|
66
|
+
|
|
67
|
+
### Text-to-Video <a name="create"></a>
|
|
4
68
|
|
|
5
69
|
Create a Text To Video video. The estimated frame cost is calculated using 30 FPS. This amount is deducted from your account balance when a video is queued. Once the video is complete, the cost will be updated based on the actual number of frames rendered.
|
|
6
|
-
|
|
7
|
-
Get more information about this mode at our [product page](/products/text-to-video).
|
|
8
|
-
|
|
70
|
+
|
|
71
|
+
Get more information about this mode at our [product page](https://magichour.ai/products/text-to-video).
|
|
9
72
|
|
|
10
73
|
**API Endpoint**: `POST /v1/text-to-video`
|
|
11
74
|
|
|
75
|
+
#### Parameters
|
|
76
|
+
|
|
77
|
+
| Parameter | Required | Description | Example |
|
|
78
|
+
| ----------------- | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
|
|
79
|
+
| `end_seconds` | ✓ | The total duration of the output video in seconds. The value must be greater than or equal to 5 seconds and less than or equal to 60 seconds. Note: For 480p resolution, the value must be either 5 or 10. | `5.0` |
|
|
80
|
+
| `orientation` | ✓ | Determines the orientation of the output video | `"landscape"` |
|
|
81
|
+
| `style` | ✓ | | `{"prompt": "a dog running"}` |
|
|
82
|
+
| `└─ prompt` | ✓ | The prompt used for the video. | `"a dog running"` |
|
|
83
|
+
| `└─ quality_mode` | ✗ | DEPRECATED: Please use `resolution` field instead. For backward compatibility: * `quick` maps to 720p resolution * `studio` maps to 1080p resolution This field will be removed in a future version. Use the `resolution` field to directly to specify the resolution. | `"quick"` |
|
|
84
|
+
| `name` | ✗ | The name of video. This value is mainly used for your own identification of the video. | `"Text To Video video"` |
|
|
85
|
+
| `resolution` | ✗ | Controls the output video resolution. Defaults to `720p` if not specified. 480p and 720p are available on Creator, Pro, or Business tiers. However, 1080p require Pro or Business tier. **Options:** - `480p` - Supports only 5 or 10 second videos. Output: 24fps. Cost: 120 credits per 5 seconds. - `720p` - Supports videos between 5-60 seconds. Output: 30fps. Cost: 300 credits per 5 seconds. - `1080p` - Supports videos between 5-60 seconds. Output: 30fps. Cost: 600 credits per 5 seconds. | `"720p"` |
|
|
86
|
+
|
|
12
87
|
#### Synchronous Client
|
|
13
88
|
|
|
14
89
|
```python
|
|
@@ -19,8 +94,9 @@ client = Client(token=getenv("API_TOKEN"))
|
|
|
19
94
|
res = client.v1.text_to_video.create(
|
|
20
95
|
end_seconds=5.0,
|
|
21
96
|
orientation="landscape",
|
|
22
|
-
style={"prompt": "
|
|
97
|
+
style={"prompt": "a dog running"},
|
|
23
98
|
name="Text To Video video",
|
|
99
|
+
resolution="720p",
|
|
24
100
|
)
|
|
25
101
|
```
|
|
26
102
|
|
|
@@ -34,7 +110,20 @@ client = AsyncClient(token=getenv("API_TOKEN"))
|
|
|
34
110
|
res = await client.v1.text_to_video.create(
|
|
35
111
|
end_seconds=5.0,
|
|
36
112
|
orientation="landscape",
|
|
37
|
-
style={"prompt": "
|
|
113
|
+
style={"prompt": "a dog running"},
|
|
38
114
|
name="Text To Video video",
|
|
115
|
+
resolution="720p",
|
|
39
116
|
)
|
|
40
117
|
```
|
|
118
|
+
|
|
119
|
+
#### Response
|
|
120
|
+
|
|
121
|
+
##### Type
|
|
122
|
+
|
|
123
|
+
[V1TextToVideoCreateResponse](/magic_hour/types/models/v1_text_to_video_create_response.py)
|
|
124
|
+
|
|
125
|
+
##### Example
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
{"credits_charged": 450, "estimated_frame_cost": 450, "id": "cuid-example"}
|
|
129
|
+
```
|