magic_hour 0.35.0__py3-none-any.whl → 0.36.1__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.

Potentially problematic release.


This version of magic_hour might be problematic. Click here for more details.

Files changed (94) hide show
  1. magic_hour/README.md +35 -0
  2. magic_hour/core/base_client.py +6 -5
  3. magic_hour/core/query.py +12 -6
  4. magic_hour/core/request.py +3 -3
  5. magic_hour/core/response.py +18 -14
  6. magic_hour/core/utils.py +3 -3
  7. magic_hour/environment.py +1 -1
  8. magic_hour/helpers/__init__.py +3 -0
  9. magic_hour/helpers/download.py +75 -0
  10. magic_hour/resources/v1/README.md +33 -0
  11. magic_hour/resources/v1/ai_clothes_changer/README.md +73 -0
  12. magic_hour/resources/v1/ai_clothes_changer/client.py +146 -0
  13. magic_hour/resources/v1/ai_face_editor/README.md +110 -0
  14. magic_hour/resources/v1/ai_face_editor/client.py +168 -0
  15. magic_hour/resources/v1/ai_gif_generator/README.md +59 -0
  16. magic_hour/resources/v1/ai_gif_generator/client.py +119 -0
  17. magic_hour/resources/v1/ai_headshot_generator/README.md +60 -0
  18. magic_hour/resources/v1/ai_headshot_generator/client.py +140 -0
  19. magic_hour/resources/v1/ai_image_editor/README.md +64 -0
  20. magic_hour/resources/v1/ai_image_editor/client.py +136 -0
  21. magic_hour/resources/v1/ai_image_generator/README.md +66 -0
  22. magic_hour/resources/v1/ai_image_generator/client.py +139 -0
  23. magic_hour/resources/v1/ai_image_upscaler/README.md +67 -0
  24. magic_hour/resources/v1/ai_image_upscaler/client.py +150 -0
  25. magic_hour/resources/v1/ai_meme_generator/README.md +71 -0
  26. magic_hour/resources/v1/ai_meme_generator/client.py +127 -0
  27. magic_hour/resources/v1/ai_photo_editor/README.md +98 -7
  28. magic_hour/resources/v1/ai_photo_editor/client.py +174 -0
  29. magic_hour/resources/v1/ai_qr_code_generator/README.md +63 -0
  30. magic_hour/resources/v1/ai_qr_code_generator/client.py +123 -0
  31. magic_hour/resources/v1/ai_talking_photo/README.md +74 -0
  32. magic_hour/resources/v1/ai_talking_photo/client.py +170 -0
  33. magic_hour/resources/v1/animation/README.md +100 -0
  34. magic_hour/resources/v1/animation/client.py +218 -0
  35. magic_hour/resources/v1/auto_subtitle_generator/README.md +69 -0
  36. magic_hour/resources/v1/auto_subtitle_generator/client.py +178 -0
  37. magic_hour/resources/v1/face_detection/README.md +59 -0
  38. magic_hour/resources/v1/face_detection/__init__.py +10 -2
  39. magic_hour/resources/v1/face_detection/client.py +179 -0
  40. magic_hour/resources/v1/face_swap/README.md +105 -8
  41. magic_hour/resources/v1/face_swap/client.py +242 -0
  42. magic_hour/resources/v1/face_swap_photo/README.md +84 -0
  43. magic_hour/resources/v1/face_swap_photo/client.py +172 -0
  44. magic_hour/resources/v1/files/README.md +40 -0
  45. magic_hour/resources/v1/files/client.py +350 -0
  46. magic_hour/resources/v1/files/client_test.py +414 -0
  47. magic_hour/resources/v1/files/upload_urls/README.md +8 -0
  48. magic_hour/resources/v1/image_background_remover/README.md +68 -0
  49. magic_hour/resources/v1/image_background_remover/client.py +130 -0
  50. magic_hour/resources/v1/image_projects/README.md +52 -0
  51. magic_hour/resources/v1/image_projects/__init__.py +10 -2
  52. magic_hour/resources/v1/image_projects/client.py +138 -0
  53. magic_hour/resources/v1/image_projects/client_test.py +527 -0
  54. magic_hour/resources/v1/image_to_video/README.md +77 -9
  55. magic_hour/resources/v1/image_to_video/client.py +186 -0
  56. magic_hour/resources/v1/lip_sync/README.md +87 -9
  57. magic_hour/resources/v1/lip_sync/client.py +210 -0
  58. magic_hour/resources/v1/photo_colorizer/README.md +59 -0
  59. magic_hour/resources/v1/photo_colorizer/client.py +130 -0
  60. magic_hour/resources/v1/text_to_video/README.md +68 -0
  61. magic_hour/resources/v1/text_to_video/client.py +151 -0
  62. magic_hour/resources/v1/video_projects/README.md +52 -0
  63. magic_hour/resources/v1/video_projects/__init__.py +10 -2
  64. magic_hour/resources/v1/video_projects/client.py +137 -0
  65. magic_hour/resources/v1/video_projects/client_test.py +527 -0
  66. magic_hour/resources/v1/video_to_video/README.md +98 -10
  67. magic_hour/resources/v1/video_to_video/client.py +222 -0
  68. magic_hour/types/params/__init__.py +58 -0
  69. magic_hour/types/params/v1_ai_clothes_changer_generate_body_assets.py +33 -0
  70. magic_hour/types/params/v1_ai_face_editor_generate_body_assets.py +17 -0
  71. magic_hour/types/params/v1_ai_headshot_generator_generate_body_assets.py +17 -0
  72. magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +17 -0
  73. magic_hour/types/params/v1_ai_image_upscaler_generate_body_assets.py +17 -0
  74. magic_hour/types/params/v1_ai_photo_editor_generate_body_assets.py +17 -0
  75. magic_hour/types/params/v1_ai_talking_photo_generate_body_assets.py +26 -0
  76. magic_hour/types/params/v1_animation_generate_body_assets.py +39 -0
  77. magic_hour/types/params/v1_auto_subtitle_generator_generate_body_assets.py +17 -0
  78. magic_hour/types/params/v1_face_detection_generate_body_assets.py +17 -0
  79. magic_hour/types/params/v1_face_swap_create_body.py +12 -0
  80. magic_hour/types/params/v1_face_swap_create_body_style.py +33 -0
  81. magic_hour/types/params/v1_face_swap_generate_body_assets.py +56 -0
  82. magic_hour/types/params/v1_face_swap_generate_body_assets_face_mappings_item.py +25 -0
  83. magic_hour/types/params/v1_face_swap_photo_generate_body_assets.py +47 -0
  84. magic_hour/types/params/v1_face_swap_photo_generate_body_assets_face_mappings_item.py +25 -0
  85. magic_hour/types/params/v1_image_background_remover_generate_body_assets.py +27 -0
  86. magic_hour/types/params/v1_image_to_video_generate_body_assets.py +17 -0
  87. magic_hour/types/params/v1_lip_sync_generate_body_assets.py +36 -0
  88. magic_hour/types/params/v1_photo_colorizer_generate_body_assets.py +17 -0
  89. magic_hour/types/params/v1_video_to_video_generate_body_assets.py +27 -0
  90. magic_hour-0.36.1.dist-info/METADATA +306 -0
  91. {magic_hour-0.35.0.dist-info → magic_hour-0.36.1.dist-info}/RECORD +93 -65
  92. magic_hour-0.35.0.dist-info/METADATA +0 -166
  93. {magic_hour-0.35.0.dist-info → magic_hour-0.36.1.dist-info}/LICENSE +0 -0
  94. {magic_hour-0.35.0.dist-info → magic_hour-0.36.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,17 @@
1
+ import pydantic
2
+ import typing_extensions
3
+
4
+
5
+ class V1AutoSubtitleGeneratorGenerateBodyAssets(typing_extensions.TypedDict):
6
+ """
7
+ Provide the assets for auto subtitle generator
8
+ """
9
+
10
+ video_file_path: typing_extensions.Required[str]
11
+ """
12
+ This is the video used to add subtitles. This value is either
13
+ - a direct URL to the video file
14
+ - a path to a local file
15
+
16
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
17
+ """
@@ -0,0 +1,17 @@
1
+ import pydantic
2
+ import typing_extensions
3
+
4
+
5
+ class V1FaceDetectionGenerateBodyAssets(typing_extensions.TypedDict):
6
+ """
7
+ Provide the assets for face detection
8
+ """
9
+
10
+ target_file_path: typing_extensions.Required[str]
11
+ """
12
+ This is the image or video where the face will be detected. This value is either
13
+ - a direct URL to the image file
14
+ - a path to a local file
15
+
16
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
17
+ """
@@ -6,6 +6,10 @@ from .v1_face_swap_create_body_assets import (
6
6
  V1FaceSwapCreateBodyAssets,
7
7
  _SerializerV1FaceSwapCreateBodyAssets,
8
8
  )
9
+ from .v1_face_swap_create_body_style import (
10
+ V1FaceSwapCreateBodyStyle,
11
+ _SerializerV1FaceSwapCreateBodyStyle,
12
+ )
9
13
 
10
14
 
11
15
  class V1FaceSwapCreateBody(typing_extensions.TypedDict):
@@ -44,6 +48,11 @@ class V1FaceSwapCreateBody(typing_extensions.TypedDict):
44
48
  The start time of the input video in seconds. This value is used to trim the input video. The value must be greater than 0.
45
49
  """
46
50
 
51
+ style: typing_extensions.NotRequired[V1FaceSwapCreateBodyStyle]
52
+ """
53
+ Style of the face swap video.
54
+ """
55
+
47
56
  width: typing_extensions.NotRequired[typing.Optional[int]]
48
57
  """
49
58
  `width` is deprecated and no longer influences the output video's resolution.
@@ -77,4 +86,7 @@ class _SerializerV1FaceSwapCreateBody(pydantic.BaseModel):
77
86
  start_seconds: float = pydantic.Field(
78
87
  alias="start_seconds",
79
88
  )
89
+ style: typing.Optional[_SerializerV1FaceSwapCreateBodyStyle] = pydantic.Field(
90
+ alias="style", default=None
91
+ )
80
92
  width: typing.Optional[int] = pydantic.Field(alias="width", default=None)
@@ -0,0 +1,33 @@
1
+ import pydantic
2
+ import typing
3
+ import typing_extensions
4
+
5
+
6
+ class V1FaceSwapCreateBodyStyle(typing_extensions.TypedDict):
7
+ """
8
+ Style of the face swap video.
9
+ """
10
+
11
+ version: typing_extensions.NotRequired[
12
+ typing_extensions.Literal["default", "v1", "v2"]
13
+ ]
14
+ """
15
+ * `v1` - May preserve skin detail and texture better, but weaker identity preservation.
16
+ * `v2` - Faster, sharper, better handling of hair and glasses. stronger identity preservation. (Recommended)
17
+ * `default` - Use the version we recommend, which will change over time. This is recommended unless you need a specific earlier version. This is the default behavior.
18
+ """
19
+
20
+
21
+ class _SerializerV1FaceSwapCreateBodyStyle(pydantic.BaseModel):
22
+ """
23
+ Serializer for V1FaceSwapCreateBodyStyle handling case conversions
24
+ and file omissions as dictated by the API
25
+ """
26
+
27
+ model_config = pydantic.ConfigDict(
28
+ populate_by_name=True,
29
+ )
30
+
31
+ version: typing.Optional[typing_extensions.Literal["default", "v1", "v2"]] = (
32
+ pydantic.Field(alias="version", default=None)
33
+ )
@@ -0,0 +1,56 @@
1
+ import pydantic
2
+ import typing
3
+ import typing_extensions
4
+
5
+ from .v1_face_swap_generate_body_assets_face_mappings_item import (
6
+ V1FaceSwapGenerateBodyAssetsFaceMappingsItem,
7
+ )
8
+
9
+
10
+ class V1FaceSwapGenerateBodyAssets(typing_extensions.TypedDict):
11
+ """
12
+ Provide the assets for face swap. For video, The `video_source` field determines whether `video_file_path` or `youtube_url` field is used
13
+ """
14
+
15
+ face_mappings: typing_extensions.NotRequired[
16
+ typing.List[V1FaceSwapGenerateBodyAssetsFaceMappingsItem]
17
+ ]
18
+ """
19
+ This is the array of face mappings used for multiple face swap. The value is required if `face_swap_mode` is `individual-faces`.
20
+ """
21
+
22
+ face_swap_mode: typing_extensions.NotRequired[
23
+ typing_extensions.Literal["all-faces", "individual-faces"]
24
+ ]
25
+ """
26
+ The mode of face swap.
27
+ * `all-faces` - Swap all faces in the target image or video. `source_file_path` is required.
28
+ * `individual-faces` - Swap individual faces in the target image or video. `source_faces` is required.
29
+ """
30
+
31
+ image_file_path: typing_extensions.NotRequired[str]
32
+ """
33
+ The path of the input image with the face to be swapped. The value is required if `face_swap_mode` is `all-faces`. This value is either
34
+ - a direct URL to the image file
35
+ - a path to a local file
36
+
37
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
38
+ """
39
+
40
+ video_file_path: typing_extensions.NotRequired[str]
41
+ """
42
+ Required if `video_source` is `file`. This value is either
43
+ - a direct URL to the image file
44
+ - a path to a local file
45
+
46
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
47
+ """
48
+
49
+ video_source: typing_extensions.Required[
50
+ typing_extensions.Literal["file", "youtube"]
51
+ ]
52
+
53
+ youtube_url: typing_extensions.NotRequired[str]
54
+ """
55
+ Using a youtube video as the input source. This field is required if `video_source` is `youtube`
56
+ """
@@ -0,0 +1,25 @@
1
+ import pydantic
2
+ import typing_extensions
3
+
4
+
5
+ class V1FaceSwapGenerateBodyAssetsFaceMappingsItem(typing_extensions.TypedDict):
6
+ """
7
+ V1FaceSwapGenerateBodyAssetsFaceMappingsItem
8
+ """
9
+
10
+ new_face: typing_extensions.Required[str]
11
+ """
12
+ The face image that will be used to replace the face in the `original_face`. This value is either
13
+ - a direct URL to the image file
14
+ - a path to a local file
15
+
16
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
17
+ """
18
+
19
+ original_face: typing_extensions.Required[str]
20
+ """
21
+ The face detected from the image in `target_file_path`. The file name is in the format of `<face_frame>-<face_index>.png`. This value is corresponds to the response in the [face detection API](https://docs.magichour.ai/api-reference/files/get-face-detection-details).
22
+
23
+ * The face_frame is the frame number of the face in the target image. For images, the frame number is always 0.
24
+ * The face_index is the index of the face in the target image, starting from 0 going left to right.
25
+ """
@@ -0,0 +1,47 @@
1
+ import pydantic
2
+ import typing
3
+ import typing_extensions
4
+
5
+ from .v1_face_swap_photo_generate_body_assets_face_mappings_item import (
6
+ V1FaceSwapPhotoGenerateBodyAssetsFaceMappingsItem,
7
+ )
8
+
9
+
10
+ class V1FaceSwapPhotoGenerateBodyAssets(typing_extensions.TypedDict):
11
+ """
12
+ Provide the assets for face swap photo
13
+ """
14
+
15
+ face_mappings: typing_extensions.NotRequired[
16
+ typing.List[V1FaceSwapPhotoGenerateBodyAssetsFaceMappingsItem]
17
+ ]
18
+ """
19
+ This is the array of face mappings used for multiple face swap. The value is required if `face_swap_mode` is `individual-faces`.
20
+ """
21
+
22
+ face_swap_mode: typing_extensions.NotRequired[
23
+ typing_extensions.Literal["all-faces", "individual-faces"]
24
+ ]
25
+ """
26
+ The mode of face swap.
27
+ * `all-faces` - Swap all faces in the target image or video. `source_file_path` is required.
28
+ * `individual-faces` - Swap individual faces in the target image or video. `source_faces` is required.
29
+ """
30
+
31
+ source_file_path: typing_extensions.NotRequired[str]
32
+ """
33
+ This is the image from which the face is extracted. The value is required if `face_swap_mode` is `all-faces`. This value is either
34
+ - a direct URL to the image file
35
+ - a path to a local file
36
+
37
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
38
+ """
39
+
40
+ target_file_path: typing_extensions.Required[str]
41
+ """
42
+ This is the image where the face from the source image will be placed. This value is either
43
+ - a direct URL to the image file
44
+ - a path to a local file
45
+
46
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
47
+ """
@@ -0,0 +1,25 @@
1
+ import pydantic
2
+ import typing_extensions
3
+
4
+
5
+ class V1FaceSwapPhotoGenerateBodyAssetsFaceMappingsItem(typing_extensions.TypedDict):
6
+ """
7
+ V1FaceSwapPhotoGenerateBodyAssetsFaceMappingsItem
8
+ """
9
+
10
+ new_face: typing_extensions.Required[str]
11
+ """
12
+ The face image that will be used to replace the face in the `original_face`. This value is either
13
+ - a direct URL to the image file
14
+ - a path to a local file
15
+
16
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
17
+ """
18
+
19
+ original_face: typing_extensions.Required[str]
20
+ """
21
+ The face detected from the image in `target_file_path`. The file name is in the format of `<face_frame>-<face_index>.png`. This value is corresponds to the response in the [face detection API](https://docs.magichour.ai/api-reference/files/get-face-detection-details).
22
+
23
+ * The face_frame is the frame number of the face in the target image. For images, the frame number is always 0.
24
+ * The face_index is the index of the face in the target image, starting from 0 going left to right.
25
+ """
@@ -0,0 +1,27 @@
1
+ import pydantic
2
+ import typing
3
+ import typing_extensions
4
+
5
+
6
+ class V1ImageBackgroundRemoverGenerateBodyAssets(typing_extensions.TypedDict):
7
+ """
8
+ Provide the assets for background removal
9
+ """
10
+
11
+ background_image_file_path: typing_extensions.NotRequired[str]
12
+ """
13
+ The image used as the new background for the image_file_path. This image will be resized to match the image in image_file_path. Please make sure the resolution between the images are similar. This value is either
14
+ - a direct URL to the image file
15
+ - a path to a local file
16
+
17
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
18
+ """
19
+
20
+ image_file_path: typing_extensions.Required[str]
21
+ """
22
+ The image to remove the background. This value is either
23
+ - a direct URL to the image file
24
+ - a path to a local file
25
+
26
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
27
+ """
@@ -0,0 +1,17 @@
1
+ import pydantic
2
+ import typing_extensions
3
+
4
+
5
+ class V1ImageToVideoGenerateBodyAssets(typing_extensions.TypedDict):
6
+ """
7
+ Provide the assets for image-to-video.
8
+ """
9
+
10
+ image_file_path: typing_extensions.Required[str]
11
+ """
12
+ The path of the image file. This value is either
13
+ - a direct URL to the image file
14
+ - a path to a local file
15
+
16
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
17
+ """
@@ -0,0 +1,36 @@
1
+ import pydantic
2
+ import typing
3
+ import typing_extensions
4
+
5
+
6
+ class V1LipSyncGenerateBodyAssets(typing_extensions.TypedDict):
7
+ """
8
+ Provide the assets for lip-sync. For video, The `video_source` field determines whether `video_file_path` or `youtube_url` field is used
9
+ """
10
+
11
+ audio_file_path: typing_extensions.Required[str]
12
+ """
13
+ The path of the audio file. This value is either
14
+ - a direct URL to the video file
15
+ - a path to a local file
16
+
17
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
18
+ """
19
+
20
+ video_file_path: typing_extensions.NotRequired[str]
21
+ """
22
+ Required if `video_source` is `file`. This value is either
23
+ - a direct URL to the video file
24
+ - a path to a local file
25
+
26
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
27
+ """
28
+
29
+ video_source: typing_extensions.Required[
30
+ typing_extensions.Literal["file", "youtube"]
31
+ ]
32
+
33
+ youtube_url: typing_extensions.NotRequired[str]
34
+ """
35
+ Using a youtube video as the input source. This field is required if `video_source` is `youtube`
36
+ """
@@ -0,0 +1,17 @@
1
+ import pydantic
2
+ import typing_extensions
3
+
4
+
5
+ class V1PhotoColorizerGenerateBodyAssets(typing_extensions.TypedDict):
6
+ """
7
+ Provide the assets for photo colorization
8
+ """
9
+
10
+ image_file_path: typing_extensions.Required[str]
11
+ """
12
+ The image used to generate the colorized image. This value is either
13
+ - a direct URL to the image file
14
+ - a path to a local file
15
+
16
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
17
+ """
@@ -0,0 +1,27 @@
1
+ import pydantic
2
+ import typing
3
+ import typing_extensions
4
+
5
+
6
+ class V1VideoToVideoGenerateBodyAssets(typing_extensions.TypedDict):
7
+ """
8
+ Provide the assets for video-to-video. For video, The `video_source` field determines whether `video_file_path` or `youtube_url` field is used
9
+ """
10
+
11
+ video_file_path: typing_extensions.NotRequired[str]
12
+ """
13
+ Required if `video_source` is `file`. This value is either
14
+ - a direct URL to the video file
15
+ - a path to a local file
16
+
17
+ Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
18
+ """
19
+
20
+ video_source: typing_extensions.Required[
21
+ typing_extensions.Literal["file", "youtube"]
22
+ ]
23
+
24
+ youtube_url: typing_extensions.NotRequired[str]
25
+ """
26
+ Using a youtube video as the input source. This field is required if `video_source` is `youtube`
27
+ """