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.
Files changed (264) hide show
  1. magic_hour/README.md +34 -0
  2. magic_hour/__init__.py +1 -1
  3. magic_hour/client.py +8 -17
  4. magic_hour/environment.py +13 -1
  5. magic_hour/helpers/__init__.py +4 -0
  6. magic_hour/helpers/download.py +77 -0
  7. magic_hour/helpers/logger.py +8 -0
  8. magic_hour/resources/v1/README.md +32 -0
  9. magic_hour/resources/v1/ai_clothes_changer/README.md +94 -5
  10. magic_hour/resources/v1/ai_clothes_changer/client.py +161 -16
  11. magic_hour/resources/v1/ai_face_editor/README.md +195 -0
  12. magic_hour/resources/v1/ai_face_editor/__init__.py +4 -0
  13. magic_hour/resources/v1/ai_face_editor/client.py +324 -0
  14. magic_hour/resources/v1/ai_gif_generator/README.md +116 -0
  15. magic_hour/resources/v1/ai_gif_generator/__init__.py +4 -0
  16. magic_hour/resources/v1/ai_gif_generator/client.py +257 -0
  17. magic_hour/resources/v1/ai_headshot_generator/README.md +81 -3
  18. magic_hour/resources/v1/ai_headshot_generator/client.py +167 -18
  19. magic_hour/resources/v1/ai_image_editor/README.md +125 -0
  20. magic_hour/resources/v1/ai_image_editor/__init__.py +4 -0
  21. magic_hour/resources/v1/ai_image_editor/client.py +290 -0
  22. magic_hour/resources/v1/ai_image_generator/README.md +99 -5
  23. magic_hour/resources/v1/ai_image_generator/client.py +170 -24
  24. magic_hour/resources/v1/ai_image_upscaler/README.md +89 -3
  25. magic_hour/resources/v1/ai_image_upscaler/client.py +173 -20
  26. magic_hour/resources/v1/ai_meme_generator/README.md +129 -0
  27. magic_hour/resources/v1/ai_meme_generator/__init__.py +4 -0
  28. magic_hour/resources/v1/ai_meme_generator/client.py +253 -0
  29. magic_hour/resources/v1/ai_photo_editor/README.md +119 -4
  30. magic_hour/resources/v1/ai_photo_editor/client.py +199 -18
  31. magic_hour/resources/v1/ai_qr_code_generator/README.md +84 -3
  32. magic_hour/resources/v1/ai_qr_code_generator/client.py +140 -18
  33. magic_hour/resources/v1/ai_talking_photo/README.md +137 -0
  34. magic_hour/resources/v1/ai_talking_photo/__init__.py +4 -0
  35. magic_hour/resources/v1/ai_talking_photo/client.py +326 -0
  36. magic_hour/resources/v1/ai_voice_cloner/README.md +62 -0
  37. magic_hour/resources/v1/ai_voice_cloner/__init__.py +4 -0
  38. magic_hour/resources/v1/ai_voice_cloner/client.py +272 -0
  39. magic_hour/resources/v1/ai_voice_generator/README.md +112 -0
  40. magic_hour/resources/v1/ai_voice_generator/__init__.py +4 -0
  41. magic_hour/resources/v1/ai_voice_generator/client.py +241 -0
  42. magic_hour/resources/v1/animation/README.md +128 -6
  43. magic_hour/resources/v1/animation/client.py +247 -22
  44. magic_hour/resources/v1/audio_projects/README.md +135 -0
  45. magic_hour/resources/v1/audio_projects/__init__.py +12 -0
  46. magic_hour/resources/v1/audio_projects/client.py +310 -0
  47. magic_hour/resources/v1/audio_projects/client_test.py +520 -0
  48. magic_hour/resources/v1/auto_subtitle_generator/README.md +128 -0
  49. magic_hour/resources/v1/auto_subtitle_generator/__init__.py +4 -0
  50. magic_hour/resources/v1/auto_subtitle_generator/client.py +346 -0
  51. magic_hour/resources/v1/client.py +75 -1
  52. magic_hour/resources/v1/face_detection/README.md +157 -0
  53. magic_hour/resources/v1/face_detection/__init__.py +12 -0
  54. magic_hour/resources/v1/face_detection/client.py +380 -0
  55. magic_hour/resources/v1/face_swap/README.md +137 -9
  56. magic_hour/resources/v1/face_swap/client.py +329 -38
  57. magic_hour/resources/v1/face_swap_photo/README.md +118 -3
  58. magic_hour/resources/v1/face_swap_photo/client.py +199 -14
  59. magic_hour/resources/v1/files/README.md +39 -0
  60. magic_hour/resources/v1/files/client.py +351 -1
  61. magic_hour/resources/v1/files/client_test.py +414 -0
  62. magic_hour/resources/v1/files/upload_urls/README.md +38 -17
  63. magic_hour/resources/v1/files/upload_urls/client.py +38 -34
  64. magic_hour/resources/v1/image_background_remover/README.md +96 -5
  65. magic_hour/resources/v1/image_background_remover/client.py +151 -16
  66. magic_hour/resources/v1/image_projects/README.md +82 -10
  67. magic_hour/resources/v1/image_projects/__init__.py +10 -2
  68. magic_hour/resources/v1/image_projects/client.py +154 -16
  69. magic_hour/resources/v1/image_projects/client_test.py +527 -0
  70. magic_hour/resources/v1/image_to_video/README.md +96 -11
  71. magic_hour/resources/v1/image_to_video/client.py +282 -38
  72. magic_hour/resources/v1/lip_sync/README.md +112 -9
  73. magic_hour/resources/v1/lip_sync/client.py +288 -34
  74. magic_hour/resources/v1/photo_colorizer/README.md +107 -0
  75. magic_hour/resources/v1/photo_colorizer/__init__.py +4 -0
  76. magic_hour/resources/v1/photo_colorizer/client.py +248 -0
  77. magic_hour/resources/v1/text_to_video/README.md +96 -7
  78. magic_hour/resources/v1/text_to_video/client.py +204 -18
  79. magic_hour/resources/v1/video_projects/README.md +81 -9
  80. magic_hour/resources/v1/video_projects/__init__.py +10 -2
  81. magic_hour/resources/v1/video_projects/client.py +151 -14
  82. magic_hour/resources/v1/video_projects/client_test.py +527 -0
  83. magic_hour/resources/v1/video_to_video/README.md +119 -15
  84. magic_hour/resources/v1/video_to_video/client.py +299 -46
  85. magic_hour/types/models/__init__.py +92 -56
  86. magic_hour/types/models/v1_ai_clothes_changer_create_response.py +33 -0
  87. magic_hour/types/models/v1_ai_face_editor_create_response.py +33 -0
  88. magic_hour/types/models/v1_ai_gif_generator_create_response.py +33 -0
  89. magic_hour/types/models/v1_ai_headshot_generator_create_response.py +33 -0
  90. magic_hour/types/models/v1_ai_image_editor_create_response.py +33 -0
  91. magic_hour/types/models/v1_ai_image_generator_create_response.py +33 -0
  92. magic_hour/types/models/v1_ai_image_upscaler_create_response.py +33 -0
  93. magic_hour/types/models/v1_ai_meme_generator_create_response.py +33 -0
  94. magic_hour/types/models/v1_ai_photo_editor_create_response.py +33 -0
  95. magic_hour/types/models/v1_ai_qr_code_generator_create_response.py +33 -0
  96. magic_hour/types/models/v1_ai_talking_photo_create_response.py +35 -0
  97. magic_hour/types/models/v1_ai_voice_cloner_create_response.py +27 -0
  98. magic_hour/types/models/v1_ai_voice_generator_create_response.py +27 -0
  99. magic_hour/types/models/v1_animation_create_response.py +35 -0
  100. magic_hour/types/models/v1_audio_projects_get_response.py +72 -0
  101. magic_hour/types/models/v1_audio_projects_get_response_downloads_item.py +19 -0
  102. magic_hour/types/models/{get_v1_image_projects_id_response_error.py → v1_audio_projects_get_response_error.py} +2 -2
  103. magic_hour/types/models/v1_auto_subtitle_generator_create_response.py +35 -0
  104. magic_hour/types/models/v1_face_detection_create_response.py +25 -0
  105. magic_hour/types/models/v1_face_detection_get_response.py +45 -0
  106. magic_hour/types/models/v1_face_detection_get_response_faces_item.py +25 -0
  107. magic_hour/types/models/v1_face_swap_create_response.py +35 -0
  108. magic_hour/types/models/v1_face_swap_photo_create_response.py +33 -0
  109. magic_hour/types/models/v1_files_upload_urls_create_response.py +24 -0
  110. magic_hour/types/models/{post_v1_files_upload_urls_response_items_item.py → v1_files_upload_urls_create_response_items_item.py} +2 -2
  111. magic_hour/types/models/v1_image_background_remover_create_response.py +33 -0
  112. magic_hour/types/models/{get_v1_image_projects_id_response.py → v1_image_projects_get_response.py} +20 -18
  113. magic_hour/types/models/{get_v1_video_projects_id_response_downloads_item.py → v1_image_projects_get_response_downloads_item.py} +1 -1
  114. magic_hour/types/models/{get_v1_video_projects_id_response_error.py → v1_image_projects_get_response_error.py} +2 -2
  115. magic_hour/types/models/v1_image_to_video_create_response.py +35 -0
  116. magic_hour/types/models/v1_lip_sync_create_response.py +35 -0
  117. magic_hour/types/models/v1_photo_colorizer_create_response.py +33 -0
  118. magic_hour/types/models/v1_text_to_video_create_response.py +35 -0
  119. magic_hour/types/models/{get_v1_video_projects_id_response.py → v1_video_projects_get_response.py} +26 -23
  120. magic_hour/types/models/{get_v1_video_projects_id_response_download.py → v1_video_projects_get_response_download.py} +1 -1
  121. magic_hour/types/models/{get_v1_image_projects_id_response_downloads_item.py → v1_video_projects_get_response_downloads_item.py} +1 -1
  122. magic_hour/types/models/v1_video_projects_get_response_error.py +25 -0
  123. magic_hour/types/models/v1_video_to_video_create_response.py +35 -0
  124. magic_hour/types/params/__init__.py +422 -176
  125. magic_hour/types/params/v1_ai_clothes_changer_create_body.py +40 -0
  126. magic_hour/types/params/v1_ai_clothes_changer_create_body_assets.py +58 -0
  127. magic_hour/types/params/v1_ai_clothes_changer_generate_body_assets.py +33 -0
  128. magic_hour/types/params/v1_ai_face_editor_create_body.py +52 -0
  129. magic_hour/types/params/v1_ai_face_editor_create_body_assets.py +33 -0
  130. magic_hour/types/params/v1_ai_face_editor_create_body_style.py +137 -0
  131. magic_hour/types/params/v1_ai_face_editor_generate_body_assets.py +17 -0
  132. magic_hour/types/params/v1_ai_gif_generator_create_body.py +47 -0
  133. magic_hour/types/params/{post_v1_ai_image_generator_body_style.py → v1_ai_gif_generator_create_body_style.py} +5 -5
  134. magic_hour/types/params/v1_ai_headshot_generator_create_body.py +49 -0
  135. magic_hour/types/params/v1_ai_headshot_generator_create_body_assets.py +33 -0
  136. magic_hour/types/params/v1_ai_headshot_generator_create_body_style.py +27 -0
  137. magic_hour/types/params/v1_ai_headshot_generator_generate_body_assets.py +17 -0
  138. magic_hour/types/params/v1_ai_image_editor_create_body.py +49 -0
  139. magic_hour/types/params/v1_ai_image_editor_create_body_assets.py +47 -0
  140. magic_hour/types/params/v1_ai_image_editor_create_body_style.py +41 -0
  141. magic_hour/types/params/v1_ai_image_editor_generate_body_assets.py +28 -0
  142. magic_hour/types/params/{post_v1_ai_image_generator_body.py → v1_ai_image_generator_create_body.py} +17 -11
  143. magic_hour/types/params/v1_ai_image_generator_create_body_style.py +127 -0
  144. magic_hour/types/params/v1_ai_image_upscaler_create_body.py +59 -0
  145. magic_hour/types/params/v1_ai_image_upscaler_create_body_assets.py +33 -0
  146. magic_hour/types/params/{post_v1_ai_image_upscaler_body_style.py → v1_ai_image_upscaler_create_body_style.py} +4 -4
  147. magic_hour/types/params/v1_ai_image_upscaler_generate_body_assets.py +17 -0
  148. magic_hour/types/params/v1_ai_meme_generator_create_body.py +37 -0
  149. magic_hour/types/params/v1_ai_meme_generator_create_body_style.py +73 -0
  150. magic_hour/types/params/{post_v1_ai_photo_editor_body.py → v1_ai_photo_editor_create_body.py} +15 -15
  151. magic_hour/types/params/v1_ai_photo_editor_create_body_assets.py +33 -0
  152. magic_hour/types/params/{post_v1_ai_photo_editor_body_style.py → v1_ai_photo_editor_create_body_style.py} +20 -4
  153. magic_hour/types/params/v1_ai_photo_editor_generate_body_assets.py +17 -0
  154. magic_hour/types/params/v1_ai_qr_code_generator_create_body.py +45 -0
  155. magic_hour/types/params/{post_v1_ai_qr_code_generator_body_style.py → v1_ai_qr_code_generator_create_body_style.py} +4 -4
  156. magic_hour/types/params/v1_ai_talking_photo_create_body.py +68 -0
  157. magic_hour/types/params/v1_ai_talking_photo_create_body_assets.py +46 -0
  158. magic_hour/types/params/v1_ai_talking_photo_create_body_style.py +44 -0
  159. magic_hour/types/params/v1_ai_talking_photo_generate_body_assets.py +26 -0
  160. magic_hour/types/params/v1_ai_voice_cloner_create_body.py +49 -0
  161. magic_hour/types/params/v1_ai_voice_cloner_create_body_assets.py +33 -0
  162. magic_hour/types/params/v1_ai_voice_cloner_create_body_style.py +28 -0
  163. magic_hour/types/params/v1_ai_voice_cloner_generate_body_assets.py +28 -0
  164. magic_hour/types/params/v1_ai_voice_generator_create_body.py +40 -0
  165. magic_hour/types/params/v1_ai_voice_generator_create_body_style.py +440 -0
  166. magic_hour/types/params/{post_v1_animation_body.py → v1_animation_create_body.py} +16 -16
  167. magic_hour/types/params/{post_v1_animation_body_assets.py → v1_animation_create_body_assets.py} +15 -5
  168. magic_hour/types/params/{post_v1_animation_body_style.py → v1_animation_create_body_style.py} +13 -10
  169. magic_hour/types/params/v1_animation_generate_body_assets.py +39 -0
  170. magic_hour/types/params/v1_auto_subtitle_generator_create_body.py +78 -0
  171. magic_hour/types/params/v1_auto_subtitle_generator_create_body_assets.py +33 -0
  172. magic_hour/types/params/v1_auto_subtitle_generator_create_body_style.py +56 -0
  173. magic_hour/types/params/v1_auto_subtitle_generator_create_body_style_custom_config.py +86 -0
  174. magic_hour/types/params/v1_auto_subtitle_generator_generate_body_assets.py +17 -0
  175. magic_hour/types/params/v1_face_detection_create_body.py +44 -0
  176. magic_hour/types/params/v1_face_detection_create_body_assets.py +33 -0
  177. magic_hour/types/params/v1_face_detection_generate_body_assets.py +17 -0
  178. magic_hour/types/params/v1_face_swap_create_body.py +92 -0
  179. magic_hour/types/params/v1_face_swap_create_body_assets.py +91 -0
  180. magic_hour/types/params/v1_face_swap_create_body_assets_face_mappings_item.py +44 -0
  181. magic_hour/types/params/v1_face_swap_create_body_style.py +33 -0
  182. magic_hour/types/params/v1_face_swap_generate_body_assets.py +56 -0
  183. magic_hour/types/params/v1_face_swap_generate_body_assets_face_mappings_item.py +25 -0
  184. magic_hour/types/params/v1_face_swap_photo_create_body.py +40 -0
  185. magic_hour/types/params/v1_face_swap_photo_create_body_assets.py +76 -0
  186. magic_hour/types/params/v1_face_swap_photo_create_body_assets_face_mappings_item.py +44 -0
  187. magic_hour/types/params/v1_face_swap_photo_generate_body_assets.py +47 -0
  188. magic_hour/types/params/v1_face_swap_photo_generate_body_assets_face_mappings_item.py +25 -0
  189. magic_hour/types/params/v1_files_upload_urls_create_body.py +36 -0
  190. magic_hour/types/params/v1_files_upload_urls_create_body_items_item.py +38 -0
  191. magic_hour/types/params/v1_image_background_remover_create_body.py +40 -0
  192. magic_hour/types/params/v1_image_background_remover_create_body_assets.py +49 -0
  193. magic_hour/types/params/v1_image_background_remover_generate_body_assets.py +27 -0
  194. magic_hour/types/params/v1_image_to_video_create_body.py +101 -0
  195. magic_hour/types/params/v1_image_to_video_create_body_assets.py +33 -0
  196. magic_hour/types/params/v1_image_to_video_create_body_style.py +53 -0
  197. magic_hour/types/params/v1_image_to_video_generate_body_assets.py +17 -0
  198. magic_hour/types/params/v1_lip_sync_create_body.py +100 -0
  199. magic_hour/types/params/{post_v1_lip_sync_body_assets.py → v1_lip_sync_create_body_assets.py} +15 -5
  200. magic_hour/types/params/v1_lip_sync_create_body_style.py +37 -0
  201. magic_hour/types/params/v1_lip_sync_generate_body_assets.py +36 -0
  202. magic_hour/types/params/v1_photo_colorizer_create_body.py +40 -0
  203. magic_hour/types/params/v1_photo_colorizer_create_body_assets.py +33 -0
  204. magic_hour/types/params/v1_photo_colorizer_generate_body_assets.py +17 -0
  205. magic_hour/types/params/v1_text_to_video_create_body.py +78 -0
  206. magic_hour/types/params/v1_text_to_video_create_body_style.py +43 -0
  207. magic_hour/types/params/v1_video_to_video_create_body.py +101 -0
  208. magic_hour/types/params/{post_v1_video_to_video_body_assets.py → v1_video_to_video_create_body_assets.py} +9 -4
  209. magic_hour/types/params/{post_v1_video_to_video_body_style.py → v1_video_to_video_create_body_style.py} +68 -26
  210. magic_hour/types/params/v1_video_to_video_generate_body_assets.py +27 -0
  211. magic_hour-0.44.0.dist-info/METADATA +328 -0
  212. magic_hour-0.44.0.dist-info/RECORD +231 -0
  213. magic_hour/core/__init__.py +0 -52
  214. magic_hour/core/api_error.py +0 -56
  215. magic_hour/core/auth.py +0 -314
  216. magic_hour/core/base_client.py +0 -618
  217. magic_hour/core/binary_response.py +0 -23
  218. magic_hour/core/query.py +0 -106
  219. magic_hour/core/request.py +0 -156
  220. magic_hour/core/response.py +0 -293
  221. magic_hour/core/type_utils.py +0 -28
  222. magic_hour/core/utils.py +0 -55
  223. magic_hour/types/models/post_v1_ai_clothes_changer_response.py +0 -25
  224. magic_hour/types/models/post_v1_ai_headshot_generator_response.py +0 -25
  225. magic_hour/types/models/post_v1_ai_image_generator_response.py +0 -25
  226. magic_hour/types/models/post_v1_ai_image_upscaler_response.py +0 -25
  227. magic_hour/types/models/post_v1_ai_photo_editor_response.py +0 -25
  228. magic_hour/types/models/post_v1_ai_qr_code_generator_response.py +0 -25
  229. magic_hour/types/models/post_v1_animation_response.py +0 -25
  230. magic_hour/types/models/post_v1_face_swap_photo_response.py +0 -25
  231. magic_hour/types/models/post_v1_face_swap_response.py +0 -25
  232. magic_hour/types/models/post_v1_files_upload_urls_response.py +0 -21
  233. magic_hour/types/models/post_v1_image_background_remover_response.py +0 -25
  234. magic_hour/types/models/post_v1_image_to_video_response.py +0 -25
  235. magic_hour/types/models/post_v1_lip_sync_response.py +0 -25
  236. magic_hour/types/models/post_v1_text_to_video_response.py +0 -25
  237. magic_hour/types/models/post_v1_video_to_video_response.py +0 -25
  238. magic_hour/types/params/post_v1_ai_clothes_changer_body.py +0 -40
  239. magic_hour/types/params/post_v1_ai_clothes_changer_body_assets.py +0 -45
  240. magic_hour/types/params/post_v1_ai_headshot_generator_body.py +0 -40
  241. magic_hour/types/params/post_v1_ai_headshot_generator_body_assets.py +0 -28
  242. magic_hour/types/params/post_v1_ai_image_upscaler_body.py +0 -57
  243. magic_hour/types/params/post_v1_ai_image_upscaler_body_assets.py +0 -28
  244. magic_hour/types/params/post_v1_ai_photo_editor_body_assets.py +0 -28
  245. magic_hour/types/params/post_v1_ai_qr_code_generator_body.py +0 -45
  246. magic_hour/types/params/post_v1_face_swap_body.py +0 -72
  247. magic_hour/types/params/post_v1_face_swap_body_assets.py +0 -52
  248. magic_hour/types/params/post_v1_face_swap_photo_body.py +0 -40
  249. magic_hour/types/params/post_v1_face_swap_photo_body_assets.py +0 -36
  250. magic_hour/types/params/post_v1_files_upload_urls_body.py +0 -31
  251. magic_hour/types/params/post_v1_files_upload_urls_body_items_item.py +0 -38
  252. magic_hour/types/params/post_v1_image_background_remover_body.py +0 -40
  253. magic_hour/types/params/post_v1_image_background_remover_body_assets.py +0 -28
  254. magic_hour/types/params/post_v1_image_to_video_body.py +0 -73
  255. magic_hour/types/params/post_v1_image_to_video_body_assets.py +0 -28
  256. magic_hour/types/params/post_v1_image_to_video_body_style.py +0 -37
  257. magic_hour/types/params/post_v1_lip_sync_body.py +0 -80
  258. magic_hour/types/params/post_v1_text_to_video_body.py +0 -57
  259. magic_hour/types/params/post_v1_text_to_video_body_style.py +0 -28
  260. magic_hour/types/params/post_v1_video_to_video_body.py +0 -93
  261. magic_hour-0.9.5.dist-info/METADATA +0 -133
  262. magic_hour-0.9.5.dist-info/RECORD +0 -132
  263. {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/LICENSE +0 -0
  264. {magic_hour-0.9.5.dist-info → magic_hour-0.44.0.dist-info}/WHEEL +0 -0
@@ -1,11 +1,84 @@
1
+ # v1.image_background_remover
1
2
 
2
- ### create <a name="create"></a>
3
- Image Background Remover
3
+ ## Module Functions
4
4
 
5
- Remove background from image. Each image costs 5 frames.
5
+ <!-- CUSTOM DOCS START -->
6
+
7
+ ### Image Background Remover 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.image_background_remover.generate(
35
+ assets={
36
+ "background_image_file_path": "/path/to/1234.png",
37
+ "image_file_path": "/path/to/1234.png",
38
+ },
39
+ name="Background Remover image",
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.image_background_remover.generate(
54
+ assets={
55
+ "background_image_file_path": "/path/to/1234.png",
56
+ "image_file_path": "/path/to/1234.png",
57
+ },
58
+ name="Background Remover image",
59
+ wait_for_completion=True,
60
+ download_outputs=True,
61
+ download_directory="outputs"
62
+ )
63
+ ```
64
+
65
+ <!-- CUSTOM DOCS END -->
66
+
67
+ ### Image Background Remover <a name="create"></a>
68
+
69
+ Remove background from image. Each image costs 5 credits.
6
70
 
7
71
  **API Endpoint**: `POST /v1/image-background-remover`
8
72
 
73
+ #### Parameters
74
+
75
+ | Parameter | Required | Description | Example |
76
+ | ------------------------------- | :------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
77
+ | `assets` | ✓ | Provide the assets for background removal | `{"background_image_file_path": "api-assets/id/1234.png", "image_file_path": "api-assets/id/1234.png"}` |
78
+ | `└─ background_image_file_path` | ✗ | 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 - 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"` |
79
+ | `└─ image_file_path` | ✓ | The image to remove the background. 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"` |
80
+ | `name` | ✗ | The name of image. This value is mainly used for your own identification of the image. | `"Background Remover image"` |
81
+
9
82
  #### Synchronous Client
10
83
 
11
84
  ```python
@@ -14,7 +87,10 @@ from os import getenv
14
87
 
15
88
  client = Client(token=getenv("API_TOKEN"))
16
89
  res = client.v1.image_background_remover.create(
17
- assets={"image_file_path": "api-assets/id/1234.png"},
90
+ assets={
91
+ "background_image_file_path": "api-assets/id/1234.png",
92
+ "image_file_path": "api-assets/id/1234.png",
93
+ },
18
94
  name="Background Remover image",
19
95
  )
20
96
  ```
@@ -27,7 +103,22 @@ from os import getenv
27
103
 
28
104
  client = AsyncClient(token=getenv("API_TOKEN"))
29
105
  res = await client.v1.image_background_remover.create(
30
- assets={"image_file_path": "api-assets/id/1234.png"},
106
+ assets={
107
+ "background_image_file_path": "api-assets/id/1234.png",
108
+ "image_file_path": "api-assets/id/1234.png",
109
+ },
31
110
  name="Background Remover image",
32
111
  )
33
112
  ```
113
+
114
+ #### Response
115
+
116
+ ##### Type
117
+
118
+ [V1ImageBackgroundRemoverCreateResponse](/magic_hour/types/models/v1_image_background_remover_create_response.py)
119
+
120
+ ##### Example
121
+
122
+ ```python
123
+ {"credits_charged": 5, "frame_cost": 5, "id": "cuid-example"}
124
+ ```
@@ -1,6 +1,13 @@
1
1
  import typing
2
2
 
3
- from magic_hour.core import (
3
+ from magic_hour.helpers.logger import get_sdk_logger
4
+ from magic_hour.resources.v1.files.client import AsyncFilesClient, FilesClient
5
+ from magic_hour.resources.v1.image_projects.client import (
6
+ AsyncImageProjectsClient,
7
+ ImageProjectsClient,
8
+ )
9
+ from magic_hour.types import models, params
10
+ from make_api_request import (
4
11
  AsyncBaseClient,
5
12
  RequestOptions,
6
13
  SyncBaseClient,
@@ -8,31 +15,93 @@ from magic_hour.core import (
8
15
  to_encodable,
9
16
  type_utils,
10
17
  )
11
- from magic_hour.types import models, params
18
+
19
+
20
+ logger = get_sdk_logger(__name__)
12
21
 
13
22
 
14
23
  class ImageBackgroundRemoverClient:
15
24
  def __init__(self, *, base_client: SyncBaseClient):
16
25
  self._base_client = base_client
17
26
 
27
+ def generate(
28
+ self,
29
+ *,
30
+ assets: params.V1ImageBackgroundRemoverGenerateBodyAssets,
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 background removed image (alias for create with additional functionality).
41
+
42
+ Remove background from image. Each removal 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 background removal
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 Image Background Remover API with the downloaded paths if `download_outputs` is True.
54
+
55
+ Examples:
56
+ ```py
57
+ response = client.v1.image_background_remover.generate(
58
+ assets={"image_file_path": "path/to/image.png"},
59
+ name="Background Removed Image",
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"Image Background Remover 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
+
18
87
  def create(
19
88
  self,
20
89
  *,
21
- assets: params.PostV1ImageBackgroundRemoverBodyAssets,
90
+ assets: params.V1ImageBackgroundRemoverCreateBodyAssets,
22
91
  name: typing.Union[
23
92
  typing.Optional[str], type_utils.NotGiven
24
93
  ] = type_utils.NOT_GIVEN,
25
94
  request_options: typing.Optional[RequestOptions] = None,
26
- ) -> models.PostV1ImageBackgroundRemoverResponse:
95
+ ) -> models.V1ImageBackgroundRemoverCreateResponse:
27
96
  """
28
97
  Image Background Remover
29
98
 
30
- Remove background from image. Each image costs 5 frames.
99
+ Remove background from image. Each image costs 5 credits.
31
100
 
32
101
  POST /v1/image-background-remover
33
102
 
34
103
  Args:
35
- name: The name of image
104
+ name: The name of image. This value is mainly used for your own identification of the image.
36
105
  assets: Provide the assets for background removal
37
106
  request_options: Additional options to customize the HTTP request
38
107
 
@@ -46,21 +115,24 @@ class ImageBackgroundRemoverClient:
46
115
  Examples:
47
116
  ```py
48
117
  client.v1.image_background_remover.create(
49
- assets={"image_file_path": "api-assets/id/1234.png"},
118
+ assets={
119
+ "background_image_file_path": "api-assets/id/1234.png",
120
+ "image_file_path": "api-assets/id/1234.png",
121
+ },
50
122
  name="Background Remover image",
51
123
  )
52
124
  ```
53
125
  """
54
126
  _json = to_encodable(
55
127
  item={"name": name, "assets": assets},
56
- dump_with=params._SerializerPostV1ImageBackgroundRemoverBody,
128
+ dump_with=params._SerializerV1ImageBackgroundRemoverCreateBody,
57
129
  )
58
130
  return self._base_client.request(
59
131
  method="POST",
60
132
  path="/v1/image-background-remover",
61
133
  auth_names=["bearerAuth"],
62
134
  json=_json,
63
- cast_to=models.PostV1ImageBackgroundRemoverResponse,
135
+ cast_to=models.V1ImageBackgroundRemoverCreateResponse,
64
136
  request_options=request_options or default_request_options(),
65
137
  )
66
138
 
@@ -69,24 +141,84 @@ class AsyncImageBackgroundRemoverClient:
69
141
  def __init__(self, *, base_client: AsyncBaseClient):
70
142
  self._base_client = base_client
71
143
 
144
+ async def generate(
145
+ self,
146
+ *,
147
+ assets: params.V1ImageBackgroundRemoverGenerateBodyAssets,
148
+ name: typing.Union[
149
+ typing.Optional[str], type_utils.NotGiven
150
+ ] = type_utils.NOT_GIVEN,
151
+ wait_for_completion: bool = True,
152
+ download_outputs: bool = True,
153
+ download_directory: typing.Optional[str] = None,
154
+ request_options: typing.Optional[RequestOptions] = None,
155
+ ):
156
+ """
157
+ Generate background removed image (alias for create with additional functionality).
158
+
159
+ Remove background from image. Each removal costs 5 credits.
160
+
161
+ Args:
162
+ name: The name of image. This value is mainly used for your own identification of the image.
163
+ assets: Provide the assets for background removal
164
+ wait_for_completion: Whether to wait for the image project to complete
165
+ download_outputs: Whether to download the outputs
166
+ download_directory: The directory to download the outputs to. If not provided, the outputs will be downloaded to the current working directory
167
+ request_options: Additional options to customize the HTTP request
168
+
169
+ Returns:
170
+ V1ImageProjectsGetResponseWithDownloads: The response from the Image Background Remover API with the downloaded paths if `download_outputs` is True.
171
+
172
+ Examples:
173
+ ```py
174
+ response = await client.v1.image_background_remover.generate(
175
+ assets={"image_file_path": "path/to/image.png"},
176
+ name="Background Removed Image",
177
+ wait_for_completion=True,
178
+ download_outputs=True,
179
+ download_directory="outputs/",
180
+ )
181
+ ```
182
+ """
183
+
184
+ file_client = AsyncFilesClient(base_client=self._base_client)
185
+
186
+ image_file_path = assets["image_file_path"]
187
+ assets["image_file_path"] = await file_client.upload_file(file=image_file_path)
188
+
189
+ create_response = await self.create(
190
+ assets=assets, name=name, request_options=request_options
191
+ )
192
+ logger.info(f"Image Background Remover response: {create_response}")
193
+
194
+ image_projects_client = AsyncImageProjectsClient(base_client=self._base_client)
195
+ response = await image_projects_client.check_result(
196
+ id=create_response.id,
197
+ wait_for_completion=wait_for_completion,
198
+ download_outputs=download_outputs,
199
+ download_directory=download_directory,
200
+ )
201
+
202
+ return response
203
+
72
204
  async def create(
73
205
  self,
74
206
  *,
75
- assets: params.PostV1ImageBackgroundRemoverBodyAssets,
207
+ assets: params.V1ImageBackgroundRemoverCreateBodyAssets,
76
208
  name: typing.Union[
77
209
  typing.Optional[str], type_utils.NotGiven
78
210
  ] = type_utils.NOT_GIVEN,
79
211
  request_options: typing.Optional[RequestOptions] = None,
80
- ) -> models.PostV1ImageBackgroundRemoverResponse:
212
+ ) -> models.V1ImageBackgroundRemoverCreateResponse:
81
213
  """
82
214
  Image Background Remover
83
215
 
84
- Remove background from image. Each image costs 5 frames.
216
+ Remove background from image. Each image costs 5 credits.
85
217
 
86
218
  POST /v1/image-background-remover
87
219
 
88
220
  Args:
89
- name: The name of image
221
+ name: The name of image. This value is mainly used for your own identification of the image.
90
222
  assets: Provide the assets for background removal
91
223
  request_options: Additional options to customize the HTTP request
92
224
 
@@ -100,20 +232,23 @@ class AsyncImageBackgroundRemoverClient:
100
232
  Examples:
101
233
  ```py
102
234
  await client.v1.image_background_remover.create(
103
- assets={"image_file_path": "api-assets/id/1234.png"},
235
+ assets={
236
+ "background_image_file_path": "api-assets/id/1234.png",
237
+ "image_file_path": "api-assets/id/1234.png",
238
+ },
104
239
  name="Background Remover image",
105
240
  )
106
241
  ```
107
242
  """
