magic123 0.1.0__tar.gz

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 (214) hide show
  1. magic123-0.1.0/LICENSE +201 -0
  2. magic123-0.1.0/MANIFEST.in +16 -0
  3. magic123-0.1.0/PKG-INFO +426 -0
  4. magic123-0.1.0/activation.py +21 -0
  5. magic123-0.1.0/all_metrics/metric_utils.py +459 -0
  6. magic123-0.1.0/assets/advanced.md +71 -0
  7. magic123-0.1.0/assets/update_logs.md +39 -0
  8. magic123-0.1.0/data/demo/a-full-body-ironman/depth.png +0 -0
  9. magic123-0.1.0/data/demo/a-full-body-ironman/image.png +0 -0
  10. magic123-0.1.0/data/demo/a-full-body-ironman/rgba.png +0 -0
  11. magic123-0.1.0/data/demo/blackpink-lisa/depth.png +0 -0
  12. magic123-0.1.0/data/demo/blackpink-lisa/image.png +0 -0
  13. magic123-0.1.0/data/demo/blackpink-lisa/rgba.png +0 -0
  14. magic123-0.1.0/data/demo/taylor-swift-sit-1989/depth.png +0 -0
  15. magic123-0.1.0/data/demo/taylor-swift-sit-1989/image.png +0 -0
  16. magic123-0.1.0/data/demo/taylor-swift-sit-1989/rgba.png +0 -0
  17. magic123-0.1.0/dnnultis/__init__.py +1 -0
  18. magic123-0.1.0/dnnultis/log/__init__.py +2 -0
  19. magic123-0.1.0/dnnultis/log/logger.py +86 -0
  20. magic123-0.1.0/dnnultis/log/wandb.py +84 -0
  21. magic123-0.1.0/docs/static/2d_3d.png +0 -0
  22. magic123-0.1.0/docs/static/ironman-val-magic123.gif +0 -0
  23. magic123-0.1.0/docs/static/magic123-results.mp4 +0 -0
  24. magic123-0.1.0/docs/static/magic123.gif +0 -0
  25. magic123-0.1.0/dpt.py +924 -0
  26. magic123-0.1.0/encoding.py +89 -0
  27. magic123-0.1.0/freqencoder/__init__.py +1 -0
  28. magic123-0.1.0/freqencoder/backend.py +42 -0
  29. magic123-0.1.0/freqencoder/freq.py +77 -0
  30. magic123-0.1.0/freqencoder/setup.py +25 -0
  31. magic123-0.1.0/freqencoder/src/bindings.cpp +8 -0
  32. magic123-0.1.0/freqencoder/src/freqencoder.cu +129 -0
  33. magic123-0.1.0/freqencoder/src/freqencoder.h +10 -0
  34. magic123-0.1.0/gradio_app.py +246 -0
  35. magic123-0.1.0/gridencoder/__init__.py +1 -0
  36. magic123-0.1.0/gridencoder/backend.py +40 -0
  37. magic123-0.1.0/gridencoder/grid.py +206 -0
  38. magic123-0.1.0/gridencoder/setup.py +24 -0
  39. magic123-0.1.0/gridencoder/src/bindings.cpp +10 -0
  40. magic123-0.1.0/gridencoder/src/gridencoder.cu +713 -0
  41. magic123-0.1.0/gridencoder/src/gridencoder.h +18 -0
  42. magic123-0.1.0/guidance/clip_utils.py +52 -0
  43. magic123-0.1.0/guidance/if_utils.py +207 -0
  44. magic123-0.1.0/guidance/sd_utils.py +707 -0
  45. magic123-0.1.0/guidance/shape_utils.py +81 -0
  46. magic123-0.1.0/guidance/zero123_utils.py +332 -0
  47. magic123-0.1.0/ldm/extras.py +77 -0
  48. magic123-0.1.0/ldm/guidance.py +96 -0
  49. magic123-0.1.0/ldm/lr_scheduler.py +98 -0
  50. magic123-0.1.0/ldm/models/autoencoder.py +443 -0
  51. magic123-0.1.0/ldm/models/diffusion/__init__.py +0 -0
  52. magic123-0.1.0/ldm/models/diffusion/classifier.py +267 -0
  53. magic123-0.1.0/ldm/models/diffusion/ddim.py +328 -0
  54. magic123-0.1.0/ldm/models/diffusion/ddpm.py +1994 -0
  55. magic123-0.1.0/ldm/models/diffusion/plms.py +259 -0
  56. magic123-0.1.0/ldm/models/diffusion/sampling_util.py +50 -0
  57. magic123-0.1.0/ldm/modules/attention.py +266 -0
  58. magic123-0.1.0/ldm/modules/diffusionmodules/__init__.py +0 -0
  59. magic123-0.1.0/ldm/modules/diffusionmodules/model.py +835 -0
  60. magic123-0.1.0/ldm/modules/diffusionmodules/openaimodel.py +996 -0
  61. magic123-0.1.0/ldm/modules/diffusionmodules/util.py +267 -0
  62. magic123-0.1.0/ldm/modules/distributions/__init__.py +0 -0
  63. magic123-0.1.0/ldm/modules/distributions/distributions.py +92 -0
  64. magic123-0.1.0/ldm/modules/ema.py +76 -0
  65. magic123-0.1.0/ldm/modules/encoders/__init__.py +0 -0
  66. magic123-0.1.0/ldm/modules/encoders/modules.py +550 -0
  67. magic123-0.1.0/ldm/modules/evaluate/adm_evaluator.py +676 -0
  68. magic123-0.1.0/ldm/modules/evaluate/evaluate_perceptualsim.py +630 -0
  69. magic123-0.1.0/ldm/modules/evaluate/frechet_video_distance.py +147 -0
  70. magic123-0.1.0/ldm/modules/evaluate/ssim.py +124 -0
  71. magic123-0.1.0/ldm/modules/evaluate/torch_frechet_video_distance.py +294 -0
  72. magic123-0.1.0/ldm/modules/image_degradation/__init__.py +2 -0
  73. magic123-0.1.0/ldm/modules/image_degradation/bsrgan.py +730 -0
  74. magic123-0.1.0/ldm/modules/image_degradation/bsrgan_light.py +650 -0
  75. magic123-0.1.0/ldm/modules/image_degradation/utils_image.py +916 -0
  76. magic123-0.1.0/ldm/modules/losses/__init__.py +1 -0
  77. magic123-0.1.0/ldm/modules/losses/contperceptual.py +111 -0
  78. magic123-0.1.0/ldm/modules/losses/vqperceptual.py +167 -0
  79. magic123-0.1.0/ldm/modules/x_transformer.py +641 -0
  80. magic123-0.1.0/ldm/thirdp/psp/helpers.py +121 -0
  81. magic123-0.1.0/ldm/thirdp/psp/id_loss.py +23 -0
  82. magic123-0.1.0/ldm/thirdp/psp/model_irse.py +86 -0
  83. magic123-0.1.0/ldm/util.py +227 -0
  84. magic123-0.1.0/magic123.egg-info/PKG-INFO +426 -0
  85. magic123-0.1.0/magic123.egg-info/SOURCES.txt +212 -0
  86. magic123-0.1.0/magic123.egg-info/dependency_links.txt +1 -0
  87. magic123-0.1.0/magic123.egg-info/requires.txt +45 -0
  88. magic123-0.1.0/magic123.egg-info/top_level.txt +22 -0
  89. magic123-0.1.0/main.py +630 -0
  90. magic123-0.1.0/meshutils.py +117 -0
  91. magic123-0.1.0/midas/__init__.py +1 -0
  92. magic123-0.1.0/midas/backbones/beit.py +196 -0
  93. magic123-0.1.0/midas/backbones/levit.py +106 -0
  94. magic123-0.1.0/midas/backbones/next_vit.py +39 -0
  95. magic123-0.1.0/midas/backbones/swin.py +13 -0
  96. magic123-0.1.0/midas/backbones/swin2.py +34 -0
  97. magic123-0.1.0/midas/backbones/swin_common.py +52 -0
  98. magic123-0.1.0/midas/backbones/utils.py +249 -0
  99. magic123-0.1.0/midas/backbones/vit.py +221 -0
  100. magic123-0.1.0/midas/base_model.py +16 -0
  101. magic123-0.1.0/midas/blocks.py +439 -0
  102. magic123-0.1.0/midas/dpt_depth.py +166 -0
  103. magic123-0.1.0/midas/midas_net.py +76 -0
  104. magic123-0.1.0/midas/midas_net_custom.py +128 -0
  105. magic123-0.1.0/midas/model_loader.py +242 -0
  106. magic123-0.1.0/midas/transforms.py +234 -0
  107. magic123-0.1.0/nerf/clip.py +127 -0
  108. magic123-0.1.0/nerf/gui.py +485 -0
  109. magic123-0.1.0/nerf/network.py +238 -0
  110. magic123-0.1.0/nerf/network_grid.py +216 -0
  111. magic123-0.1.0/nerf/network_grid_taichi.py +161 -0
  112. magic123-0.1.0/nerf/network_grid_tcnn.py +178 -0
  113. magic123-0.1.0/nerf/provider.py +329 -0
  114. magic123-0.1.0/nerf/renderer.py +1575 -0
  115. magic123-0.1.0/nerf/utils.py +1599 -0
  116. magic123-0.1.0/optimizer.py +325 -0
  117. magic123-0.1.0/preprocess_image.py +279 -0
  118. magic123-0.1.0/pretrained/zero123/sd-objaverse-finetune-c_concat-256.yaml +117 -0
  119. magic123-0.1.0/pyproject.toml +108 -0
  120. magic123-0.1.0/raymarching/__init__.py +1 -0
  121. magic123-0.1.0/raymarching/backend.py +41 -0
  122. magic123-0.1.0/raymarching/raymarching.py +398 -0
  123. magic123-0.1.0/raymarching/setup.py +36 -0
  124. magic123-0.1.0/raymarching/src/bindings.cpp +20 -0
  125. magic123-0.1.0/raymarching/src/raymarching.cu +934 -0
  126. magic123-0.1.0/raymarching/src/raymarching.h +19 -0
  127. magic123-0.1.0/readme.md +361 -0
  128. magic123-0.1.0/render/light.py +158 -0
  129. magic123-0.1.0/render/material.py +182 -0
  130. magic123-0.1.0/render/mesh.py +241 -0
  131. magic123-0.1.0/render/mlptexture.py +111 -0
  132. magic123-0.1.0/render/obj.py +179 -0
  133. magic123-0.1.0/render/regularizer.py +82 -0
  134. magic123-0.1.0/render/render.py +311 -0
  135. magic123-0.1.0/render/renderutils/__init__.py +11 -0
  136. magic123-0.1.0/render/renderutils/bsdf.py +151 -0
  137. magic123-0.1.0/render/renderutils/c_src/bsdf.cu +710 -0
  138. magic123-0.1.0/render/renderutils/c_src/bsdf.h +84 -0
  139. magic123-0.1.0/render/renderutils/c_src/common.cpp +74 -0
  140. magic123-0.1.0/render/renderutils/c_src/common.h +41 -0
  141. magic123-0.1.0/render/renderutils/c_src/cubemap.cu +350 -0
  142. magic123-0.1.0/render/renderutils/c_src/cubemap.h +38 -0
  143. magic123-0.1.0/render/renderutils/c_src/loss.cu +210 -0
  144. magic123-0.1.0/render/renderutils/c_src/loss.h +38 -0
  145. magic123-0.1.0/render/renderutils/c_src/mesh.cu +94 -0
  146. magic123-0.1.0/render/renderutils/c_src/mesh.h +23 -0
  147. magic123-0.1.0/render/renderutils/c_src/normal.cu +182 -0
  148. magic123-0.1.0/render/renderutils/c_src/normal.h +27 -0
  149. magic123-0.1.0/render/renderutils/c_src/tensor.h +92 -0
  150. magic123-0.1.0/render/renderutils/c_src/torch_bindings.cpp +1062 -0
  151. magic123-0.1.0/render/renderutils/c_src/vec3f.h +109 -0
  152. magic123-0.1.0/render/renderutils/c_src/vec4f.h +25 -0
  153. magic123-0.1.0/render/renderutils/loss.py +41 -0
  154. magic123-0.1.0/render/renderutils/ops.py +554 -0
  155. magic123-0.1.0/render/renderutils/tests/test_bsdf.py +296 -0
  156. magic123-0.1.0/render/renderutils/tests/test_cubemap.py +47 -0
  157. magic123-0.1.0/render/renderutils/tests/test_loss.py +61 -0
  158. magic123-0.1.0/render/renderutils/tests/test_mesh.py +90 -0
  159. magic123-0.1.0/render/renderutils/tests/test_perf.py +57 -0
  160. magic123-0.1.0/render/texture.py +186 -0
  161. magic123-0.1.0/render/util.py +465 -0
  162. magic123-0.1.0/requirements-torch201-cuda117.txt +249 -0
  163. magic123-0.1.0/requirements.txt +79 -0
  164. magic123-0.1.0/scripts/check_cuda_build_env.py +54 -0
  165. magic123-0.1.0/scripts/install_ext.sh +12 -0
  166. magic123-0.1.0/scripts/magic123/preprocess_folder.sh +6 -0
  167. magic123-0.1.0/scripts/magic123/run_2dprior.sh +75 -0
  168. magic123-0.1.0/scripts/magic123/run_2dprior_noinv.sh +73 -0
  169. magic123-0.1.0/scripts/magic123/run_2dprior_notextinv_ironman.sh +73 -0
  170. magic123-0.1.0/scripts/magic123/run_3dprior.sh +73 -0
  171. magic123-0.1.0/scripts/magic123/run_both_priors.sh +76 -0
  172. magic123-0.1.0/scripts/magic123/run_both_priors_angle60.sh +82 -0
  173. magic123-0.1.0/scripts/magic123/run_both_priors_camera.sh +80 -0
  174. magic123-0.1.0/scripts/magic123/run_both_priors_nodepth.sh +87 -0
  175. magic123-0.1.0/scripts/magic123/run_both_priors_noinv.sh +74 -0
  176. magic123-0.1.0/scripts/magic123/run_both_priors_nonorm.sh +87 -0
  177. magic123-0.1.0/scripts/magic123/run_both_priors_noreg.sh +82 -0
  178. magic123-0.1.0/scripts/magic123/run_folder_both_priors.sh +13 -0
  179. magic123-0.1.0/scripts/magic123/run_list_both_priors.sh +27 -0
  180. magic123-0.1.0/scripts/magic123/smoke_train_ironman_10_steps.sh +30 -0
  181. magic123-0.1.0/scripts/textual_inversion/textual_inversion.sh +52 -0
  182. magic123-0.1.0/scripts/textual_inversion/textual_inversion_list.sh +22 -0
  183. magic123-0.1.0/setup.cfg +4 -0
  184. magic123-0.1.0/setup_cuda_ext.py +129 -0
  185. magic123-0.1.0/shencoder/__init__.py +1 -0
  186. magic123-0.1.0/shencoder/backend.py +41 -0
  187. magic123-0.1.0/shencoder/setup.py +24 -0
  188. magic123-0.1.0/shencoder/sphere_harmonics.py +87 -0
  189. magic123-0.1.0/shencoder/src/bindings.cpp +8 -0
  190. magic123-0.1.0/shencoder/src/shencoder.cu +439 -0
  191. magic123-0.1.0/shencoder/src/shencoder.h +10 -0
  192. magic123-0.1.0/taichi_modules/__init__.py +5 -0
  193. magic123-0.1.0/taichi_modules/hash_encoder.py +305 -0
  194. magic123-0.1.0/taichi_modules/intersection.py +68 -0
  195. magic123-0.1.0/taichi_modules/ray_march.py +340 -0
  196. magic123-0.1.0/taichi_modules/utils.py +224 -0
  197. magic123-0.1.0/taichi_modules/volume_render_test.py +48 -0
  198. magic123-0.1.0/taichi_modules/volume_train.py +239 -0
  199. magic123-0.1.0/taming/lr_scheduler.py +34 -0
  200. magic123-0.1.0/taming/models/cond_transformer.py +352 -0
  201. magic123-0.1.0/taming/models/dummy_cond_stage.py +22 -0
  202. magic123-0.1.0/taming/models/vqgan.py +404 -0
  203. magic123-0.1.0/taming/modules/diffusionmodules/model.py +776 -0
  204. magic123-0.1.0/taming/modules/discriminator/model.py +67 -0
  205. magic123-0.1.0/taming/modules/losses/__init__.py +2 -0
  206. magic123-0.1.0/taming/modules/losses/lpips.py +123 -0
  207. magic123-0.1.0/taming/modules/losses/segmentation.py +22 -0
  208. magic123-0.1.0/taming/modules/losses/vqperceptual.py +136 -0
  209. magic123-0.1.0/taming/modules/misc/coord.py +31 -0
  210. magic123-0.1.0/taming/modules/transformer/mingpt.py +415 -0
  211. magic123-0.1.0/taming/modules/transformer/permuter.py +248 -0
  212. magic123-0.1.0/taming/modules/util.py +130 -0
  213. magic123-0.1.0/taming/modules/vqvae/quantize.py +445 -0
  214. magic123-0.1.0/taming/util.py +157 -0