108
243
  _json = to_encodable(
109
244
  item={"name": name, "assets": assets},
110
- dump_with=params._SerializerPostV1ImageBackgroundRemoverBody,
245
+ dump_with=params._SerializerV1ImageBackgroundRemoverCreateBody,
111
246
  )
112
247
  return await self._base_client.request(
113
248
  method="POST",
114
249
  path="/v1/image-background-remover",
115
250
  auth_names=["bearerAuth"],
116
251
  json=_json,
117
- cast_to=models.PostV1ImageBackgroundRemoverResponse,
252
+ cast_to=models.V1ImageBackgroundRemoverCreateResponse,
118
253
  request_options=request_options or default_request_options(),
119
254
  )
@@ -1,11 +1,66 @@
1
+ # v1.image_projects
1
2
 
2
- ### delete <a name="delete"></a>
3
- Delete image
3
+ ## Module Functions
4
4
 
5
- Permanently delete the rendered image. This action is not reversible, please be sure before deleting.
5
+ <!-- CUSTOM DOCS START -->
6
+
7
+ ### Check results <a name="check-result"></a>
8
+
9
+ Poll the details API to check on the status of the rendering. Optionally can also download the output
10
+
11
+ #### Parameters
12
+
13
+ | Parameter | Required | Description | Example |
14
+ | --------------------- | :------: | ---------------------------------------------------------------------------------------------------- | ---------------- |
15
+ | `id` | ✓ | Unique ID of the image project. This value is returned by all of the POST APIs that create an image. | `"cuid-example"` |
16
+ | `wait_for_completion` | ✗ | Whether to wait for the project to complete. | `True` |
17
+ | `download_outputs` | ✗ | Whether to download the generated files | `True` |
18
+ | `download_directory` | ✗ | Directory to save downloaded files (defaults to current directory) | `"./outputs"` |
19
+
20
+ #### Synchronous Client
21
+
22
+ ```python
23
+ from magic_hour import Client
24
+ from os import getenv
25
+
26
+ client = Client(token=getenv("API_TOKEN"))
27
+ res = client.v1.image_projects.check_result(
28
+ id="cuid-example",
29
+ wait_for_completion=True,
30
+ download_outputs=True,
31
+ download_directory="outputs",
32
+ )
33
+ ```
34
+
35
+ #### Asynchronous Client
36
+
37
+ ```python
38
+ from magic_hour import AsyncClient
39
+ from os import getenv
40
+
41
+ client = AsyncClient(token=getenv("API_TOKEN"))
42
+ res = await client.v1.image_projects.check_result(
43
+ id="cuid-example",
44
+ wait_for_completion=True,
45
+ download_outputs=True,
46
+ download_directory="outputs",
47
+ )
48
+ ```
49
+
50
+ <!-- CUSTOM DOCS END -->
51
+
52
+ ### Delete image <a name="delete"></a>
53
+
54
+ Permanently delete the rendered image(s). This action is not reversible, please be sure before deleting.
6
55
 
7
56
  **API Endpoint**: `DELETE /v1/image-projects/{id}`
8
57
 
58
+ #### Parameters
59
+
60
+ | Parameter | Required | Description | Example |
61
+ | --------- | :------: | ---------------------------------------------------------------------------------------------------- | ---------------- |
62
+ | `id` | ✓ | Unique ID of the image project. This value is returned by all of the POST APIs that create an image. | `"cuid-example"` |
63
+
9
64
  #### Synchronous Client
10
65
 
11
66
  ```python
@@ -13,7 +68,7 @@ from magic_hour import Client
13
68
  from os import getenv
14
69
 
15
70
  client = Client(token=getenv("API_TOKEN"))
16
- res = client.v1.image_projects.delete(id="cm6pvghix03bvyz0zwash6noj")
71
+ res = client.v1.image_projects.delete(id="cuid-example")
17
72
  ```
18
73
 
19
74
  #### Asynchronous Client
@@ -23,15 +78,15 @@ from magic_hour import AsyncClient
23
78
  from os import getenv
24
79
 
25
80
  client = AsyncClient(token=getenv("API_TOKEN"))
26
- res = await client.v1.image_projects.delete(id="cm6pvghix03bvyz0zwash6noj")
81
+ res = await client.v1.image_projects.delete(id="cuid-example")
27
82
  ```
28
83
 
29
- ### get <a name="get"></a>
30
- Get image details
84
+ ### Get image details <a name="get"></a>
31
85
 
32
86
  Get the details of a image project. The `downloads` field will be empty unless the image was successfully rendered.
33
87
 
34
88
  The image can be one of the following status
89
+
35
90
  - `draft` - not currently used
36
91
  - `queued` - the job is queued and waiting for a GPU
37
92
  - `rendering` - the generation is in progress
@@ -39,9 +94,14 @@ The image can be one of the following status
39
94
  - `error` - an error occurred during rendering
40
95
  - `canceled` - image render is canceled by the user
41
96
 
42
-
43
97
  **API Endpoint**: `GET /v1/image-projects/{id}`
44
98
 
99
+ #### Parameters
100
+
101
+ | Parameter | Required | Description | Example |
102
+ | --------- | :------: | ---------------------------------------------------------------------------------------------------- | ---------------- |
103
+ | `id` | ✓ | Unique ID of the image project. This value is returned by all of the POST APIs that create an image. | `"cuid-example"` |
104
+
45
105
  #### Synchronous Client
46
106
 
47
107
  ```python