magic123-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,16 @@
1
+ include LICENSE
2
+ include readme.md
3
+ include requirements.txt
4
+ include requirements-torch201-cuda117.txt
5
+ include setup_cuda_ext.py
6
+ recursive-include assets *
7
+ recursive-include data/demo *
8
+ recursive-include docs/static *
9
+ recursive-include pretrained/zero123 *.yaml
10
+ recursive-include raymarching/src *.cpp *.cu *.h
11
+ recursive-include shencoder/src *.cpp *.cu *.h
12
+ recursive-include freqencoder/src *.cpp *.cu *.h
13
+ recursive-include gridencoder/src *.cpp *.cu *.h
14
+ recursive-include render/renderutils/c_src *.cpp *.cu *.h
15
+ recursive-include scripts *.sh *.py
16
+ global-exclude __pycache__ *.py[cod] .DS_Store
@@ -0,0 +1,426 @@
1
+ Metadata-Version: 2.4
2
+ Name: magic123
3
+ Version: 0.1.0
4
+ Summary: Magic123: one image to high-quality 3D object generation using 2D and 3D diffusion priors.
5
+ Author: Guocheng Qian
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://guochengqian.github.io/project/magic123/
8
+ Project-URL: Repository, https://github.com/guochengqian/Magic123
9
+ Project-URL: Issues, https://github.com/guochengqian/Magic123/issues
10
+ Keywords: 3d-generation,diffusion,nerf,cuda,pytorch
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: tqdm
22
+ Requires-Dist: rich
23
+ Requires-Dist: ninja
24
+ Requires-Dist: numpy
25
+ Requires-Dist: scipy
26
+ Requires-Dist: scikit-learn
27
+ Requires-Dist: matplotlib
28
+ Requires-Dist: opencv-python
29
+ Requires-Dist: imageio
30
+ Requires-Dist: imageio-ffmpeg
31
+ Requires-Dist: pandas
32
+ Requires-Dist: torch
33
+ Requires-Dist: torchvision
34
+ Requires-Dist: torch-ema
35
+ Requires-Dist: einops
36
+ Requires-Dist: tensorboard
37
+ Requires-Dist: tensorboardX
38
+ Requires-Dist: dearpygui
39
+ Requires-Dist: huggingface_hub
40
+ Requires-Dist: diffusers>=0.9.0
41
+ Requires-Dist: accelerate
42
+ Requires-Dist: transformers
43
+ Requires-Dist: xatlas
44
+ Requires-Dist: PyMCubes
45
+ Requires-Dist: rembg
46
+ Requires-Dist: omegaconf
47
+ Requires-Dist: pytorch-lightning
48
+ Requires-Dist: taming-transformers-rom1504
49
+ Requires-Dist: kornia
50
+ Requires-Dist: gdown
51
+ Requires-Dist: trimesh
52
+ Requires-Dist: pymeshlab==2022.2.post4
53
+ Requires-Dist: timm==0.6.7
54
+ Requires-Dist: easydict
55
+ Requires-Dist: wandb
56
+ Requires-Dist: termcolor
57
+ Requires-Dist: sentencepiece
58
+ Requires-Dist: psutil
59
+ Requires-Dist: lpips
60
+ Provides-Extra: cuda
61
+ Provides-Extra: dev
62
+ Requires-Dist: build; extra == "dev"
63
+ Requires-Dist: twine; extra == "dev"
64
+ Dynamic: license-file
65
+
66
+ # Magic123: One Image to High-Quality 3D Object Generation Using Both 2D and 3D Diffusion Priors [ICLR 2024]
67
+
68
+ [arXiv](https://arxiv.org/abs/2306.17843) | [webpage](https://guochengqian.github.io/project/magic123/)
69
+
70
+ <img src="docs/static/magic123.gif" width="800" />
71
+
72
+ [Guocheng Qian](https://guochengqian.github.io/) <sup>1,2</sup>, [Jinjie Mai](https://cemse.kaust.edu.sa/people/person/jinjie-mai) <sup>1</sup>, [Abdullah Hamdi](https://abdullahamdi.com/) <sup>3</sup>, [Jian Ren](https://alanspike.github.io/) <sup>2</sup>, [Aliaksandr Siarohin](https://aliaksandrsiarohin.github.io/aliaksandr-siarohin-website/) <sup>2</sup>, [Bing Li](https://cemse.kaust.edu.sa/people/person/bing-li) <sup>1</sup>, [Hsin-Ying Lee](http://hsinyinglee.com/) <sup>2</sup>, [Ivan Skorokhodov](https://universome.github.io/) <sup>1,2</sup>, [Peter Wonka](https://peterwonka.net/) <sup>1</sup>, [Sergey Tulyakov](http://www.stulyakov.com/) <sup>2</sup>, [Bernard Ghanem](https://www.bernardghanem.com/) <sup>1</sup>
73
+
74
+ <sup>1</sup> [King Abdullah University of Science and Technology (KAUST)](https://www.kaust.edu.sa/),
75
+ <sup>2</sup> [Snap Inc.](https://www.snap.com/),
76
+ <sup>3</sup> [Visual Geometry Group, University of Oxford](http://www.robots.ox.ac.uk/~vgg/)
77
+
78
+
79
+ Training convergence of a demo example:
80
+ <img src="docs/static/ironman-val-magic123.gif" width="800" />
81
+
82
+
83
+ Compare Magic123 without textual inversion with abaltions using only 2D prior (SDS) or using only 3D prior (Zero123):
84
+
85
+
86
+ https://github.com/guochengqian/Magic123/assets/48788073/c91f4c81-8c2c-4f84-8ce1-420c12f7e886
87
+
88
+
89
+ Effects of Joint Prior. Increasing the strength of 2D prior leads to more imagination, more details, and less 3D consistencies.
90
+
91
+ <img src="docs/static/2d_3d.png" width="800" />
92
+
93
+
94
+
95
+
96
+ https://github.com/guochengqian/Magic123/assets/48788073/98cb4dd7-7bf3-4179-9b6d-e8b47d928a68
97
+
98
+
99
+ Official PyTorch Implementation of Magic123: One Image to High-Quality 3D Object Generation Using Both 2D and 3D Diffusion Priors. Code is built upon [Stable-DreamFusion](https://github.com/ashawkey/stable-dreamfusion) repo.
100
+
101
+
102
+ # NEWS:
103
+ - [2024/01/16] Magic123 gets accepted to ICLR24
104
+ - [2023/07/25] Code is available at [GitHub](https://github.com/guochengqian/Magic123)
105
+ - [2023/07/03] Paper is available at [arXiv](https://arxiv.org/abs/2306.17843)
106
+ - [2023/06/25] Much better performance than the submitted version is achieved by 1)reimplementing Magic123 using [Stable DreamFusion code](https://github.com/ashawkey/stable-dreamfusion), 2)fixing some gradient issues, 3)leveraging the [tricks](#tips-and-tricks)
107
+ - [2023] Initial version of Magic123 submitted to conference
108
+
109
+
110
+ # Install
111
+ We only test on Ubuntu system. Make sure git, wget, Eigen are installed.
112
+ ```
113
+ apt update && apt upgrade
114
+ apt install git wget libeigen3-dev python3-dev python3-venv -y
115
+ ```
116
+
117
+ ### Install from PyPI
118
+
119
+ ```bash
120
+ python -m venv venv_magic123
121
+ source venv_magic123/bin/activate
122
+ python -m pip install --upgrade pip setuptools wheel
123
+ python -m pip install magic123
124
+
125
+ # Build the CUDA extensions after installing PyTorch. 4090/4090 Ti uses SM 8.9.
126
+ export CUDA_HOME=${CUDA_HOME:-/usr/local/cuda-12.9}
127
+ export PATH=$CUDA_HOME/bin:$PATH
128
+ export TORCH_CUDA_ARCH_LIST=${TORCH_CUDA_ARCH_LIST:-8.9}
129
+ git clone https://github.com/guochengqian/Magic123.git
130
+ cd Magic123
131
+ bash scripts/install_ext.sh
132
+ ```
133
+
134
+ The PyPI package ships the Python project and source code for the CUDA extensions. The extension modules are compiled locally because PyTorch CUDA extension wheels must match the local Python, PyTorch, CUDA toolkit, compiler, and GPU architecture.
135
+
136
+ ### CUDA and Windows notes
137
+
138
+ - NVIDIA RTX 4090 and 4090 Ti builds should set `TORCH_CUDA_ARCH_LIST=8.9`.
139
+ - The CUDA toolkit must provide `nvcc`; check with `python scripts/check_cuda_build_env.py`.
140
+ - Building the PyTorch CUDA extensions also requires Python development headers. On Ubuntu/Debian install `python3-dev` or the version-specific package such as `python3.10-dev`.
141
+ - On Windows, install Visual Studio Build Tools with the "Desktop development with C++" workload and run installation from a Developer PowerShell or Developer Command Prompt. The setup scripts use `vswhere`/Visual Studio discovery to locate `cl.exe`, but CUDA still requires a Visual Studio version supported by the installed CUDA toolkit.
142
+ - On Colab, install PyTorch and the matching CUDA toolkit first, then run `bash scripts/install_ext.sh`. If Colab changes its compiler or CUDA image, rebuild the extensions with `--no-cache-dir`.
143
+
144
+ ### Install Environment
145
+
146
+ ```bash
147
+ source install.sh
148
+ ```
149
+ Note: in this `install.sh`, we use python venv by default. If you prefer conda, uncomment the conda and comment venv in the file and run the same command.
150
+
151
+
152
+ ### Download pre-trained models
153
+
154
+ * [Zero-1-to-3](https://github.com/cvlab-columbia/zero123) for 3D diffusion prior.
155
+ We use `105000.ckpt` by default, reimplementation borrowed from Stable Diffusion repo, and is available in `guidance/zero123_utils.py`.
156
+ ```bash
157
+ cd pretrained/zero123
158
+ wget https://huggingface.co/cvlab/zero123-weights/resolve/main/105000.ckpt
159
+ cd ../../
160
+ ```
161
+
162
+ * [MiDaS](https://github.com/isl-org/MiDaS) for depth estimation.
163
+ We use `dpt_beit_large_512.pt`. Put it in folder `pretrained/midas/`
164
+ ```bash
165
+ mkdir -p pretrained/midas
166
+ cd pretrained/midas
167
+ wget https://github.com/isl-org/MiDaS/releases/download/v3_1/dpt_beit_large_512.pt
168
+ cd ../../
169
+ ```
170
+
171
+ # Usage
172
+ ## Preprocess [Optional]
173
+ We have included all preprocessed files in `./data` directory. Preprocessing is only necessary if you want to test on your own examples. Takes seconds.
174
+
175
+ ### Step1: Extract depth
176
+ ```
177
+ python preprocess_image.py --path /path/to/image
178
+ ```
179
+
180
+
181
+ ### Step 2: textual inversion [Optional]
182
+ Magic123 uses the default [textual inversion](https://huggingface.co/docs/diffusers/training/text_inversion) from diffuers, which consumes around 2 hours on a 32G V100. If you do not want to spend time in this textual inversion, you can: (1) study whether there is other faster textual inversion; or (2) do not use textual inversion in the loss of texture and shape consistencies. To run textual inversion:
183
+
184
+ ```
185
+ bash scripts/textual_inversion/textual_inversion.sh $GPU_IDX runwayml/stable-diffusion-v1-5 /path/to/example/rgba.png /path/to/save $token_name $init_token --max_train_steps 5000
186
+ ```
187
+ $token_name is a the special token, usually name that by _examplename_
188
+ $init_token is a single token to describe the image using natural language
189
+
190
+ For example:
191
+ ```bash
192
+ bash scripts/textual_inversion/textual_inversion.sh runwayml/stable-diffusion-v1-5 data/demo/a-full-body-ironman/rgba.png out/textual_inversion/ironman _ironman_ ironman --max_train_steps 3000
193
+ ```
194
+ Don't forget to move the final `learned_embeds.bin` under data/demo/a-full-body-ironman/
195
+
196
+
197
+ ## Run
198
+ ### Run Magic123 for a single example
199
+ Takes ~40 mins for the coarse stage and ~20 mins for the second stage on a 32G V100.
200
+ ```bash
201
+ bash scripts/magic123/run_both_priors.sh $GPU_NO $JOBNAME_First_Stage $JOBNAME_Second_Stage $PATH_to_Example_Directory $IMAGE_BASE_NAME $Enable_First_Stage $Enable_Second_Stage {More_Arugments}
202
+ ```
203
+
204
+ As an example, run Magic123 in the dragon example using both stages in GPU 0 and set the jobname for the first stage as `nerf` and the jobname for the second stage as `dmtet`, by the following command:
205
+ ```bash
206
+ bash scripts/magic123/run_both_priors.sh 0 nerf dmtet data/realfusion15/metal_dragon_statue 1 1
207
+ ```
208
+
209
+ More arguments (e.g. `--lambda_guidance 1 40`) can be appended to the command line such as:
210
+ ```bash
211
+ bash scripts/magic123/run_both_priors.sh 0 nerf dmtet data/realfusion15/metal_dragon_statue 1 1 --lambda_guidance 1 40
212
+ ```
213
+
214
+ ### Run Magic123 for a group of examples
215
+ - Run all examples in a folder, check the scripts `scripts/magic123/run_folder_both_priors.sh`
216
+ - Run all examples in a given list, check the scripts `scripts/magic123/run_list_both_priors.sh`
217
+
218
+
219
+ ### Run Magic123 on a single example without textual inversion
220
+ textual inversion is tedious (requires ~2.5 hours optimization), if you want to test Magic123 quickly on your own example without textual inversion (might degrade the performance), try the following:
221
+
222
+ - first, foreground and depth estimation
223
+ ```
224
+ python preprocess_image.py --path data/demo/a-full-body-ironman/main.png
225
+ ```
226
+
227
+ - Run Magic123 coarse stage without textual inversion, takes ~40 mins
228
+ ```
229
+ export RUN_ID='default-a-full-body-ironman'
230
+ export DATA_DIR='data/demo/a-full-body-ironman'
231
+ export IMAGE_NAME='rgba.png'
232
+ export FILENAME=$(basename $DATA_DIR)
233
+ export dataset=$(basename $(dirname $DATA_DIR))
234
+ CUDA_VISIBLE_DEVICES=0 python main.py -O \
235
+ --text "A high-resolution DSLR image of a full body ironman" \
236
+ --sd_version 1.5 \
237
+ --image ${DATA_DIR}/${IMAGE_NAME} \
238
+ --workspace out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse \
239
+ --optim adam \
240
+ --iters 5000 \
241
+ --guidance SD zero123 \
242
+ --lambda_guidance 1.0 40 \
243
+ --guidance_scale 100 5 \
244
+ --latent_iter_ratio 0 \
245
+ --normal_iter_ratio 0.2 \
246
+ --t_range 0.2 0.6 \
247
+ --bg_radius -1 \
248
+ --save_mesh
249
+ ```
250
+
251
+ - Run Magic123 fine stage without textual inversion, takes around ~20 mins
252
+ ```
253
+ export RUN_ID='default-a-full-body-ironman'
254
+ export RUN_ID2='dmtet'
255
+ export DATA_DIR='data/demo/a-full-body-ironman'
256
+ export IMAGE_NAME='rgba.png'
257
+ export FILENAME=$(basename $DATA_DIR)
258
+ export dataset=$(basename $(dirname $DATA_DIR))
259
+ CUDA_VISIBLE_DEVICES=0 python main.py -O \
260
+ --text "A high-resolution DSLR image of a full body ironman" \
261
+ --sd_version 1.5 \
262
+ --image ${DATA_DIR}/${IMAGE_NAME} \
263
+ --workspace out/magic123-${RUN_ID}-${RUN_ID2}/$dataset/magic123_${FILENAME}_${RUN_ID}_${RUN_ID2} \
264
+ --dmtet --init_ckpt out/magic123-${RUN_ID}-coarse/$dataset/magic123_${FILENAME}_${RUN_ID}_coarse/checkpoints/magic123_${FILENAME}_${RUN_ID}_coarse.pth \
265
+ --iters 5000 \
266
+ --optim adam \
267
+ --known_view_interval 4 \
268
+ --latent_iter_ratio 0 \
269
+ --guidance SD zero123 \
270
+ --lambda_guidance 1e-3 0.01 \
271
+ --guidance_scale 100 5 \
272
+ --rm_edge \
273
+ --bg_radius -1 \
274
+ --save_mesh
275
+ ```
276
+
277
+ ### 10-step CUDA smoke test on the Ironman example
278
+
279
+ After installing dependencies and CUDA extensions, run a short 4090-class smoke test:
280
+
281
+ ```bash
282
+ bash scripts/magic123/smoke_train_ironman_10_steps.sh 0 out/smoke-ironman-10-steps
283
+ ```
284
+
285
+ The script sets `TORCH_CUDA_ARCH_LIST=8.9`, runs `scripts/check_cuda_build_env.py`, trains for 10 iterations, and saves outputs under the workspace argument. The default workspace is `out/smoke-ironman-10-steps`.
286
+
287
+ ### Outputs and mesh export
288
+
289
+ Use `--save_mesh` to export the object. Coarse NeRF runs save mesh files under the run workspace, typically in a `mesh/` subdirectory, including `mesh.obj`, material, and texture files. DMTet fine-stage runs also write the final textured `.obj` assets under the fine-stage workspace. The `.mp4` files are render previews; the `.obj` plus its `.mtl` and texture images are the 3D object files to open in Blender, MeshLab, or another mesh viewer.
290
+
291
+ ### Run ablation studies
292
+ - Run Magic123 with only 2D prior *with* textual inversion (Like RealFusion but we achieve much better performance through training stragies and the coarse-to-fine pipeline)
293
+ ```
294
+ bash scripts/magic123/run_2dprior.sh 0 nerf dmtet data/realfusion15/metal_dragon_statue 1 1
295
+ ```
296
+
297
+ - Run Magic123 with only 2D prior *without* textual inversion (Like RealFusion but we achieve much better performance through training stragies and the coarse-to-fine pipeline)
298
+ ```
299
+ bash scripts/magic123/run_2dprior_notextinv_ironman.sh 0 default 1 1
300
+ ```
301
+ note: change the path and the text prompt inside the script if you wana test another example.
302
+
303
+ - Run Magic123 with only 3D prior (Like Zero-1-to-3 but we achieve much better performance through training stragies and the coarse-to-fine pipeline)
304
+ ```
305
+ bash scripts/magic123/run_3dprior.sh 0 nerf dmtet data/demo/a-full-body-ironman 1 1
306
+ ```
307
+
308
+
309
+ # Tips and Tricks
310
+ 1. Fix camera distance (*radius_range*) and FOV (*fovy_range*) and tune the camera polar range (*theta_range*). Note it is better to keep camera jittering to reduce grid artifacts.
311
+ 2. Smaller range of time steps for the defusion noise (t_range). We find *[0.2, 0.6]* gives better performance for image-to-3D tasks.
312
+ 3. Using normals as latent in the first 2000 improves generated geometry a bit gernerally (but not always). We turn on this for Magic123 corase stage in the script `--normal_iter_ratio 0.2`
313
+ 4. We erode segmentation edges (makes the segmentation map 2 pixels shrinked towards internal side) to remove artifacts due to segmentation erros. This is turned on in the fine stage in magic123 in the script through `--rm_edge`
314
+ 5. Other general tricks such as improved textual inversion, advanced diffusion prior (DeepFloyd, SD-XL), stronger 3D prior (Zero123-XL), and larger batch size can be adopted as well but not studied in this work.
315
+ 6. textual inversion is not very necessary for well-known things (e.g. ironman) and easily described textures and geoemtries, since pure texts contains these texture information and will be understood by diffusion models. We use textual inversion by default in all experiments.
316
+
317
+
318
+ # Some Projects that use Magic123
319
+ 1. [Threestudio](https://github.com/threestudio-project/threestudio)
320
+ 2. [DreamCraft3D](https://mrtornado24.github.io/DreamCraft3D/)
321
+
322
+ # Acknowledgement
323
+ This work is build upon Stable DreamFusion, many thanks to the author [Kiui Jiaxiang Tang](https://github.com/ashawkey) and many other contributors.
324
+
325
+ * [Stable DreamFusion](https://github.com/ashawkey/stable-dreamfusion)
326
+
327
+ ```
328
+ @misc{stable-dreamfusion,
329
+ Author = {Jiaxiang Tang},
330
+ Year = {2022},
331
+ Note = {https://github.com/ashawkey/stable-dreamfusion},
332
+ Title = {Stable-dreamfusion: Text-to-3D with Stable-diffusion}
333
+ }
334
+ ```
335
+
336
+
337
+ We also get inspirations from a list of amazing research works and open-source projects, thanks a lot to all the authors for sharing!
338
+
339
+ * [DreamFusion: Text-to-3D using 2D Diffusion](https://dreamfusion3d.github.io/)
340
+ ```
341
+ @article{poole2022dreamfusion,
342
+ author = {Poole, Ben and Jain, Ajay and Barron, Jonathan T. and Mildenhall, Ben},
343
+ title = {DreamFusion: Text-to-3D using 2D Diffusion},
344
+ journal = {arXiv},
345
+ year = {2022},
346
+ }
347
+ ```
348
+
349
+ * [Magic3D: High-Resolution Text-to-3D Content Creation](https://research.nvidia.com/labs/dir/magic3d/)
350
+ ```
351
+ @inproceedings{lin2023magic3d,
352
+ title={Magic3D: High-Resolution Text-to-3D Content Creation},
353
+ author={Lin, Chen-Hsuan and Gao, Jun and Tang, Luming and Takikawa, Towaki and Zeng, Xiaohui and Huang, Xun and Kreis, Karsten and Fidler, Sanja and Liu, Ming-Yu and Lin, Tsung-Yi},
354
+ booktitle={IEEE Conference on Computer Vision and Pattern Recognition ({CVPR})},
355
+ year={2023}
356
+ }
357
+ ```
358
+
359
+ * [Zero-1-to-3: Zero-shot One Image to 3D Object](https://github.com/cvlab-columbia/zero123)
360
+ ```
361
+ @misc{liu2023zero1to3,
362
+ title={Zero-1-to-3: Zero-shot One Image to 3D Object},
363
+ author={Ruoshi Liu and Rundi Wu and Basile Van Hoorick and Pavel Tokmakov and Sergey Zakharov and Carl Vondrick},
364
+ year={2023},
365
+ eprint={2303.11328},
366
+ archivePrefix={arXiv},
367
+ primaryClass={cs.CV}
368
+ }
369
+ ```
370
+
371
+ * [RealFusion: 360° Reconstruction of Any Object from a Single Image](https://github.com/lukemelas/realfusion)
372
+ ```
373
+ @inproceedings{melaskyriazi2023realfusion,
374
+ author = {Melas-Kyriazi, Luke and Rupprecht, Christian and Laina, Iro and Vedaldi, Andrea},
375
+ title = {RealFusion: 360 Reconstruction of Any Object from a Single Image},
376
+ booktitle={CVPR}
377
+ year = {2023},
378
+ url = {https://arxiv.org/abs/2302.10663},
379
+ }
380
+ ```
381
+
382
+ * [Make-it-3d: High-fidelity 3d creation from a single image with diffusion prior](https://arxiv.org/abs/2303.14184)
383
+ ```
384
+ @article{tang2023make-it-3d,
385
+ title={Make-it-3d: High-fidelity 3d creation from a single image with diffusion prior},
386
+ author={Tang, Junshu and Wang, Tengfei and Zhang, Bo and Zhang, Ting and Yi, Ran and Ma, Lizhuang and Chen, Dong},
387
+ journal={arXiv preprint arXiv:2303.14184},
388
+ year={2023}
389
+ }
390
+ ```
391
+
392
+ * [Stable Diffusion](https://github.com/CompVis/stable-diffusion) and the [diffusers](https://github.com/huggingface/diffusers) library.
393
+
394
+ ```
395
+ @misc{rombach2021highresolution,
396
+ title={High-Resolution Image Synthesis with Latent Diffusion Models},
397
+ author={Robin Rombach and Andreas Blattmann and Dominik Lorenz and Patrick Esser and Björn Ommer},
398
+ year={2021},
399
+ eprint={2112.10752},
400
+ archivePrefix={arXiv},
401
+ primaryClass={cs.CV}
402
+ }
403
+
404
+ @misc{von-platen-etal-2022-diffusers,
405
+ author = {Patrick von Platen and Suraj Patil and Anton Lozhkov and Pedro Cuenca and Nathan Lambert and Kashif Rasul and Mishig Davaadorj and Thomas Wolf},
406
+ title = {Diffusers: State-of-the-art diffusion models},
407
+ year = {2022},
408
+ publisher = {GitHub},
409
+ journal = {GitHub repository},
410
+ howpublished = {\url{https://github.com/huggingface/diffusers}}
411
+ }
412
+ ```
413
+
414
+
415
+ # Cite
416
+ If you find this work useful, a citation will be appreciated via:
417
+ ```
418
+ @inproceedings{
419
+ Magic123,
420
+ title={Magic123: One Image to High-Quality 3D Object Generation Using Both 2D and 3D Diffusion Priors},
421
+ author={Qian, Guocheng and Mai, Jinjie and Hamdi, Abdullah and Ren, Jian and Siarohin, Aliaksandr and Li, Bing and Lee, Hsin-Ying and Skorokhodov, Ivan and Wonka, Peter and Tulyakov, Sergey and Ghanem, Bernard},
422
+ booktitle={The Twelfth International Conference on Learning Representations (ICLR)},
423
+ year={2024},
424
+ url={https://openreview.net/forum?id=0jHkUDyEO9}
425
+ }
426
+ ```
@@ -0,0 +1,21 @@
1
+ import torch
2
+ from torch.autograd import Function
3
+ from torch.cuda.amp import custom_bwd, custom_fwd
4
+
5
+ class _trunc_exp(Function):
6
+ @staticmethod
7
+ @custom_fwd(cast_inputs=torch.float)
8
+ def forward(ctx, x):
9
+ ctx.save_for_backward(x)
10
+ return torch.exp(x)
11
+
12
+ @staticmethod
13
+ @custom_bwd
14
+ def backward(ctx, g):
15
+ x = ctx.saved_tensors[0]
16
+ return g * torch.exp(x.clamp(max=15))
17
+
18
+ trunc_exp = _trunc_exp.apply
19
+
20
+ def biased_softplus(x, bias=0):
21
+ return torch.nn.functional.softplus(x - bias)