@@ -49,7 +109,7 @@ from magic_hour import Client
49
109
  from os import getenv
50
110
 
51
111
  client = Client(token=getenv("API_TOKEN"))
52
- res = client.v1.image_projects.get(id="cm6pvghix03bvyz0zwash6noj")
112
+ res = client.v1.image_projects.get(id="cuid-example")
53
113
  ```
54
114
 
55
115
  #### Asynchronous Client
@@ -59,5 +119,17 @@ from magic_hour import AsyncClient
59
119
  from os import getenv
60
120
 
61
121
  client = AsyncClient(token=getenv("API_TOKEN"))
62
- res = await client.v1.image_projects.get(id="cm6pvghix03bvyz0zwash6noj")
122
+ res = await client.v1.image_projects.get(id="cuid-example")
123
+ ```
124
+
125
+ #### Response
126
+
127
+ ##### Type
128
+
129
+ [V1ImageProjectsGetResponse](/magic_hour/types/models/v1_image_projects_get_response.py)
130
+
131
+ ##### Example
132
+
133
+ ```python
134
+ {"created_at": "1970-01-01T00:00:00", "credits_charged": 5, "downloads": [{"expires_at": "2024-10-19T05:16:19.027Z", "url": "https://videos.magichour.ai/id/output.png"}], "enabled": True, "error": {"code": "no_source_face", "message": "Please use an image with a detectable face"}, "id": "cuid-example", "image_count": 1, "name": "Example Name", "status": "complete", "total_frame_cost": 5, "type_": "AI_IMAGE"}
63
135
  ```
@@ -1,4 +1,12 @@
1
- from .client import AsyncImageProjectsClient, ImageProjectsClient
1
+ from .client import (
2
+ AsyncImageProjectsClient,
3
+ ImageProjectsClient,
4
+ V1ImageProjectsGetResponseWithDownloads,
5
+ )
2
6
 
3
7
 
4
- __all__ = ["AsyncImageProjectsClient", "ImageProjectsClient"]
8
+ __all__ = [
9
+ "AsyncImageProjectsClient",
10
+ "ImageProjectsClient",
11
+ "V1ImageProjectsGetResponseWithDownloads",
12
+ ]