diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000000000000000000000000000000000000..a6344aac8c09253b3b630fb776ae94478aa0275b
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,35 @@
+*.7z filter=lfs diff=lfs merge=lfs -text
+*.arrow filter=lfs diff=lfs merge=lfs -text
+*.bin filter=lfs diff=lfs merge=lfs -text
+*.bz2 filter=lfs diff=lfs merge=lfs -text
+*.ckpt filter=lfs diff=lfs merge=lfs -text
+*.ftz filter=lfs diff=lfs merge=lfs -text
+*.gz filter=lfs diff=lfs merge=lfs -text
+*.h5 filter=lfs diff=lfs merge=lfs -text
+*.joblib filter=lfs diff=lfs merge=lfs -text
+*.lfs.* filter=lfs diff=lfs merge=lfs -text
+*.mlmodel filter=lfs diff=lfs merge=lfs -text
+*.model filter=lfs diff=lfs merge=lfs -text
+*.msgpack filter=lfs diff=lfs merge=lfs -text
+*.npy filter=lfs diff=lfs merge=lfs -text
+*.npz filter=lfs diff=lfs merge=lfs -text
+*.onnx filter=lfs diff=lfs merge=lfs -text
+*.ot filter=lfs diff=lfs merge=lfs -text
+*.parquet filter=lfs diff=lfs merge=lfs -text
+*.pb filter=lfs diff=lfs merge=lfs -text
+*.pickle filter=lfs diff=lfs merge=lfs -text
+*.pkl filter=lfs diff=lfs merge=lfs -text
+*.pt filter=lfs diff=lfs merge=lfs -text
+*.pth filter=lfs diff=lfs merge=lfs -text
+*.rar filter=lfs diff=lfs merge=lfs -text
+*.safetensors filter=lfs diff=lfs merge=lfs -text
+saved_model/**/* filter=lfs diff=lfs merge=lfs -text
+*.tar.* filter=lfs diff=lfs merge=lfs -text
+*.tar filter=lfs diff=lfs merge=lfs -text
+*.tflite filter=lfs diff=lfs merge=lfs -text
+*.tgz filter=lfs diff=lfs merge=lfs -text
+*.wasm filter=lfs diff=lfs merge=lfs -text
+*.xz filter=lfs diff=lfs merge=lfs -text
+*.zip filter=lfs diff=lfs merge=lfs -text
+*.zst filter=lfs diff=lfs merge=lfs -text
+*tfevents* filter=lfs diff=lfs merge=lfs -text
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..e384d092207c525d6951c7f8d31b19c2bceea787
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,263 @@
+Licences of the files in moonbox-dev/moebius
+
+Each part of this repository keeps the licence of the work it was made from. The sections below say which parts each licence covers, with the notices to keep, followed by the licence's full text.
+
+====================================================================================================
+Apache License 2.0
+https://www.apache.org/licenses/LICENSE-2.0
+
+Covers:
+ - Moebius 0.22B inpainting UNet, variant 'pretrained' (General)
+ Notice: Copyright 2024 Moebius Authors
+ - Moebius fine-tune 'ft_places2' (Scenes)
+ Notice: Copyright 2024 Moebius Authors
+ - Moebius fine-tune 'ft_ffhq' (Faces)
+ Notice: Copyright 2024 Moebius Authors
+ - the three UNets and the VAE as ONNX graphs, for the Windows engine
+ - SAM 2.1 Hiera Tiny, used to select objects (Windows engine)
+ Notice: Copyright (c) Meta Platforms, Inc. and affiliates
+====================================================================================================
+
+Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+====================================================================================================
+MIT License
+https://opensource.org/license/mit
+
+Covers:
+ - PixelHacker VAE (frozen SDXL VAE), fp16 + Core ML
+ Notice: PixelHacker authors (HUST Vision Lab); the SDXL VAE is Copyright (c) Stability AI, MIT
+ - the three UNets and the VAE as ONNX graphs, for the Windows engine
+ - BiRefNet, used to select a picture's subject (Windows engine)
+ Notice: Copyright (c) 2024 ZhengPeng
+====================================================================================================
+
+MIT License
+
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+====================================================================================================
+BSD 3-Clause License
+https://opensource.org/license/bsd-3-clause
+
+Covers:
+ - torchvision's Mask R-CNN (ResNet-50 FPN v2, COCO) weights as safetensors (Windows engine)
+ Notice: Copyright (c) Soumith Chintala 2016, all rights reserved
+====================================================================================================
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..924a1d4f25a666731e47fea057f559184c2682f9
--- /dev/null
+++ b/README.md
@@ -0,0 +1,51 @@
+---
+license: apache-2.0
+base_model:
+ - hustvl/Moebius
+library_name: mlx
+pipeline_tag: image-to-image
+tags:
+ - mlx
+ - moonbox
+ - inpainting
+---
+
+# Moebius for Moonbox
+
+The files the [Moonbox](https://moonbox.dev) desktop app downloads for these models:
+
+- **Moebius** (HUST Vision Lab): Removes objects and repairs damage; everything outside the brushed area stays as it was.
+
+They are the Moebius inpainting UNets (General, Scenes, Faces) and their VAE converted to MLX and Core ML for Apple silicon. Moonbox checks every file against a signed list before using it. You do not need this repository to use Moonbox, and it is not an official release of the original models.
+
+## What is here
+
+| Path | What | From |
+|---|---|---|
+| `packs/moebius-general/unet.safetensors`, `packs/moebius-general/temb.npz`, `packs/moebius-general/manifest.json` | Moebius 0.22B inpainting UNet, variant 'pretrained' (General) | https://huggingface.co/hustvl/Moebius (pretrained/) |
+| `packs/moebius-places2/` | Moebius fine-tune 'ft_places2' (Scenes) | https://huggingface.co/hustvl/Moebius (ft_places2/) |
+| `packs/moebius-ffhq/` | Moebius fine-tune 'ft_ffhq' (Faces) | https://huggingface.co/hustvl/Moebius (ft_ffhq/) |
+| `packs/moebius-general/vae.safetensors`, `packs/moebius-general/coreml/` | PixelHacker VAE (frozen SDXL VAE), fp16 + Core ML | https://huggingface.co/hustvl/PixelHacker (vae/) |
+| `models/ort/` | the three UNets and the VAE as ONNX graphs, for the Windows engine | https://huggingface.co/hustvl/Moebius, https://huggingface.co/hustvl/PixelHacker |
+| `models/hf/BiRefNet/` | BiRefNet, used to select a picture's subject (Windows engine) | https://huggingface.co/ZhengPeng7/BiRefNet |
+| `models/hf/sam2.1-hiera-tiny/` | SAM 2.1 Hiera Tiny, used to select objects (Windows engine) | https://huggingface.co/facebook/sam2.1-hiera-tiny |
+| `models/torch/maskrcnn_resnet50_fpn_v2_coco.safetensors` | torchvision's Mask R-CNN (ResNet-50 FPN v2, COCO) weights as safetensors (Windows engine) | https://github.com/pytorch/vision |
+
+Every part was converted, quantized or repackaged from its source unless its row says "as published": treat none of these files as the original release.
+
+## Licences
+
+The Scenes and Faces fine-tunes were trained by their authors on Places2 and FFHQ, datasets released for research and non-commercial use; BiRefNet's general weights were trained on DIS5K, also non-commercial. The weights carry the licences below; whether the training data matters for your use is yours to judge.
+
+| Part | Licence | Notice |
+|---|---|---|
+| Moebius 0.22B inpainting UNet, variant 'pretrained' (General) | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) | Copyright 2024 Moebius Authors |
+| Moebius fine-tune 'ft_places2' (Scenes) | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) | Copyright 2024 Moebius Authors |
+| Moebius fine-tune 'ft_ffhq' (Faces) | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) | Copyright 2024 Moebius Authors |
+| PixelHacker VAE (frozen SDXL VAE), fp16 + Core ML | [MIT License](https://opensource.org/license/mit) | PixelHacker authors (HUST Vision Lab); the SDXL VAE is Copyright (c) Stability AI, MIT |
+| the three UNets and the VAE as ONNX graphs, for the Windows engine | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0); [MIT License](https://opensource.org/license/mit) | |
+| BiRefNet, used to select a picture's subject (Windows engine) | [MIT License](https://opensource.org/license/mit) | Copyright (c) 2024 ZhengPeng |
+| SAM 2.1 Hiera Tiny, used to select objects (Windows engine) | [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) | Copyright (c) Meta Platforms, Inc. and affiliates |
+| torchvision's Mask R-CNN (ResNet-50 FPN v2, COCO) weights as safetensors (Windows engine) | [BSD 3-Clause License](https://opensource.org/license/bsd-3-clause) | Copyright (c) Soumith Chintala 2016, all rights reserved |
+
+The full text of each licence is in [LICENSE](LICENSE). The models are the work of their authors, linked above. Moonbox converted and packaged them and claims no rights in them. Use is subject to each licence above.
diff --git a/models/hf/BiRefNet/README.md b/models/hf/BiRefNet/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..83cda9675fd4096e9b3a65bb4e1f8fa3d652929f
--- /dev/null
+++ b/models/hf/BiRefNet/README.md
@@ -0,0 +1,226 @@
+---
+library_name: birefnet
+tags:
+- background-removal
+- mask-generation
+- Dichotomous Image Segmentation
+- Camouflaged Object Detection
+- Salient Object Detection
+- pytorch_model_hub_mixin
+- model_hub_mixin
+- transformers
+repo_url: https://github.com/ZhengPeng7/BiRefNet
+pipeline_tag: image-segmentation
+license: mit
+---
+
Bilateral Reference for High-Resolution Dichotomous Image Segmentation
+
+
+
+
+ 1 Nankai University 2 Northwestern Polytechnical University 3 National University of Defense Technology 4 Aalto University 5 Shanghai AI Laboratory 6 University of Trento
+
+
+
+
+
+| *DIS-Sample_1* | *DIS-Sample_2* |
+| :------------------------------: | :-------------------------------: |
+|
|
|
+
+This repo is the official implementation of "[**Bilateral Reference for High-Resolution Dichotomous Image Segmentation**](https://arxiv.org/pdf/2401.03407.pdf)" (___CAAI AIR 2024___).
+
+Visit our GitHub repo: [https://github.com/ZhengPeng7/BiRefNet](https://github.com/ZhengPeng7/BiRefNet) for more details -- **codes**, **docs**, and **model zoo**!
+
+## How to use
+
+### 0. Install Packages:
+```
+pip install -qr https://raw.githubusercontent.com/ZhengPeng7/BiRefNet/main/requirements.txt
+```
+
+### 1. Load BiRefNet:
+
+#### Use codes + weights from HuggingFace
+> Only use the weights on HuggingFace -- Pro: No need to download BiRefNet codes manually; Con: Codes on HuggingFace might not be latest version (I'll try to keep them always latest).
+
+```python
+# Load BiRefNet with weights
+from transformers import AutoModelForImageSegmentation
+birefnet = AutoModelForImageSegmentation.from_pretrained('ZhengPeng7/BiRefNet', trust_remote_code=True)
+```
+
+#### Use codes from GitHub + weights from HuggingFace
+> Only use the weights on HuggingFace -- Pro: codes are always latest; Con: Need to clone the BiRefNet repo from my GitHub.
+
+```shell
+# Download codes
+git clone https://github.com/ZhengPeng7/BiRefNet.git
+cd BiRefNet
+```
+
+```python
+# Use codes locally
+from models.birefnet import BiRefNet
+
+# Load weights from Hugging Face Models
+birefnet = BiRefNet.from_pretrained('ZhengPeng7/BiRefNet')
+```
+
+#### Use codes from GitHub + weights from local space
+> Only use the weights and codes both locally.
+
+```python
+# Use codes and weights locally
+import torch
+from utils import check_state_dict
+
+birefnet = BiRefNet(bb_pretrained=False)
+state_dict = torch.load(PATH_TO_WEIGHT, map_location='cpu')
+state_dict = check_state_dict(state_dict)
+birefnet.load_state_dict(state_dict)
+```
+
+#### Use the loaded BiRefNet for inference
+```python
+# Imports
+from PIL import Image
+import matplotlib.pyplot as plt
+import torch
+from torchvision import transforms
+from models.birefnet import BiRefNet
+
+birefnet = ... # -- BiRefNet should be loaded with codes above, either way.
+torch.set_float32_matmul_precision(['high', 'highest'][0])
+birefnet.to('cuda')
+birefnet.eval()
+birefnet.half()
+
+def extract_object(birefnet, imagepath):
+ # Data settings
+ image_size = (1024, 1024)
+ transform_image = transforms.Compose([
+ transforms.Resize(image_size),
+ transforms.ToTensor(),
+ transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
+ ])
+
+ image = Image.open(imagepath)
+ input_images = transform_image(image).unsqueeze(0).to('cuda').half()
+
+ # Prediction
+ with torch.no_grad():
+ preds = birefnet(input_images)[-1].sigmoid().cpu()
+ pred = preds[0].squeeze()
+ pred_pil = transforms.ToPILImage()(pred)
+ mask = pred_pil.resize(image.size)
+ image.putalpha(mask)
+ return image, mask
+
+# Visualization
+plt.axis("off")
+plt.imshow(extract_object(birefnet, imagepath='PATH-TO-YOUR_IMAGE.jpg')[0])
+plt.show()
+
+```
+
+### 2. Use inference endpoint locally:
+> You may need to click the *deploy* and set up the endpoint by yourself, which would make some costs.
+```
+import requests
+import base64
+from io import BytesIO
+from PIL import Image
+
+
+YOUR_HF_TOKEN = 'xxx'
+API_URL = "xxx"
+headers = {
+ "Authorization": "Bearer {}".format(YOUR_HF_TOKEN)
+}
+
+def base64_to_bytes(base64_string):
+ # Remove the data URI prefix if present
+ if "data:image" in base64_string:
+ base64_string = base64_string.split(",")[1]
+
+ # Decode the Base64 string into bytes
+ image_bytes = base64.b64decode(base64_string)
+ return image_bytes
+
+def bytes_to_base64(image_bytes):
+ # Create a BytesIO object to handle the image data
+ image_stream = BytesIO(image_bytes)
+
+ # Open the image using Pillow (PIL)
+ image = Image.open(image_stream)
+ return image
+
+def query(payload):
+ response = requests.post(API_URL, headers=headers, json=payload)
+ return response.json()
+
+output = query({
+ "inputs": "https://hips.hearstapps.com/hmg-prod/images/gettyimages-1229892983-square.jpg",
+ "parameters": {}
+})
+
+output_image = bytes_to_base64(base64_to_bytes(output))
+output_image
+```
+
+
+> This BiRefNet for standard dichotomous image segmentation (DIS) is trained on **DIS-TR** and validated on **DIS-TEs and DIS-VD**.
+
+## This repo holds the official model weights of "[Bilateral Reference for High-Resolution Dichotomous Image Segmentation](https://arxiv.org/pdf/2401.03407)" (_CAAI AIR 2024_).
+
+This repo contains the weights of BiRefNet proposed in our paper, which has achieved the SOTA performance on three tasks (DIS, HRSOD, and COD).
+
+Go to my GitHub page for BiRefNet codes and the latest updates: https://github.com/ZhengPeng7/BiRefNet :)
+
+
+#### Try our online demos for inference:
+
++ Online **Image Inference** on Colab: [](https://colab.research.google.com/drive/14Dqg7oeBkFEtchaHLNpig2BcdkZEogba?usp=drive_link)
++ **Online Inference with GUI on Hugging Face** with adjustable resolutions: [](https://huggingface.co/spaces/ZhengPeng7/BiRefNet_demo)
++ **Inference and evaluation** of your given weights: [](https://colab.research.google.com/drive/1MaEiBfJ4xIaZZn0DqKrhydHB8X97hNXl#scrollTo=DJ4meUYjia6S)
+
+
+## Acknowledgement:
+
++ Many thanks to @Freepik for their generous support on GPU resources for training higher resolution BiRefNet models and more of my explorations.
++ Many thanks to @fal for their generous support on GPU resources for training better general BiRefNet models.
++ Many thanks to @not-lain for his help on the better deployment of our BiRefNet model on HuggingFace.
+
+
+## Citation
+
+```
+@article{zheng2024birefnet,
+ title={Bilateral Reference for High-Resolution Dichotomous Image Segmentation},
+ author={Zheng, Peng and Gao, Dehong and Fan, Deng-Ping and Liu, Li and Laaksonen, Jorma and Ouyang, Wanli and Sebe, Nicu},
+ journal={CAAI Artificial Intelligence Research},
+ volume = {3},
+ pages = {9150038},
+ year={2024}
+}
+```
\ No newline at end of file
diff --git a/models/hf/BiRefNet/config.json b/models/hf/BiRefNet/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..06d8fa9d7f2f4c6f1cf0dc6e7bfd194153176a42
--- /dev/null
+++ b/models/hf/BiRefNet/config.json
@@ -0,0 +1,20 @@
+{
+ "_name_or_path": "ZhengPeng7/BiRefNet",
+ "architectures": [
+ "BiRefNet"
+ ],
+ "auto_map": {
+ "AutoConfig": "BiRefNet_config.BiRefNetConfig",
+ "AutoModelForImageSegmentation": "birefnet.BiRefNet"
+ },
+ "custom_pipelines": {
+ "image-segmentation": {
+ "pt": [
+ "AutoModelForImageSegmentation"
+ ],
+ "tf": [],
+ "type": "image"
+ }
+ },
+ "bb_pretrained": false
+}
\ No newline at end of file
diff --git a/models/hf/BiRefNet/model.safetensors b/models/hf/BiRefNet/model.safetensors
new file mode 100644
index 0000000000000000000000000000000000000000..3b958f6368413c833b0abc357a1357cb78ce6d52
--- /dev/null
+++ b/models/hf/BiRefNet/model.safetensors
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9ab37426bf4de0567af6b5d21b16151357149139362e6e8992021b8ce356a154
+size 444473596
diff --git a/models/hf/sam2.1-hiera-tiny/README.md b/models/hf/sam2.1-hiera-tiny/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..12b65bdbc03bb143004d17be09037c39c19d6c5e
--- /dev/null
+++ b/models/hf/sam2.1-hiera-tiny/README.md
@@ -0,0 +1,542 @@
+---
+license: apache-2.0
+pipeline_tag: mask-generation
+library_name: transformers
+---
+
+Repository for SAM 2: Segment Anything in Images and Videos, a foundation model towards solving promptable visual segmentation in images and videos from FAIR. See the [SAM 2 paper](https://arxiv.org/abs/2408.00714) for more information.
+
+The official code is publicly release in this [repo](https://github.com/facebookresearch/segment-anything-2/).
+
+## Usage
+
+For image prediction:
+
+```python
+import torch
+from sam2.sam2_image_predictor import SAM2ImagePredictor
+
+predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2.1-hiera-tiny")
+
+with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
+ predictor.set_image()
+ masks, _, _ = predictor.predict()
+```
+
+For video prediction:
+
+```python
+import torch
+from sam2.sam2_video_predictor import SAM2VideoPredictor
+
+predictor = SAM2VideoPredictor.from_pretrained("facebook/sam2.1-hiera-tiny")
+
+with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
+ state = predictor.init_state()
+
+ # add new prompts and instantly get the output on the same frame
+ frame_idx, object_ids, masks = predictor.add_new_points_or_box(state, ):
+
+ # propagate the prompts to get masklets throughout the video
+ for frame_idx, object_ids, masks in predictor.propagate_in_video(state):
+ ...
+```
+
+Refer to the [demo notebooks](https://github.com/facebookresearch/segment-anything-2/tree/main/notebooks) for details.
+
+## Usage with π€ Transformers
+
+
+### Automatic Mask Generation with Pipeline
+
+SAM2 can be used for automatic mask generation to segment all objects in an image using the `mask-generation` pipeline:
+
+```python
+>>> from transformers import pipeline
+
+>>> generator = pipeline("mask-generation", model="facebook/sam2.1-hiera-tiny", device=0)
+>>> image_url = "https://huggingface.co/datasets/hf-internal-testing/sam2-fixtures/resolve/main/truck.jpg"
+>>> outputs = generator(image_url, points_per_batch=64)
+
+>>> len(outputs["masks"]) # Number of masks generated
+39
+```
+
+### Basic Image Segmentation
+
+#### Single Point Click
+
+You can segment objects by providing a single point click on the object you want to segment:
+
+```python
+>>> from transformers import Sam2Processor, Sam2Model
+>>> import torch
+>>> from PIL import Image
+>>> import requests
+
+>>> device = "cuda" if torch.cuda.is_available() else "cpu"
+
+>>> model = Sam2Model.from_pretrained("facebook/sam2.1-hiera-tiny").to(device)
+>>> processor = Sam2Processor.from_pretrained("facebook/sam2.1-hiera-tiny")
+
+>>> image_url = "https://huggingface.co/datasets/hf-internal-testing/sam2-fixtures/resolve/main/truck.jpg"
+>>> raw_image = Image.open(requests.get(image_url, stream=True).raw).convert("RGB")
+
+>>> input_points = [[[[500, 375]]]] # Single point click, 4 dimensions (image_dim, object_dim, point_per_object_dim, coordinates)
+>>> input_labels = [[[1]]] # 1 for positive click, 0 for negative click, 3 dimensions (image_dim, object_dim, point_label)
+
+>>> inputs = processor(images=raw_image, input_points=input_points, input_labels=input_labels, return_tensors="pt").to(device)
+
+>>> with torch.no_grad():
+... outputs = model(**inputs)
+
+>>> masks = processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"])[0]
+
+>>> # The model outputs multiple mask predictions ranked by quality score
+>>> print(f"Generated {masks.shape[1]} masks with shape {masks.shape}")
+Generated 3 masks with shape torch.Size(1, 3, 1500, 2250)
+```
+
+#### Multiple Points for Refinement
+
+You can provide multiple points to refine the segmentation:
+
+```python
+>>> # Add both positive and negative points to refine the mask
+>>> input_points = [[[[500, 375], [1125, 625]]]] # Multiple points for refinement
+>>> input_labels = [[[1, 1]]] # Both positive clicks
+
+>>> inputs = processor(images=raw_image, input_points=input_points, input_labels=input_labels, return_tensors="pt").to(device)
+
+>>> with torch.no_grad():
+... outputs = model(**inputs)
+
+>>> masks = processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"])[0]
+```
+
+#### Bounding Box Input
+
+SAM2 also supports bounding box inputs for segmentation:
+
+```python
+>>> # Define bounding box as [x_min, y_min, x_max, y_max]
+>>> input_boxes = [[[75, 275, 1725, 850]]]
+
+>>> inputs = processor(images=raw_image, input_boxes=input_boxes, return_tensors="pt").to(device)
+
+>>> with torch.no_grad():
+... outputs = model(**inputs)
+
+>>> masks = processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"])[0]
+```
+
+#### Multiple Objects Segmentation
+
+You can segment multiple objects simultaneously:
+
+```python
+>>> # Define points for two different objects
+>>> input_points = [[[[500, 375]], [[650, 750]]]] # Points for two objects in same image
+>>> input_labels = [[[1], [1]]] # Positive clicks for both objects
+
+>>> inputs = processor(images=raw_image, input_points=input_points, input_labels=input_labels, return_tensors="pt").to(device)
+
+>>> with torch.no_grad():
+... outputs = model(**inputs, multimask_output=False)
+
+>>> # Each object gets its own mask
+>>> masks = processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"])[0]
+>>> print(f"Generated masks for {masks.shape[0]} objects")
+Generated masks for 2 objects
+```
+
+### Batch Inference
+
+#### Batched Images
+
+Process multiple images simultaneously for improved efficiency:
+
+```python
+>>> from transformers import Sam2Processor, Sam2Model
+>>> import torch
+>>> from PIL import Image
+>>> import requests
+
+>>> device = "cuda" if torch.cuda.is_available() else "cpu"
+
+>>> model = Sam2Model.from_pretrained("facebook/sam2.1-hiera-tiny").to(device)
+>>> processor = Sam2Processor.from_pretrained("facebook/sam2.1-hiera-tiny")
+
+>>> # Load multiple images
+>>> image_urls = [
+... "https://huggingface.co/datasets/hf-internal-testing/sam2-fixtures/resolve/main/truck.jpg",
+... "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/dog-sam.png"
+... ]
+>>> raw_images = [Image.open(requests.get(url, stream=True).raw).convert("RGB") for url in image_urls]
+
+>>> # Single point per image
+>>> input_points = [[[[500, 375]]], [[[770, 200]]]] # One point for each image
+>>> input_labels = [[[1]], [[1]]] # Positive clicks for both images
+
+>>> inputs = processor(images=raw_images, input_points=input_points, input_labels=input_labels, return_tensors="pt").to(device)
+
+>>> with torch.no_grad():
+... outputs = model(**inputs, multimask_output=False)
+
+>>> # Post-process masks for each image
+>>> all_masks = processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"])
+>>> print(f"Processed {len(all_masks)} images, each with {all_masks[0].shape[0]} objects")
+Processed 2 images, each with 1 objects
+```
+
+#### Batched Objects per Image
+
+Segment multiple objects within each image using batch inference:
+
+```python
+>>> # Multiple objects per image - different numbers of objects per image
+>>> input_points = [
+... [[[500, 375]], [[650, 750]]], # Truck image: 2 objects
+... [[[770, 200]]] # Dog image: 1 object
+... ]
+>>> input_labels = [
+... [[1], [1]], # Truck image: positive clicks for both objects
+... [[1]] # Dog image: positive click for the object
+... ]
+
+>>> inputs = processor(images=raw_images, input_points=input_points, input_labels=input_labels, return_tensors="pt").to(device)
+
+>>> with torch.no_grad():
+... outputs = model(**inputs, multimask_output=False)
+
+>>> all_masks = processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"])
+```
+
+#### Batched Images with Batched Objects and Multiple Points
+
+Handle complex batch scenarios with multiple points per object:
+
+```python
+>>> # Add groceries image for more complex example
+>>> groceries_url = "https://huggingface.co/datasets/hf-internal-testing/sam2-fixtures/resolve/main/groceries.jpg"
+>>> groceries_image = Image.open(requests.get(groceries_url, stream=True).raw).convert("RGB")
+>>> raw_images = [raw_images[0], groceries_image] # Use truck and groceries images
+
+>>> # Complex batching: multiple images, multiple objects, multiple points per object
+>>> input_points = [
+... [[[500, 375]], [[650, 750]]], # Truck image: 2 objects with 1 point each
+... [[[400, 300]], [[630, 300], [550, 300]]] # Groceries image: obj1 has 1 point, obj2 has 2 points
+... ]
+>>> input_labels = [
+... [[1], [1]], # Truck image: positive clicks
+... [[1], [1, 1]] # Groceries image: positive clicks for refinement
+... ]
+
+>>> inputs = processor(images=raw_images, input_points=input_points, input_labels=input_labels, return_tensors="pt").to(device)
+
+>>> with torch.no_grad():
+... outputs = model(**inputs, multimask_output=False)
+
+>>> all_masks = processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"])
+```
+
+#### Batched Bounding Boxes
+
+Process multiple images with bounding box inputs:
+
+```python
+>>> # Multiple bounding boxes per image (using truck and groceries images)
+>>> input_boxes = [
+... [[75, 275, 1725, 850], [425, 600, 700, 875], [1375, 550, 1650, 800], [1240, 675, 1400, 750]], # Truck image: 4 boxes
+... [[450, 170, 520, 350], [350, 190, 450, 350], [500, 170, 580, 350], [580, 170, 640, 350]] # Groceries image: 4 boxes
+... ]
+
+>>> # Update images for this example
+>>> raw_images = [raw_images[0], groceries_image] # truck and groceries
+
+>>> inputs = processor(images=raw_images, input_boxes=input_boxes, return_tensors="pt").to(device)
+
+>>> with torch.no_grad():
+... outputs = model(**inputs, multimask_output=False)
+
+>>> all_masks = processor.post_process_masks(outputs.pred_masks.cpu(), inputs["original_sizes"])
+>>> print(f"Processed {len(input_boxes)} images with {len(input_boxes[0])} and {len(input_boxes[1])} boxes respectively")
+Processed 2 images with 4 and 4 boxes respectively
+```
+
+### Using Previous Masks as Input
+
+SAM2 can use masks from previous predictions as input to refine segmentation:
+
+```python
+>>> # Get initial segmentation
+>>> input_points = [[[[500, 375]]]]
+>>> input_labels = [[[1]]]
+>>> inputs = processor(images=raw_image, input_points=input_points, input_labels=input_labels, return_tensors="pt").to(device)
+
+>>> with torch.no_grad():
+... outputs = model(**inputs)
+
+>>> # Use the best mask as input for refinement
+>>> mask_input = outputs.pred_masks[:, :, torch.argmax(outputs.iou_scores.squeeze())]
+
+>>> # Add additional points with the mask input
+>>> new_input_points = [[[[500, 375], [450, 300]]]]
+>>> new_input_labels = [[[1, 1]]]
+>>> inputs = processor(
+... input_points=new_input_points,
+... input_labels=new_input_labels,
+... original_sizes=inputs["original_sizes"],
+... return_tensors="pt",
+... ).to(device)
+
+>>> with torch.no_grad():
+... refined_outputs = model(
+... **inputs,
+... input_masks=mask_input,
+... image_embeddings=outputs.image_embeddings,
+... multimask_output=False,
+... )
+```
+
+
+### Video Segmentation and Tracking
+
+SAM2's key strength is its ability to track objects across video frames. Here's how to use it for video segmentation:
+
+#### Basic Video Tracking
+
+```python
+>>> from transformers import Sam2VideoModel, Sam2VideoProcessor
+>>> import torch
+
+>>> device = "cuda" if torch.cuda.is_available() else "cpu"
+>>> model = Sam2VideoModel.from_pretrained("facebook/sam2.1-hiera-tiny").to(device, dtype=torch.bfloat16)
+>>> processor = Sam2VideoProcessor.from_pretrained("facebook/sam2.1-hiera-tiny")
+
+>>> # Load video frames (example assumes you have a list of PIL Images)
+>>> # video_frames = [Image.open(f"frame_{i:05d}.jpg") for i in range(num_frames)]
+
+>>> # For this example, we'll use the video loading utility
+>>> from transformers.video_utils import load_video
+>>> video_url = "https://huggingface.co/datasets/hf-internal-testing/sam2-fixtures/resolve/main/bedroom.mp4"
+>>> video_frames, _ = load_video(video_url)
+
+>>> # Initialize video inference session
+>>> inference_session = processor.init_video_session(
+... video=video_frames,
+... inference_device=device,
+... torch_dtype=torch.bfloat16,
+... )
+
+>>> # Add click on first frame to select object
+>>> ann_frame_idx = 0
+>>> ann_obj_id = 1
+>>> points = [[[[210, 350]]]]
+>>> labels = [[[1]]]
+
+>>> processor.add_inputs_to_inference_session(
+... inference_session=inference_session,
+... frame_idx=ann_frame_idx,
+... obj_ids=ann_obj_id,
+... input_points=points,
+... input_labels=labels,
+... )
+
+>>> # Segment the object on the first frame
+>>> outputs = model(
+... inference_session=inference_session,
+... frame_idx=ann_frame_idx,
+... )
+>>> video_res_masks = processor.post_process_masks(
+... [outputs.pred_masks], original_sizes=[[inference_session.video_height, inference_session.video_width]], binarize=False
+... )[0]
+>>> print(f"Segmentation shape: {video_res_masks.shape}")
+Segmentation shape: torch.Size([1, 1, 480, 854])
+
+>>> # Propagate through the entire video
+>>> video_segments = {}
+>>> for sam2_video_output in model.propagate_in_video_iterator(inference_session):
+... video_res_masks = processor.post_process_masks(
+... [sam2_video_output.pred_masks], original_sizes=[[inference_session.video_height, inference_session.video_width]], binarize=False
+... )[0]
+... video_segments[sam2_video_output.frame_idx] = video_res_masks
+
+>>> print(f"Tracked object through {len(video_segments)} frames")
+Tracked object through 180 frames
+```
+
+#### Multi-Object Video Tracking
+
+Track multiple objects simultaneously across video frames:
+
+```python
+>>> # Reset for new tracking session
+>>> inference_session.reset_inference_session()
+
+>>> # Add multiple objects on the first frame
+>>> ann_frame_idx = 0
+>>> obj_ids = [2, 3]
+>>> input_points = [[[[200, 300]], [[400, 150]]]] # Points for two objects (batched)
+>>> input_labels = [[[1], [1]]]
+
+>>> processor.add_inputs_to_inference_session(
+... inference_session=inference_session,
+... frame_idx=ann_frame_idx,
+... obj_ids=obj_ids,
+... input_points=input_points,
+... input_labels=input_labels,
+... )
+
+>>> # Get masks for both objects on first frame
+>>> outputs = model(
+... inference_session=inference_session,
+... frame_idx=ann_frame_idx,
+... )
+
+>>> # Propagate both objects through video
+>>> video_segments = {}
+>>> for sam2_video_output in model.propagate_in_video_iterator(inference_session):
+... video_res_masks = processor.post_process_masks(
+... [sam2_video_output.pred_masks], original_sizes=[[inference_session.video_height, inference_session.video_width]], binarize=False
+... )[0]
+... video_segments[sam2_video_output.frame_idx] = {
+... obj_id: video_res_masks[i]
+... for i, obj_id in enumerate(inference_session.obj_ids)
+... }
+
+>>> print(f"Tracked {len(inference_session.obj_ids)} objects through {len(video_segments)} frames")
+Tracked 2 objects through 180 frames
+```
+
+#### Refining Video Segmentation
+
+You can add additional clicks on any frame to refine the tracking:
+
+```python
+>>> # Add refinement click on a later frame
+>>> refine_frame_idx = 50
+>>> ann_obj_id = 2 # Refining first object
+>>> points = [[[[220, 280]]]] # Additional point
+>>> labels = [[[1]]] # Positive click
+
+>>> processor.add_inputs_to_inference_session(
+... inference_session=inference_session,
+... frame_idx=refine_frame_idx,
+... obj_ids=ann_obj_id,
+... input_points=points,
+... input_labels=labels,
+... )
+
+>>> # Re-propagate with the additional information
+>>> video_segments = {}
+>>> for sam2_video_output in model.propagate_in_video_iterator(inference_session):
+... video_res_masks = processor.post_process_masks(
+... [sam2_video_output.pred_masks], original_sizes=[[inference_session.video_height, inference_session.video_width]], binarize=False
+... )[0]
+... video_segments[sam2_video_output.frame_idx] = video_res_masks
+```
+
+### Streaming Video Inference
+
+For real-time applications, SAM2 supports processing video frames as they arrive:
+
+```python
+>>> # Initialize session for streaming
+>>> inference_session = processor.init_video_session(
+... inference_device=device,
+... torch_dtype=torch.bfloat16,
+... )
+
+>>> # Process frames one by one
+>>> for frame_idx, frame in enumerate(video_frames[:10]): # Process first 10 frames
+... inputs = processor(images=frame, device=device, return_tensors="pt")
+...
+... if frame_idx == 0:
+... # Add point input on first frame
+... processor.add_inputs_to_inference_session(
+... inference_session=inference_session,
+... frame_idx=0,
+... obj_ids=1,
+... input_points=[[[[210, 350], [250, 220]]]],
+... input_labels=[[[1, 1]]],
+... original_size=inputs.original_sizes[0], # need to be provided when using streaming video inference
+... )
+...
+... # Process current frame
+... sam2_video_output = model(inference_session=inference_session, frame=inputs.pixel_values[0])
+...
+... video_res_masks = processor.post_process_masks(
+... [sam2_video_output.pred_masks], original_sizes=inputs.original_sizes, binarize=False
+... )[0]
+... print(f"Frame {frame_idx}: mask shape {video_res_masks.shape}")
+```
+
+#### Video Batch Processing for Multiple Objects
+
+Track multiple objects simultaneously in video by adding them all at once:
+
+```python
+>>> # Initialize video session
+>>> inference_session = processor.init_video_session(
+... video=video_frames,
+... inference_device=device,
+... torch_dtype=torch.bfloat16,
+... )
+
+>>> # Add multiple objects on the first frame using batch processing
+>>> ann_frame_idx = 0
+>>> obj_ids = [2, 3] # Track two different objects
+>>> input_points = [
+... [[[200, 300], [230, 250], [275, 175]], [[400, 150]]]
+... ] # Object 2: 3 points (2 positive, 1 negative); Object 3: 1 point
+>>> input_labels = [
+... [[1, 1, 0], [1]]
+... ] # Object 2: positive, positive, negative; Object 3: positive
+
+>>> processor.add_inputs_to_inference_session(
+... inference_session=inference_session,
+... frame_idx=ann_frame_idx,
+... obj_ids=obj_ids,
+... input_points=input_points,
+... input_labels=input_labels,
+... )
+
+>>> # Get masks for all objects on the first frame
+>>> outputs = model(
+... inference_session=inference_session,
+... frame_idx=ann_frame_idx,
+... )
+>>> video_res_masks = processor.post_process_masks(
+... [outputs.pred_masks], original_sizes=[[inference_session.video_height, inference_session.video_width]], binarize=False
+... )[0]
+>>> print(f"Generated masks for {video_res_masks.shape[0]} objects")
+Generated masks for 2 objects
+
+>>> # Propagate all objects through the video
+>>> video_segments = {}
+>>> for sam2_video_output in model.propagate_in_video_iterator(inference_session):
+... video_res_masks = processor.post_process_masks(
+... [sam2_video_output.pred_masks], original_sizes=[[inference_session.video_height, inference_session.video_width]], binarize=False
+... )[0]
+... video_segments[sam2_video_output.frame_idx] = {
+... obj_id: video_res_masks[i]
+... for i, obj_id in enumerate(inference_session.obj_ids)
+... }
+
+>>> print(f"Tracked {len(inference_session.obj_ids)} objects through {len(video_segments)} frames")
+Tracked 2 objects through 180 frames
+```
+
+### Citation
+
+To cite the paper, model, or software, please use the below:
+```
+@article{ravi2024sam2,
+ title={SAM 2: Segment Anything in Images and Videos},
+ author={Ravi, Nikhila and Gabeur, Valentin and Hu, Yuan-Ting and Hu, Ronghang and Ryali, Chaitanya and Ma, Tengyu and Khedr, Haitham and R{\"a}dle, Roman and Rolland, Chloe and Gustafson, Laura and Mintun, Eric and Pan, Junting and Alwala, Kalyan Vasudev and Carion, Nicolas and Wu, Chao-Yuan and Girshick, Ross and Doll{\'a}r, Piotr and Feichtenhofer, Christoph},
+ journal={arXiv preprint arXiv:2408.00714},
+ url={https://arxiv.org/abs/2408.00714},
+ year={2024}
+}
+```
diff --git a/models/hf/sam2.1-hiera-tiny/config.json b/models/hf/sam2.1-hiera-tiny/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..e8fa1e6d6d31299bba32d2f5759c2d156c8a6bd1
--- /dev/null
+++ b/models/hf/sam2.1-hiera-tiny/config.json
@@ -0,0 +1,233 @@
+{
+ "architectures": [
+ "Sam2VideoModel"
+ ],
+ "enable_occlusion_spatial_embedding": true,
+ "enable_temporal_pos_encoding_for_object_pointers": true,
+ "image_size": 1024,
+ "initializer_range": 0.02,
+ "mask_decoder_config": {
+ "attention_downsample_rate": 2,
+ "dynamic_multimask_stability_delta": 0.05,
+ "dynamic_multimask_stability_thresh": 0.98,
+ "dynamic_multimask_via_stability": true,
+ "hidden_act": "gelu",
+ "hidden_size": 256,
+ "iou_head_depth": 3,
+ "iou_head_hidden_dim": 256,
+ "mlp_dim": 2048,
+ "model_type": "",
+ "num_attention_heads": 8,
+ "num_hidden_layers": 2,
+ "num_multimask_outputs": 3
+ },
+ "mask_downsampler_embed_dim": 256,
+ "mask_downsampler_hidden_act": "gelu",
+ "mask_downsampler_kernel_size": 3,
+ "mask_downsampler_padding": 1,
+ "mask_downsampler_stride": 2,
+ "mask_downsampler_total_stride": 16,
+ "max_object_pointers_in_encoder": 16,
+ "memory_attention_downsample_rate": 1,
+ "memory_attention_dropout": 0.1,
+ "memory_attention_feed_forward_hidden_act": "relu",
+ "memory_attention_feed_forward_hidden_size": 2048,
+ "memory_attention_hidden_size": 256,
+ "memory_attention_num_attention_heads": 1,
+ "memory_attention_num_layers": 4,
+ "memory_attention_rope_dropout": 0.1,
+ "memory_attention_rope_feat_sizes": [
+ 64,
+ 64
+ ],
+ "memory_attention_rope_theta": 10000,
+ "memory_encoder_hidden_size": 256,
+ "memory_encoder_output_channels": 64,
+ "memory_fuser_embed_dim": 256,
+ "memory_fuser_hidden_act": "gelu",
+ "memory_fuser_intermediate_dim": 1024,
+ "memory_fuser_kernel_size": 7,
+ "memory_fuser_layer_scale_init_value": 1e-06,
+ "memory_fuser_num_layers": 2,
+ "memory_fuser_padding": 3,
+ "model_type": "sam2_video",
+ "multimask_max_pt_num": 1,
+ "multimask_min_pt_num": 0,
+ "multimask_output_for_tracking": true,
+ "multimask_output_in_sam": true,
+ "num_maskmem": 7,
+ "prompt_encoder_config": {
+ "hidden_act": "gelu",
+ "hidden_size": 256,
+ "image_size": 1024,
+ "layer_norm_eps": 1e-06,
+ "mask_input_channels": 16,
+ "model_type": "",
+ "num_point_embeddings": 4,
+ "patch_size": 16,
+ "scale": 1
+ },
+ "sigmoid_bias_for_mem_enc": -10.0,
+ "sigmoid_scale_for_mem_enc": 20.0,
+ "torch_dtype": "float32",
+ "transformers_version": "4.56.0.dev0",
+ "vision_config": {
+ "backbone_channel_list": [
+ 768,
+ 384,
+ 192,
+ 96
+ ],
+ "backbone_config": {
+ "_name_or_path": "",
+ "add_cross_attention": false,
+ "architectures": null,
+ "bad_words_ids": null,
+ "begin_suppress_tokens": null,
+ "blocks_per_stage": [
+ 1,
+ 2,
+ 7,
+ 2
+ ],
+ "bos_token_id": null,
+ "chunk_size_feed_forward": 0,
+ "cross_attention_hidden_size": null,
+ "decoder_start_token_id": null,
+ "diversity_penalty": 0.0,
+ "do_sample": false,
+ "early_stopping": false,
+ "embed_dim_per_stage": [
+ 96,
+ 192,
+ 384,
+ 768
+ ],
+ "encoder_no_repeat_ngram_size": 0,
+ "eos_token_id": null,
+ "exponential_decay_length_penalty": null,
+ "finetuning_task": null,
+ "forced_bos_token_id": null,
+ "forced_eos_token_id": null,
+ "global_attention_blocks": [
+ 5,
+ 7,
+ 9
+ ],
+ "hidden_act": "gelu",
+ "hidden_size": 96,
+ "id2label": {
+ "0": "LABEL_0",
+ "1": "LABEL_1"
+ },
+ "image_size": [
+ 1024,
+ 1024
+ ],
+ "initializer_range": 0.02,
+ "is_decoder": false,
+ "is_encoder_decoder": false,
+ "label2id": {
+ "LABEL_0": 0,
+ "LABEL_1": 1
+ },
+ "layer_norm_eps": 1e-06,
+ "length_penalty": 1.0,
+ "max_length": 20,
+ "min_length": 0,
+ "mlp_ratio": 4.0,
+ "model_type": "sam2_hiera_det_model",
+ "no_repeat_ngram_size": 0,
+ "num_attention_heads": 1,
+ "num_attention_heads_per_stage": [
+ 1,
+ 2,
+ 4,
+ 8
+ ],
+ "num_beam_groups": 1,
+ "num_beams": 1,
+ "num_channels": 3,
+ "num_query_pool_stages": 3,
+ "num_return_sequences": 1,
+ "output_attentions": false,
+ "output_hidden_states": false,
+ "output_scores": false,
+ "pad_token_id": null,
+ "patch_kernel_size": [
+ 7,
+ 7
+ ],
+ "patch_padding": [
+ 3,
+ 3
+ ],
+ "patch_stride": [
+ 4,
+ 4
+ ],
+ "prefix": null,
+ "problem_type": null,
+ "pruned_heads": {},
+ "query_stride": [
+ 2,
+ 2
+ ],
+ "remove_invalid_values": false,
+ "repetition_penalty": 1.0,
+ "return_dict": true,
+ "return_dict_in_generate": false,
+ "sep_token_id": null,
+ "suppress_tokens": null,
+ "task_specific_params": null,
+ "temperature": 1.0,
+ "tf_legacy_loss": false,
+ "tie_encoder_decoder": false,
+ "tie_word_embeddings": true,
+ "tokenizer_class": null,
+ "top_k": 50,
+ "top_p": 1.0,
+ "torch_dtype": null,
+ "torchscript": false,
+ "typical_p": 1.0,
+ "use_bfloat16": false,
+ "window_positional_embedding_background_size": [
+ 7,
+ 7
+ ],
+ "window_size_per_stage": [
+ 8,
+ 4,
+ 14,
+ 7
+ ]
+ },
+ "backbone_feature_sizes": [
+ [
+ 256,
+ 256
+ ],
+ [
+ 128,
+ 128
+ ],
+ [
+ 64,
+ 64
+ ]
+ ],
+ "fpn_hidden_size": 256,
+ "fpn_kernel_size": 1,
+ "fpn_padding": 0,
+ "fpn_stride": 1,
+ "fpn_top_down_levels": [
+ 2,
+ 3
+ ],
+ "hidden_act": "gelu",
+ "initializer_range": 0.02,
+ "layer_norm_eps": 1e-06,
+ "model_type": "sam2_vision_model",
+ "num_feature_levels": 3
+ }
+}
diff --git a/models/hf/sam2.1-hiera-tiny/model.safetensors b/models/hf/sam2.1-hiera-tiny/model.safetensors
new file mode 100644
index 0000000000000000000000000000000000000000..ab4d169b8fd1a8342e3f9cb4017d7a0f25ec7736
--- /dev/null
+++ b/models/hf/sam2.1-hiera-tiny/model.safetensors
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:48c14467e5cf9e51870511feb72c89688e82dd74523142c0538b663e193ac2a7
+size 155908064
diff --git a/models/hf/sam2.1-hiera-tiny/preprocessor_config.json b/models/hf/sam2.1-hiera-tiny/preprocessor_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..8499e53cb79bf1786a890021550e6994b9808f39
--- /dev/null
+++ b/models/hf/sam2.1-hiera-tiny/preprocessor_config.json
@@ -0,0 +1,36 @@
+{
+ "crop_size": null,
+ "data_format": "channels_first",
+ "default_to_square": true,
+ "device": null,
+ "disable_grouping": null,
+ "do_center_crop": null,
+ "do_convert_rgb": true,
+ "do_normalize": true,
+ "do_rescale": true,
+ "do_resize": true,
+ "image_mean": [
+ 0.485,
+ 0.456,
+ 0.406
+ ],
+ "image_processor_type": "Sam2ImageProcessorFast",
+ "image_std": [
+ 0.229,
+ 0.224,
+ 0.225
+ ],
+ "input_data_format": null,
+ "mask_size": {
+ "height": 256,
+ "width": 256
+ },
+ "processor_class": "Sam2VideoProcessor",
+ "resample": 2,
+ "rescale_factor": 0.00392156862745098,
+ "return_tensors": null,
+ "size": {
+ "height": 1024,
+ "width": 1024
+ }
+}
diff --git a/models/hf/sam2.1-hiera-tiny/processor_config.json b/models/hf/sam2.1-hiera-tiny/processor_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..7556f607c3581a19f545de09d8b3fc98502b9f36
--- /dev/null
+++ b/models/hf/sam2.1-hiera-tiny/processor_config.json
@@ -0,0 +1,5 @@
+{
+ "point_pad_value": -10,
+ "processor_class": "Sam2VideoProcessor",
+ "target_size": 1024
+}
diff --git a/models/ort/unet_ft_ffhq/meta.json b/models/ort/unet_ft_ffhq/meta.json
new file mode 100644
index 0000000000000000000000000000000000000000..3e2d27396a11ce0b2518e350af0f9f459519b39b
--- /dev/null
+++ b/models/ort/unet_ft_ffhq/meta.json
@@ -0,0 +1,158 @@
+{
+ "name": "unet_step_ft_ffhq_fp16_conv3d_nearest_conv_pack",
+ "kind": "step_pack",
+ "from": [
+ "unet_step_ft_ffhq_fp16_conv3d_nearest_conv_b2/model.onnx",
+ "unet_step_ft_ffhq_fp16_conv3d_nearest_conv_b1/model.onnx"
+ ],
+ "matched_initializers": 689,
+ "b1_initializers": 689,
+ "shared_bytes": 442821360,
+ "files": {
+ "model_b2.onnx": 456896,
+ "model_b1.onnx": 456438,
+ "weights.bin": 442821360
+ },
+ "bytes": 443734694,
+ "unpacked_bytes": 886490708,
+ "source_meta": {
+ "name": "unet_step_ft_ffhq_fp16_conv3d_nearest_conv_b2",
+ "kind": "unet_step",
+ "ckpt": "ft_ffhq",
+ "precision": "fp16",
+ "options": {
+ "posconv": "conv3d",
+ "upsample": "nearest_conv",
+ "latent_hw": [
+ 64,
+ 64
+ ],
+ "norm_fp32": false
+ },
+ "opset": 18,
+ "params": 221447814,
+ "source_sha256": "ddd5b81b3034dea2bb380c574517ebbf24957903d99319fa8bbb8e69ca9d5606",
+ "exporter": "torchscript",
+ "torch": "2.13.0+cu130",
+ "export_seconds": 10.1,
+ "nodes": 2155,
+ "op_histogram": {
+ "Constant": 521,
+ "Add": 294,
+ "Reshape": 289,
+ "MatMul": 195,
+ "Mul": 164,
+ "Conv": 109,
+ "Transpose": 105,
+ "Sigmoid": 63,
+ "Shape": 61,
+ "Unsqueeze": 60,
+ "Gather": 53,
+ "InstanceNormalization": 46,
+ "LayerNormalization": 45,
+ "Slice": 34,
+ "Relu": 32,
+ "Gemm": 17,
+ "Div": 16,
+ "Softmax": 15,
+ "Concat": 12,
+ "Cast": 6,
+ "ConstantOfShape": 3,
+ "Equal": 3,
+ "Where": 3,
+ "Expand": 3,
+ "Resize": 2,
+ "Sub": 2,
+ "Sin": 1,
+ "Cos": 1
+ },
+ "inputs": [
+ [
+ "x_t",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "mask_lat",
+ [
+ 1,
+ 1,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "masked_lat",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "branch",
+ [
+ 2
+ ],
+ 7
+ ],
+ [
+ "coef",
+ [
+ 8
+ ],
+ 1
+ ],
+ [
+ "x0_prev",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ]
+ ],
+ "outputs": [
+ [
+ "x_next",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "x0",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ]
+ ],
+ "bytes": 443245583
+ },
+ "options": {
+ "posconv": "conv3d",
+ "upsample": "nearest_conv",
+ "latent_hw": [
+ 64,
+ 64
+ ],
+ "norm_fp32": false
+ }
+}
\ No newline at end of file
diff --git a/models/ort/unet_ft_ffhq/model_b1.onnx b/models/ort/unet_ft_ffhq/model_b1.onnx
new file mode 100644
index 0000000000000000000000000000000000000000..f121ba90ca5479b13406c23cec91816e3fc3d183
--- /dev/null
+++ b/models/ort/unet_ft_ffhq/model_b1.onnx
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:975a68e46aeaf33c36b4f013d1b90f06eb1df71b8be69fe9deb4c646c700795d
+size 456438
diff --git a/models/ort/unet_ft_ffhq/model_b2.onnx b/models/ort/unet_ft_ffhq/model_b2.onnx
new file mode 100644
index 0000000000000000000000000000000000000000..a9f87c18f2e350489976d498b26188ab4b0072ee
--- /dev/null
+++ b/models/ort/unet_ft_ffhq/model_b2.onnx
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:aec8649c624e3bccec51df4b6f87e481c7e2ebbf753b9f00f71a830f8e08edca
+size 456896
diff --git a/models/ort/unet_ft_ffhq/weights.bin b/models/ort/unet_ft_ffhq/weights.bin
new file mode 100644
index 0000000000000000000000000000000000000000..47bc60d7598aa88baabd8acfe0826a02b8b64033
--- /dev/null
+++ b/models/ort/unet_ft_ffhq/weights.bin
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:4ce9063ffc0341d8051dc227e5cd2063330bcba4723a374aa676485509d43845
+size 442821360
diff --git a/models/ort/unet_ft_places2/meta.json b/models/ort/unet_ft_places2/meta.json
new file mode 100644
index 0000000000000000000000000000000000000000..10b15386a94d8a298e302b2d9be53cb3ff383b0d
--- /dev/null
+++ b/models/ort/unet_ft_places2/meta.json
@@ -0,0 +1,158 @@
+{
+ "name": "unet_step_ft_places2_fp16_conv3d_nearest_conv_pack",
+ "kind": "step_pack",
+ "from": [
+ "unet_step_ft_places2_fp16_conv3d_nearest_conv_b2/model.onnx",
+ "unet_step_ft_places2_fp16_conv3d_nearest_conv_b1/model.onnx"
+ ],
+ "matched_initializers": 689,
+ "b1_initializers": 689,
+ "shared_bytes": 442821360,
+ "files": {
+ "model_b2.onnx": 456896,
+ "model_b1.onnx": 456438,
+ "weights.bin": 442821360
+ },
+ "bytes": 443734694,
+ "unpacked_bytes": 886490708,
+ "source_meta": {
+ "name": "unet_step_ft_places2_fp16_conv3d_nearest_conv_b2",
+ "kind": "unet_step",
+ "ckpt": "ft_places2",
+ "precision": "fp16",
+ "options": {
+ "posconv": "conv3d",
+ "upsample": "nearest_conv",
+ "latent_hw": [
+ 64,
+ 64
+ ],
+ "norm_fp32": false
+ },
+ "opset": 18,
+ "params": 221447814,
+ "source_sha256": "6525afb888e55f9b5c74fa0a5d19ca0762d720d6c716fb0f8422fbeb6868a09a",
+ "exporter": "torchscript",
+ "torch": "2.13.0+cu130",
+ "export_seconds": 9.0,
+ "nodes": 2155,
+ "op_histogram": {
+ "Constant": 521,
+ "Add": 294,
+ "Reshape": 289,
+ "MatMul": 195,
+ "Mul": 164,
+ "Conv": 109,
+ "Transpose": 105,
+ "Sigmoid": 63,
+ "Shape": 61,
+ "Unsqueeze": 60,
+ "Gather": 53,
+ "InstanceNormalization": 46,
+ "LayerNormalization": 45,
+ "Slice": 34,
+ "Relu": 32,
+ "Gemm": 17,
+ "Div": 16,
+ "Softmax": 15,
+ "Concat": 12,
+ "Cast": 6,
+ "ConstantOfShape": 3,
+ "Equal": 3,
+ "Where": 3,
+ "Expand": 3,
+ "Resize": 2,
+ "Sub": 2,
+ "Sin": 1,
+ "Cos": 1
+ },
+ "inputs": [
+ [
+ "x_t",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "mask_lat",
+ [
+ 1,
+ 1,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "masked_lat",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "branch",
+ [
+ 2
+ ],
+ 7
+ ],
+ [
+ "coef",
+ [
+ 8
+ ],
+ 1
+ ],
+ [
+ "x0_prev",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ]
+ ],
+ "outputs": [
+ [
+ "x_next",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "x0",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ]
+ ],
+ "bytes": 443245583
+ },
+ "options": {
+ "posconv": "conv3d",
+ "upsample": "nearest_conv",
+ "latent_hw": [
+ 64,
+ 64
+ ],
+ "norm_fp32": false
+ }
+}
\ No newline at end of file
diff --git a/models/ort/unet_ft_places2/model_b1.onnx b/models/ort/unet_ft_places2/model_b1.onnx
new file mode 100644
index 0000000000000000000000000000000000000000..0d312c809d564450fce6d71b909c90d163917813
--- /dev/null
+++ b/models/ort/unet_ft_places2/model_b1.onnx
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:0b1782ea484df7b7d59fde0beba023e7876760b826ede9199dbffd1bdf032396
+size 456438
diff --git a/models/ort/unet_ft_places2/model_b2.onnx b/models/ort/unet_ft_places2/model_b2.onnx
new file mode 100644
index 0000000000000000000000000000000000000000..0b7ef266702c8a9602ab2c2a773107df56465f74
--- /dev/null
+++ b/models/ort/unet_ft_places2/model_b2.onnx
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:5734f1e8c4dd81790825e3c198c6f7e37013722200b21e80bc258bec88b253f6
+size 456896
diff --git a/models/ort/unet_ft_places2/weights.bin b/models/ort/unet_ft_places2/weights.bin
new file mode 100644
index 0000000000000000000000000000000000000000..c72ce0779a24a581c22790b582d41ea861d9db0b
--- /dev/null
+++ b/models/ort/unet_ft_places2/weights.bin
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b1c33d534573638fe613a0170e20931a97973c03643f69cabae99750a1e681d5
+size 442821360
diff --git a/models/ort/unet_pretrained/meta.json b/models/ort/unet_pretrained/meta.json
new file mode 100644
index 0000000000000000000000000000000000000000..9936292f9f3870a96272807bfa4c0031cd00ecec
--- /dev/null
+++ b/models/ort/unet_pretrained/meta.json
@@ -0,0 +1,158 @@
+{
+ "name": "unet_step_pretrained_fp16_conv3d_nearest_conv_pack",
+ "kind": "step_pack",
+ "from": [
+ "build\\unet_step_pretrained_fp16_conv3d_nearest_conv_b2\\model.onnx",
+ "build\\unet_step_pretrained_fp16_conv3d_nearest_conv_b1\\model.onnx"
+ ],
+ "matched_initializers": 689,
+ "b1_initializers": 689,
+ "shared_bytes": 442821360,
+ "files": {
+ "model_b2.onnx": 456896,
+ "model_b1.onnx": 456438,
+ "weights.bin": 442821360
+ },
+ "bytes": 443734694,
+ "unpacked_bytes": 886490708,
+ "source_meta": {
+ "name": "unet_step_pretrained_fp16_conv3d_nearest_conv_b2",
+ "kind": "unet_step",
+ "ckpt": "pretrained",
+ "precision": "fp16",
+ "options": {
+ "posconv": "conv3d",
+ "upsample": "nearest_conv",
+ "latent_hw": [
+ 64,
+ 64
+ ],
+ "norm_fp32": false
+ },
+ "opset": 18,
+ "params": 221447814,
+ "source_sha256": "6c9ee08ce467af48767b74416646d82f8a0c1dcfb558c478e635cef0ca8b2ad2",
+ "exporter": "torchscript",
+ "torch": "2.13.0+cu130",
+ "export_seconds": 11.7,
+ "nodes": 2155,
+ "op_histogram": {
+ "Constant": 521,
+ "Add": 294,
+ "Reshape": 289,
+ "MatMul": 195,
+ "Mul": 164,
+ "Conv": 109,
+ "Transpose": 105,
+ "Sigmoid": 63,
+ "Shape": 61,
+ "Unsqueeze": 60,
+ "Gather": 53,
+ "InstanceNormalization": 46,
+ "LayerNormalization": 45,
+ "Slice": 34,
+ "Relu": 32,
+ "Gemm": 17,
+ "Div": 16,
+ "Softmax": 15,
+ "Concat": 12,
+ "Cast": 6,
+ "ConstantOfShape": 3,
+ "Equal": 3,
+ "Where": 3,
+ "Expand": 3,
+ "Resize": 2,
+ "Sub": 2,
+ "Sin": 1,
+ "Cos": 1
+ },
+ "inputs": [
+ [
+ "x_t",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "mask_lat",
+ [
+ 1,
+ 1,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "masked_lat",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "branch",
+ [
+ 2
+ ],
+ 7
+ ],
+ [
+ "coef",
+ [
+ 8
+ ],
+ 1
+ ],
+ [
+ "x0_prev",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ]
+ ],
+ "outputs": [
+ [
+ "x_next",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ],
+ [
+ "x0",
+ [
+ 1,
+ 4,
+ 64,
+ 64
+ ],
+ 1
+ ]
+ ],
+ "bytes": 443245583
+ },
+ "options": {
+ "posconv": "conv3d",
+ "upsample": "nearest_conv",
+ "latent_hw": [
+ 64,
+ 64
+ ],
+ "norm_fp32": false
+ }
+}
\ No newline at end of file
diff --git a/models/ort/unet_pretrained/model_b1.onnx b/models/ort/unet_pretrained/model_b1.onnx
new file mode 100644
index 0000000000000000000000000000000000000000..a10b8b9e0e9dc4dd122f0cc1007a23fa18ffa808
--- /dev/null
+++ b/models/ort/unet_pretrained/model_b1.onnx
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:560932a557f50e095b928b38f57ddea8db77fb186d2e93542b95f63e0358b112
+size 456438
diff --git a/models/ort/unet_pretrained/model_b2.onnx b/models/ort/unet_pretrained/model_b2.onnx
new file mode 100644
index 0000000000000000000000000000000000000000..27c262c0a0ae9b168d03379c8f4e9a18f6968769
--- /dev/null
+++ b/models/ort/unet_pretrained/model_b2.onnx
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:962e6283c2f578fcfa32e5f0a4df3f7bf160cd95cd8eac4e1a12ebd4da172ad2
+size 456896
diff --git a/models/ort/unet_pretrained/weights.bin b/models/ort/unet_pretrained/weights.bin
new file mode 100644
index 0000000000000000000000000000000000000000..e0c33eeed4e14ba358593143fad7d432ebea7f10
--- /dev/null
+++ b/models/ort/unet_pretrained/weights.bin
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:c5b2d4cd71f4080d90c8ab123d63cee41d38b69140ebc69d7371d4a45c53aa1c
+size 442821360
diff --git a/models/ort/vae_fp16/decoder.onnx b/models/ort/vae_fp16/decoder.onnx
new file mode 100644
index 0000000000000000000000000000000000000000..9a6cd0411653523f1df4bc733c8f461231165b65
--- /dev/null
+++ b/models/ort/vae_fp16/decoder.onnx
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:44b8c0fb44db2412048f4c6cac51c2f7ab7e7df47ba56e33512bd975c262797e
+size 99098258
diff --git a/models/ort/vae_fp16/encoder.onnx b/models/ort/vae_fp16/encoder.onnx
new file mode 100644
index 0000000000000000000000000000000000000000..65b0e40a973d3c0db1f27900696c22033a55ea47
--- /dev/null
+++ b/models/ort/vae_fp16/encoder.onnx
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d00aff246d1e6e97d950ce3c97ebf7f1e800341d88880dbee135db1d1737b9b5
+size 68431349
diff --git a/models/ort/vae_fp16/meta.json b/models/ort/vae_fp16/meta.json
new file mode 100644
index 0000000000000000000000000000000000000000..8f0c5b4b834707520ac9fab6da3010b2c9874f39
--- /dev/null
+++ b/models/ort/vae_fp16/meta.json
@@ -0,0 +1,125 @@
+{
+ "name": "vae_fp16",
+ "kind": "vae",
+ "precision": "fp16",
+ "opset": 18,
+ "scaling_factor": 0.13025,
+ "encoder": {
+ "export_seconds": 2.1,
+ "nodes": 480,
+ "op_histogram": {
+ "Constant": 145,
+ "Reshape": 56,
+ "Mul": 49,
+ "Add": 38,
+ "Shape": 30,
+ "Conv": 28,
+ "InstanceNormalization": 22,
+ "Sigmoid": 21,
+ "Unsqueeze": 15,
+ "Div": 14,
+ "Cast": 12,
+ "Transpose": 10,
+ "Concat": 9,
+ "Gather": 7,
+ "Slice": 6,
+ "MatMul": 6,
+ "ConstantOfShape": 3,
+ "Pad": 3,
+ "Sqrt": 3,
+ "Softmax": 1,
+ "Clip": 1,
+ "Exp": 1
+ },
+ "inputs": [
+ [
+ "image",
+ [
+ "B",
+ 3,
+ "H",
+ "W"
+ ],
+ 1
+ ]
+ ],
+ "outputs": [
+ [
+ "mean",
+ [
+ "B",
+ "Castmean_dim_1",
+ "h",
+ "w"
+ ],
+ 1
+ ],
+ [
+ "std",
+ [
+ "B",
+ "Caststd_dim_1",
+ "h",
+ "w"
+ ],
+ 1
+ ]
+ ],
+ "bytes": 68431349
+ },
+ "decoder": {
+ "export_seconds": 1.8,
+ "nodes": 533,
+ "op_histogram": {
+ "Constant": 146,
+ "Reshape": 66,
+ "Mul": 64,
+ "Add": 50,
+ "Shape": 37,
+ "Conv": 36,
+ "InstanceNormalization": 30,
+ "Sigmoid": 29,
+ "Div": 18,
+ "Unsqueeze": 15,
+ "Cast": 8,
+ "Transpose": 7,
+ "Gather": 6,
+ "Concat": 6,
+ "MatMul": 6,
+ "Sqrt": 3,
+ "Resize": 3,
+ "Slice": 1,
+ "Softmax": 1,
+ "Clip": 1
+ },
+ "inputs": [
+ [
+ "latent",
+ [
+ "B",
+ 4,
+ "h",
+ "w"
+ ],
+ 1
+ ]
+ ],
+ "outputs": [
+ [
+ "image",
+ [
+ "B",
+ 3,
+ "H",
+ "W"
+ ],
+ 1
+ ]
+ ],
+ "bytes": 99098258
+ },
+ "nodes": 1013,
+ "bytes": 167529607,
+ "export_seconds": 3.9000000000000004,
+ "source": "hustvl/PixelHacker vae (== madebyollin/sdxl-vae-fp16-fix)"
+}
\ No newline at end of file
diff --git a/models/torch/maskrcnn_resnet50_fpn_v2_coco.safetensors b/models/torch/maskrcnn_resnet50_fpn_v2_coco.safetensors
new file mode 100644
index 0000000000000000000000000000000000000000..4fd9cf50797ba80f141ce21ba79fac9e57dc7adc
--- /dev/null
+++ b/models/torch/maskrcnn_resnet50_fpn_v2_coco.safetensors
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:de8ca4510a47ed7f4506d425f8d39a4c53b3d2dbbd91a7f365cf15afe49447f7
+size 185728340
diff --git a/packs/moebius-ffhq/manifest.json b/packs/moebius-ffhq/manifest.json
new file mode 100644
index 0000000000000000000000000000000000000000..01633a0c3f21d6a3a26e2e29c65ca68db7656792
--- /dev/null
+++ b/packs/moebius-ffhq/manifest.json
@@ -0,0 +1,29 @@
+{
+ "name": "moebius-ffhq",
+ "model": "Moebius 0.22B inpainting (hustvl, ECCV'26)",
+ "variant": "ft_ffhq",
+ "label": "Faces (FFHQ fine-tune)",
+ "dtype": "float16",
+ "quant": "none",
+ "group_size": 64,
+ "quantized": [],
+ "resolution": 512,
+ "files": {
+ "unet.safetensors": {
+ "size": 476805987,
+ "sha256": "447f9e33dc2795df96fa94d478a19a0cd42afe62da685c3a45c0ef63baf309f1"
+ },
+ "temb.npz": {
+ "size": 5120262,
+ "sha256": "db4e76209b1149e80edc6f28fb71b38aeb6d1d17a5a40a11cac6bf71abb14fa6"
+ }
+ },
+ "sources": {
+ "hustvl/PixelHacker/vae/config.json": null,
+ "hustvl/PixelHacker/vae/diffusion_pytorch_model.bin": "a59d7ea697f2942d22002dc3469e8c53db807a6b78f7f5ec03bd4c1f70f98efe",
+ "hustvl/Moebius/ft_ffhq/diffusion_pytorch_model.bin": "ddd5b81b3034dea2bb380c574517ebbf24957903d99319fa8bbb8e69ca9d5606"
+ },
+ "license": "Moebius code: Apache-2.0 (GitHub); weights card: MIT (Hugging Face). VAE: hustvl/PixelHacker.",
+ "built": "2026-09-26 11:15:13",
+ "vae_from": "moebius-general"
+}
\ No newline at end of file
diff --git a/packs/moebius-ffhq/temb.npz b/packs/moebius-ffhq/temb.npz
new file mode 100644
index 0000000000000000000000000000000000000000..bf6546b3963b9b9c64edfd0b51921d302c7d2910
--- /dev/null
+++ b/packs/moebius-ffhq/temb.npz
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:db4e76209b1149e80edc6f28fb71b38aeb6d1d17a5a40a11cac6bf71abb14fa6
+size 5120262
diff --git a/packs/moebius-ffhq/unet.safetensors b/packs/moebius-ffhq/unet.safetensors
new file mode 100644
index 0000000000000000000000000000000000000000..813e5eb2656c24603925d2c618b87b7f5d74afba
--- /dev/null
+++ b/packs/moebius-ffhq/unet.safetensors
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:447f9e33dc2795df96fa94d478a19a0cd42afe62da685c3a45c0ef63baf309f1
+size 476805987
diff --git a/packs/moebius-general/coreml/vae_dec_vae.mlmodelc/analytics/coremldata.bin b/packs/moebius-general/coreml/vae_dec_vae.mlmodelc/analytics/coremldata.bin
new file mode 100644
index 0000000000000000000000000000000000000000..dfe4cc1536efbdd21363ca411c70331e97fd28c0
--- /dev/null
+++ b/packs/moebius-general/coreml/vae_dec_vae.mlmodelc/analytics/coremldata.bin
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a6663f0fb9e382b63c15a1115abcbe33cc8619449051ea529ec3fcdc178b7732
+size 243
diff --git a/packs/moebius-general/coreml/vae_dec_vae.mlmodelc/coremldata.bin b/packs/moebius-general/coreml/vae_dec_vae.mlmodelc/coremldata.bin
new file mode 100644
index 0000000000000000000000000000000000000000..85e0789c3c588eff8585e329265c5f0189c5e109
--- /dev/null
+++ b/packs/moebius-general/coreml/vae_dec_vae.mlmodelc/coremldata.bin
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:d68c4f729a505b616f7659890748c8b1af8b42c0d0f5012d1abf7663d85f675f
+size 375
diff --git a/packs/moebius-general/coreml/vae_dec_vae.mlmodelc/model.mil b/packs/moebius-general/coreml/vae_dec_vae.mlmodelc/model.mil
new file mode 100644
index 0000000000000000000000000000000000000000..83b885ce7859f3b1bb21f08548d88884b48bd1ab
--- /dev/null
+++ b/packs/moebius-general/coreml/vae_dec_vae.mlmodelc/model.mil
@@ -0,0 +1,994 @@
+program(1.3)
+[buildInfo = dict({{"coremlc-component-MIL", "3405.2.1"}, {"coremlc-version", "3405.2.1"}, {"coremltools-component-torch", "2.13.0"}, {"coremltools-source-dialect", "TorchScript"}, {"coremltools-version", "9.0"}})]
+{
+ func main(tensor latent) {
+ string latent_to_fp16_dtype_0 = const()[name = string("latent_to_fp16_dtype_0"), val = string("fp16")];
+ fp16 _inversed_input_1_y_0_to_fp16 = const()[name = string("_inversed_input_1_y_0_to_fp16"), val = fp16(0x1.eb4p+2)];
+ tensor latent_to_fp16 = cast(dtype = latent_to_fp16_dtype_0, x = latent)[name = string("cast_39")];
+ tensor _inversed_input_1_cast_fp16 = mul(x = latent_to_fp16, y = _inversed_input_1_y_0_to_fp16)[name = string("_inversed_input_1_cast_fp16")];
+ string input_3_pad_type_0 = const()[name = string("input_3_pad_type_0"), val = string("valid")];
+ tensor input_3_strides_0 = const()[name = string("input_3_strides_0"), val = tensor([1, 1])];
+ tensor input_3_pad_0 = const()[name = string("input_3_pad_0"), val = tensor([0, 0, 0, 0])];
+ tensor input_3_dilations_0 = const()[name = string("input_3_dilations_0"), val = tensor([1, 1])];
+ int32 input_3_groups_0 = const()[name = string("input_3_groups_0"), val = int32(1)];
+ tensor pqc_weight_to_fp16 = const()[name = string("pqc_weight_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(64)))];
+ tensor pqc_bias_to_fp16 = const()[name = string("pqc_bias_to_fp16"), val = tensor([-0x1.d7cp-5, 0x1.cf4p-3, -0x1.c7p-4, 0x1.adp-3])];
+ tensor input_3_cast_fp16 = conv(bias = pqc_bias_to_fp16, dilations = input_3_dilations_0, groups = input_3_groups_0, pad = input_3_pad_0, pad_type = input_3_pad_type_0, strides = input_3_strides_0, weight = pqc_weight_to_fp16, x = _inversed_input_1_cast_fp16)[name = string("input_3_cast_fp16")];
+ string input_5_pad_type_0 = const()[name = string("input_5_pad_type_0"), val = string("custom")];
+ tensor input_5_pad_0 = const()[name = string("input_5_pad_0"), val = tensor([1, 1, 1, 1])];
+ tensor input_5_strides_0 = const()[name = string("input_5_strides_0"), val = tensor([1, 1])];
+ tensor input_5_dilations_0 = const()[name = string("input_5_dilations_0"), val = tensor([1, 1])];
+ int32 input_5_groups_0 = const()[name = string("input_5_groups_0"), val = int32(1)];
+ tensor dec_conv_in_weight_to_fp16 = const()[name = string("dec_conv_in_weight_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(192)))];
+ tensor dec_conv_in_bias_to_fp16 = const()[name = string("dec_conv_in_bias_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(37120)))];
+ tensor input_5_cast_fp16 = conv(bias = dec_conv_in_bias_to_fp16, dilations = input_5_dilations_0, groups = input_5_groups_0, pad = input_5_pad_0, pad_type = input_5_pad_type_0, strides = input_5_strides_0, weight = dec_conv_in_weight_to_fp16, x = input_3_cast_fp16)[name = string("input_5_cast_fp16")];
+ tensor reshape_0_shape_0 = const()[name = string("reshape_0_shape_0"), val = tensor([1, 32, 16, 64, 64])];
+ tensor reshape_0_cast_fp16 = reshape(shape = reshape_0_shape_0, x = input_5_cast_fp16)[name = string("reshape_0_cast_fp16")];
+ tensor reduce_mean_0_axes_0 = const()[name = string("reduce_mean_0_axes_0"), val = tensor([2, 3, 4])];
+ bool reduce_mean_0_keep_dims_0 = const()[name = string("reduce_mean_0_keep_dims_0"), val = bool(true)];
+ tensor reduce_mean_0_cast_fp16 = reduce_mean(axes = reduce_mean_0_axes_0, keep_dims = reduce_mean_0_keep_dims_0, x = reshape_0_cast_fp16)[name = string("reduce_mean_0_cast_fp16")];
+ tensor sub_0_cast_fp16 = sub(x = reshape_0_cast_fp16, y = reduce_mean_0_cast_fp16)[name = string("sub_0_cast_fp16")];
+ tensor square_0_cast_fp16 = square(x = sub_0_cast_fp16)[name = string("square_0_cast_fp16")];
+ tensor reduce_mean_2_axes_0 = const()[name = string("reduce_mean_2_axes_0"), val = tensor([2, 3, 4])];
+ bool reduce_mean_2_keep_dims_0 = const()[name = string("reduce_mean_2_keep_dims_0"), val = bool(true)];
+ tensor reduce_mean_2_cast_fp16 = reduce_mean(axes = reduce_mean_2_axes_0, keep_dims = reduce_mean_2_keep_dims_0, x = square_0_cast_fp16)[name = string("reduce_mean_2_cast_fp16")];
+ fp16 add_0_y_0_to_fp16 = const()[name = string("add_0_y_0_to_fp16"), val = fp16(0x1.1p-20)];
+ tensor add_0_cast_fp16 = add(x = reduce_mean_2_cast_fp16, y = add_0_y_0_to_fp16)[name = string("add_0_cast_fp16")];
+ tensor sqrt_0_cast_fp16 = sqrt(x = add_0_cast_fp16)[name = string("sqrt_0_cast_fp16")];
+ tensor real_div_0_cast_fp16 = real_div(x = sub_0_cast_fp16, y = sqrt_0_cast_fp16)[name = string("real_div_0_cast_fp16")];
+ tensor reshape_1_shape_0 = const()[name = string("reshape_1_shape_0"), val = tensor([1, 512, 64, 64])];
+ tensor reshape_1_cast_fp16 = reshape(shape = reshape_1_shape_0, x = real_div_0_cast_fp16)[name = string("reshape_1_cast_fp16")];
+ tensor add_1_mean_0_to_fp16 = const()[name = string("add_1_mean_0_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(38208)))];
+ tensor add_1_variance_0_to_fp16 = const()[name = string("add_1_variance_0_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(39296)))];
+ tensor add_1_gamma_0_to_fp16 = const()[name = string("add_1_gamma_0_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(40384)))];
+ tensor add_1_beta_0_to_fp16 = const()[name = string("add_1_beta_0_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(41472)))];
+ fp16 add_1_epsilon_0_to_fp16 = const()[name = string("add_1_epsilon_0_to_fp16"), val = fp16(0x1.5p-17)];
+ tensor add_1_cast_fp16 = batch_norm(beta = add_1_beta_0_to_fp16, epsilon = add_1_epsilon_0_to_fp16, gamma = add_1_gamma_0_to_fp16, mean = add_1_mean_0_to_fp16, variance = add_1_variance_0_to_fp16, x = reshape_1_cast_fp16)[name = string("add_1_cast_fp16")];
+ tensor input_9_cast_fp16 = silu(x = add_1_cast_fp16)[name = string("input_9_cast_fp16")];
+ string input_11_pad_type_0 = const()[name = string("input_11_pad_type_0"), val = string("custom")];
+ tensor input_11_pad_0 = const()[name = string("input_11_pad_0"), val = tensor([1, 1, 1, 1])];
+ tensor input_11_strides_0 = const()[name = string("input_11_strides_0"), val = tensor([1, 1])];
+ tensor input_11_dilations_0 = const()[name = string("input_11_dilations_0"), val = tensor([1, 1])];
+ int32 input_11_groups_0 = const()[name = string("input_11_groups_0"), val = int32(1)];
+ tensor dec_mid_block_resnets_0_conv1_weight_to_fp16 = const()[name = string("dec_mid_block_resnets_0_conv1_weight_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(42560)))];
+ tensor dec_mid_block_resnets_0_conv1_bias_to_fp16 = const()[name = string("dec_mid_block_resnets_0_conv1_bias_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(4761216)))];
+ tensor input_11_cast_fp16 = conv(bias = dec_mid_block_resnets_0_conv1_bias_to_fp16, dilations = input_11_dilations_0, groups = input_11_groups_0, pad = input_11_pad_0, pad_type = input_11_pad_type_0, strides = input_11_strides_0, weight = dec_mid_block_resnets_0_conv1_weight_to_fp16, x = input_9_cast_fp16)[name = string("input_11_cast_fp16")];
+ tensor reshape_4_shape_0 = const()[name = string("reshape_4_shape_0"), val = tensor([1, 32, 16, 64, 64])];
+ tensor reshape_4_cast_fp16 = reshape(shape = reshape_4_shape_0, x = input_11_cast_fp16)[name = string("reshape_4_cast_fp16")];
+ tensor reduce_mean_3_axes_0 = const()[name = string("reduce_mean_3_axes_0"), val = tensor([2, 3, 4])];
+ bool reduce_mean_3_keep_dims_0 = const()[name = string("reduce_mean_3_keep_dims_0"), val = bool(true)];
+ tensor reduce_mean_3_cast_fp16 = reduce_mean(axes = reduce_mean_3_axes_0, keep_dims = reduce_mean_3_keep_dims_0, x = reshape_4_cast_fp16)[name = string("reduce_mean_3_cast_fp16")];
+ tensor sub_2_cast_fp16 = sub(x = reshape_4_cast_fp16, y = reduce_mean_3_cast_fp16)[name = string("sub_2_cast_fp16")];
+ tensor square_1_cast_fp16 = square(x = sub_2_cast_fp16)[name = string("square_1_cast_fp16")];
+ tensor reduce_mean_5_axes_0 = const()[name = string("reduce_mean_5_axes_0"), val = tensor([2, 3, 4])];
+ bool reduce_mean_5_keep_dims_0 = const()[name = string("reduce_mean_5_keep_dims_0"), val = bool(true)];
+ tensor reduce_mean_5_cast_fp16 = reduce_mean(axes = reduce_mean_5_axes_0, keep_dims = reduce_mean_5_keep_dims_0, x = square_1_cast_fp16)[name = string("reduce_mean_5_cast_fp16")];
+ fp16 add_2_y_0_to_fp16 = const()[name = string("add_2_y_0_to_fp16"), val = fp16(0x1.1p-20)];
+ tensor add_2_cast_fp16 = add(x = reduce_mean_5_cast_fp16, y = add_2_y_0_to_fp16)[name = string("add_2_cast_fp16")];
+ tensor sqrt_1_cast_fp16 = sqrt(x = add_2_cast_fp16)[name = string("sqrt_1_cast_fp16")];
+ tensor real_div_1_cast_fp16 = real_div(x = sub_2_cast_fp16, y = sqrt_1_cast_fp16)[name = string("real_div_1_cast_fp16")];
+ tensor reshape_5_shape_0 = const()[name = string("reshape_5_shape_0"), val = tensor([1, 512, 64, 64])];
+ tensor reshape_5_cast_fp16 = reshape(shape = reshape_5_shape_0, x = real_div_1_cast_fp16)[name = string("reshape_5_cast_fp16")];
+ tensor add_3_gamma_0_to_fp16 = const()[name = string("add_3_gamma_0_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(4762304)))];
+ tensor add_3_beta_0_to_fp16 = const()[name = string("add_3_beta_0_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(4763392)))];
+ fp16 add_3_epsilon_0_to_fp16 = const()[name = string("add_3_epsilon_0_to_fp16"), val = fp16(0x1.5p-17)];
+ tensor add_3_cast_fp16 = batch_norm(beta = add_3_beta_0_to_fp16, epsilon = add_3_epsilon_0_to_fp16, gamma = add_3_gamma_0_to_fp16, mean = add_1_mean_0_to_fp16, variance = add_1_variance_0_to_fp16, x = reshape_5_cast_fp16)[name = string("add_3_cast_fp16")];
+ tensor input_15_cast_fp16 = silu(x = add_3_cast_fp16)[name = string("input_15_cast_fp16")];
+ string hidden_states_1_pad_type_0 = const()[name = string("hidden_states_1_pad_type_0"), val = string("custom")];
+ tensor hidden_states_1_pad_0 = const()[name = string("hidden_states_1_pad_0"), val = tensor([1, 1, 1, 1])];
+ tensor hidden_states_1_strides_0 = const()[name = string("hidden_states_1_strides_0"), val = tensor([1, 1])];
+ tensor hidden_states_1_dilations_0 = const()[name = string("hidden_states_1_dilations_0"), val = tensor([1, 1])];
+ int32 hidden_states_1_groups_0 = const()[name = string("hidden_states_1_groups_0"), val = int32(1)];
+ tensor dec_mid_block_resnets_0_conv2_weight_to_fp16 = const()[name = string("dec_mid_block_resnets_0_conv2_weight_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(4764480)))];
+ tensor dec_mid_block_resnets_0_conv2_bias_to_fp16 = const()[name = string("dec_mid_block_resnets_0_conv2_bias_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(9483136)))];
+ tensor hidden_states_1_cast_fp16 = conv(bias = dec_mid_block_resnets_0_conv2_bias_to_fp16, dilations = hidden_states_1_dilations_0, groups = hidden_states_1_groups_0, pad = hidden_states_1_pad_0, pad_type = hidden_states_1_pad_type_0, strides = hidden_states_1_strides_0, weight = dec_mid_block_resnets_0_conv2_weight_to_fp16, x = input_15_cast_fp16)[name = string("hidden_states_1_cast_fp16")];
+ tensor var_84_cast_fp16 = add(x = input_5_cast_fp16, y = hidden_states_1_cast_fp16)[name = string("op_84_cast_fp16")];
+ tensor reshape_8_shape_0 = const()[name = string("reshape_8_shape_0"), val = tensor([1, 32, 16, 4096])];
+ tensor reshape_8_cast_fp16 = reshape(shape = reshape_8_shape_0, x = var_84_cast_fp16)[name = string("reshape_8_cast_fp16")];
+ tensor reduce_mean_6_axes_0 = const()[name = string("reduce_mean_6_axes_0"), val = tensor([2, 3])];
+ bool reduce_mean_6_keep_dims_0 = const()[name = string("reduce_mean_6_keep_dims_0"), val = bool(true)];
+ tensor reduce_mean_6_cast_fp16 = reduce_mean(axes = reduce_mean_6_axes_0, keep_dims = reduce_mean_6_keep_dims_0, x = reshape_8_cast_fp16)[name = string("reduce_mean_6_cast_fp16")];
+ tensor sub_4_cast_fp16 = sub(x = reshape_8_cast_fp16, y = reduce_mean_6_cast_fp16)[name = string("sub_4_cast_fp16")];
+ tensor square_2_cast_fp16 = square(x = sub_4_cast_fp16)[name = string("square_2_cast_fp16")];
+ tensor reduce_mean_8_axes_0 = const()[name = string("reduce_mean_8_axes_0"), val = tensor([2, 3])];
+ bool reduce_mean_8_keep_dims_0 = const()[name = string("reduce_mean_8_keep_dims_0"), val = bool(true)];
+ tensor reduce_mean_8_cast_fp16 = reduce_mean(axes = reduce_mean_8_axes_0, keep_dims = reduce_mean_8_keep_dims_0, x = square_2_cast_fp16)[name = string("reduce_mean_8_cast_fp16")];
+ fp16 add_4_y_0_to_fp16 = const()[name = string("add_4_y_0_to_fp16"), val = fp16(0x1.1p-20)];
+ tensor add_4_cast_fp16 = add(x = reduce_mean_8_cast_fp16, y = add_4_y_0_to_fp16)[name = string("add_4_cast_fp16")];
+ tensor sqrt_2_cast_fp16 = sqrt(x = add_4_cast_fp16)[name = string("sqrt_2_cast_fp16")];
+ tensor real_div_2_cast_fp16 = real_div(x = sub_4_cast_fp16, y = sqrt_2_cast_fp16)[name = string("real_div_2_cast_fp16")];
+ tensor reshape_9_shape_0 = const()[name = string("reshape_9_shape_0"), val = tensor([1, 512, 4096])];
+ tensor reshape_9_cast_fp16 = reshape(shape = reshape_9_shape_0, x = real_div_2_cast_fp16)[name = string("reshape_9_cast_fp16")];
+ tensor reshape_10_to_fp16 = const()[name = string("reshape_10_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(9484224)))];
+ tensor mul_2_cast_fp16 = mul(x = reshape_9_cast_fp16, y = reshape_10_to_fp16)[name = string("mul_2_cast_fp16")];
+ tensor reshape_11_to_fp16 = const()[name = string("reshape_11_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(9485312)))];
+ tensor add_5_cast_fp16 = add(x = mul_2_cast_fp16, y = reshape_11_to_fp16)[name = string("add_5_cast_fp16")];
+ tensor input_21_perm_0 = const()[name = string("input_21_perm_0"), val = tensor([0, 2, 1])];
+ tensor dec_mid_block_attentions_0_to_q_weight_to_fp16 = const()[name = string("dec_mid_block_attentions_0_to_q_weight_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(9486400)))];
+ tensor dec_mid_block_attentions_0_to_q_bias_to_fp16 = const()[name = string("dec_mid_block_attentions_0_to_q_bias_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(10010752)))];
+ tensor input_21_cast_fp16 = transpose(perm = input_21_perm_0, x = add_5_cast_fp16)[name = string("transpose_14")];
+ tensor linear_0_cast_fp16 = linear(bias = dec_mid_block_attentions_0_to_q_bias_to_fp16, weight = dec_mid_block_attentions_0_to_q_weight_to_fp16, x = input_21_cast_fp16)[name = string("linear_0_cast_fp16")];
+ tensor dec_mid_block_attentions_0_to_k_weight_to_fp16 = const()[name = string("dec_mid_block_attentions_0_to_k_weight_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(10011840)))];
+ tensor dec_mid_block_attentions_0_to_k_bias_to_fp16 = const()[name = string("dec_mid_block_attentions_0_to_k_bias_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(10536192)))];
+ tensor linear_1_cast_fp16 = linear(bias = dec_mid_block_attentions_0_to_k_bias_to_fp16, weight = dec_mid_block_attentions_0_to_k_weight_to_fp16, x = input_21_cast_fp16)[name = string("linear_1_cast_fp16")];
+ tensor dec_mid_block_attentions_0_to_v_weight_to_fp16 = const()[name = string("dec_mid_block_attentions_0_to_v_weight_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(10537280)))];
+ tensor dec_mid_block_attentions_0_to_v_bias_to_fp16 = const()[name = string("dec_mid_block_attentions_0_to_v_bias_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(11061632)))];
+ tensor linear_2_cast_fp16 = linear(bias = dec_mid_block_attentions_0_to_v_bias_to_fp16, weight = dec_mid_block_attentions_0_to_v_weight_to_fp16, x = input_21_cast_fp16)[name = string("linear_2_cast_fp16")];
+ tensor var_125 = const()[name = string("op_125"), val = tensor([1, -1, 1, 512])];
+ tensor var_126_cast_fp16 = reshape(shape = var_125, x = linear_0_cast_fp16)[name = string("op_126_cast_fp16")];
+ tensor var_128 = const()[name = string("op_128"), val = tensor([1, -1, 1, 512])];
+ tensor var_129_cast_fp16 = reshape(shape = var_128, x = linear_1_cast_fp16)[name = string("op_129_cast_fp16")];
+ tensor var_131 = const()[name = string("op_131"), val = tensor([1, -1, 1, 512])];
+ tensor var_132_cast_fp16 = reshape(shape = var_131, x = linear_2_cast_fp16)[name = string("op_132_cast_fp16")];
+ tensor transpose_6_perm_0 = const()[name = string("transpose_6_perm_0"), val = tensor([0, 2, 1, 3])];
+ tensor transpose_7_perm_0 = const()[name = string("transpose_7_perm_0"), val = tensor([0, 2, 1, 3])];
+ tensor transpose_8_perm_0 = const()[name = string("transpose_8_perm_0"), val = tensor([0, 2, 1, 3])];
+ tensor transpose_8 = transpose(perm = transpose_8_perm_0, x = var_132_cast_fp16)[name = string("transpose_11")];
+ tensor transpose_7 = transpose(perm = transpose_7_perm_0, x = var_129_cast_fp16)[name = string("transpose_12")];
+ tensor transpose_6 = transpose(perm = transpose_6_perm_0, x = var_126_cast_fp16)[name = string("transpose_13")];
+ tensor hidden_states_7_cast_fp16 = scaled_dot_product_attention(key = transpose_7, query = transpose_6, value = transpose_8)[name = string("hidden_states_7_cast_fp16")];
+ tensor var_135_perm_0 = const()[name = string("op_135_perm_0"), val = tensor([0, 2, 1, 3])];
+ tensor var_139 = const()[name = string("op_139"), val = tensor([1, -1, 512])];
+ tensor var_135_cast_fp16 = transpose(perm = var_135_perm_0, x = hidden_states_7_cast_fp16)[name = string("transpose_10")];
+ tensor hidden_states_9_cast_fp16 = reshape(shape = var_139, x = var_135_cast_fp16)[name = string("hidden_states_9_cast_fp16")];
+ tensor dec_mid_block_attentions_0_to_out_0_weight_to_fp16 = const()[name = string("dec_mid_block_attentions_0_to_out_0_weight_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(11062720)))];
+ tensor dec_mid_block_attentions_0_to_out_0_bias_to_fp16 = const()[name = string("dec_mid_block_attentions_0_to_out_0_bias_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(11587072)))];
+ tensor linear_3_cast_fp16 = linear(bias = dec_mid_block_attentions_0_to_out_0_bias_to_fp16, weight = dec_mid_block_attentions_0_to_out_0_weight_to_fp16, x = hidden_states_9_cast_fp16)[name = string("linear_3_cast_fp16")];
+ tensor var_146_perm_0 = const()[name = string("op_146_perm_0"), val = tensor([0, -1, -2])];
+ tensor var_147 = const()[name = string("op_147"), val = tensor([1, 512, 64, 64])];
+ tensor var_146_cast_fp16 = transpose(perm = var_146_perm_0, x = linear_3_cast_fp16)[name = string("transpose_9")];
+ tensor hidden_states_13_cast_fp16 = reshape(shape = var_147, x = var_146_cast_fp16)[name = string("hidden_states_13_cast_fp16")];
+ tensor hidden_states_15_cast_fp16 = add(x = hidden_states_13_cast_fp16, y = var_84_cast_fp16)[name = string("hidden_states_15_cast_fp16")];
+ tensor reshape_12_shape_0 = const()[name = string("reshape_12_shape_0"), val = tensor([1, 32, 16, 64, 64])];
+ tensor reshape_12_cast_fp16 = reshape(shape = reshape_12_shape_0, x = hidden_states_15_cast_fp16)[name = string("reshape_12_cast_fp16")];
+ tensor reduce_mean_9_axes_0 = const()[name = string("reduce_mean_9_axes_0"), val = tensor([2, 3, 4])];
+ bool reduce_mean_9_keep_dims_0 = const()[name = string("reduce_mean_9_keep_dims_0"), val = bool(true)];
+ tensor reduce_mean_9_cast_fp16 = reduce_mean(axes = reduce_mean_9_axes_0, keep_dims = reduce_mean_9_keep_dims_0, x = reshape_12_cast_fp16)[name = string("reduce_mean_9_cast_fp16")];
+ tensor sub_6_cast_fp16 = sub(x = reshape_12_cast_fp16, y = reduce_mean_9_cast_fp16)[name = string("sub_6_cast_fp16")];
+ tensor square_3_cast_fp16 = square(x = sub_6_cast_fp16)[name = string("square_3_cast_fp16")];
+ tensor reduce_mean_11_axes_0 = const()[name = string("reduce_mean_11_axes_0"), val = tensor([2, 3, 4])];
+ bool reduce_mean_11_keep_dims_0 = const()[name = string("reduce_mean_11_keep_dims_0"), val = bool(true)];
+ tensor reduce_mean_11_cast_fp16 = reduce_mean(axes = reduce_mean_11_axes_0, keep_dims = reduce_mean_11_keep_dims_0, x = square_3_cast_fp16)[name = string("reduce_mean_11_cast_fp16")];
+ fp16 add_6_y_0_to_fp16 = const()[name = string("add_6_y_0_to_fp16"), val = fp16(0x1.1p-20)];
+ tensor add_6_cast_fp16 = add(x = reduce_mean_11_cast_fp16, y = add_6_y_0_to_fp16)[name = string("add_6_cast_fp16")];
+ tensor sqrt_3_cast_fp16 = sqrt(x = add_6_cast_fp16)[name = string("sqrt_3_cast_fp16")];
+ tensor real_div_3_cast_fp16 = real_div(x = sub_6_cast_fp16, y = sqrt_3_cast_fp16)[name = string("real_div_3_cast_fp16")];
+ tensor reshape_13_shape_0 = const()[name = string("reshape_13_shape_0"), val = tensor([1, 512, 64, 64])];
+ tensor reshape_13_cast_fp16 = reshape(shape = reshape_13_shape_0, x = real_div_3_cast_fp16)[name = string("reshape_13_cast_fp16")];
+ tensor add_7_gamma_0_to_fp16 = const()[name = string("add_7_gamma_0_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(11588160)))];
+ tensor add_7_beta_0_to_fp16 = const()[name = string("add_7_beta_0_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(11589248)))];
+ fp16 add_7_epsilon_0_to_fp16 = const()[name = string("add_7_epsilon_0_to_fp16"), val = fp16(0x1.5p-17)];
+ tensor add_7_cast_fp16 = batch_norm(beta = add_7_beta_0_to_fp16, epsilon = add_7_epsilon_0_to_fp16, gamma = add_7_gamma_0_to_fp16, mean = add_1_mean_0_to_fp16, variance = add_1_variance_0_to_fp16, x = reshape_13_cast_fp16)[name = string("add_7_cast_fp16")];
+ tensor input_31_cast_fp16 = silu(x = add_7_cast_fp16)[name = string("input_31_cast_fp16")];
+ string input_33_pad_type_0 = const()[name = string("input_33_pad_type_0"), val = string("custom")];
+ tensor input_33_pad_0 = const()[name = string("input_33_pad_0"), val = tensor([1, 1, 1, 1])];
+ tensor input_33_strides_0 = const()[name = string("input_33_strides_0"), val = tensor([1, 1])];
+ tensor input_33_dilations_0 = const()[name = string("input_33_dilations_0"), val = tensor([1, 1])];
+ int32 input_33_groups_0 = const()[name = string("input_33_groups_0"), val = int32(1)];
+ tensor dec_mid_block_resnets_1_conv1_weight_to_fp16 = const()[name = string("dec_mid_block_resnets_1_conv1_weight_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(11590336)))];
+ tensor dec_mid_block_resnets_1_conv1_bias_to_fp16 = const()[name = string("dec_mid_block_resnets_1_conv1_bias_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(16308992)))];
+ tensor input_33_cast_fp16 = conv(bias = dec_mid_block_resnets_1_conv1_bias_to_fp16, dilations = input_33_dilations_0, groups = input_33_groups_0, pad = input_33_pad_0, pad_type = input_33_pad_type_0, strides = input_33_strides_0, weight = dec_mid_block_resnets_1_conv1_weight_to_fp16, x = input_31_cast_fp16)[name = string("input_33_cast_fp16")];
+ tensor reshape_16_shape_0 = const()[name = string("reshape_16_shape_0"), val = tensor([1, 32, 16, 64, 64])];
+ tensor reshape_16_cast_fp16 = reshape(shape = reshape_16_shape_0, x = input_33_cast_fp16)[name = string("reshape_16_cast_fp16")];
+ tensor reduce_mean_12_axes_0 = const()[name = string("reduce_mean_12_axes_0"), val = tensor([2, 3, 4])];
+ bool reduce_mean_12_keep_dims_0 = const()[name = string("reduce_mean_12_keep_dims_0"), val = bool(true)];
+ tensor reduce_mean_12_cast_fp16 = reduce_mean(axes = reduce_mean_12_axes_0, keep_dims = reduce_mean_12_keep_dims_0, x = reshape_16_cast_fp16)[name = string("reduce_mean_12_cast_fp16")];
+ tensor sub_8_cast_fp16 = sub(x = reshape_16_cast_fp16, y = reduce_mean_12_cast_fp16)[name = string("sub_8_cast_fp16")];
+ tensor square_4_cast_fp16 = square(x = sub_8_cast_fp16)[name = string("square_4_cast_fp16")];
+ tensor reduce_mean_14_axes_0 = const()[name = string("reduce_mean_14_axes_0"), val = tensor([2, 3, 4])];
+ bool reduce_mean_14_keep_dims_0 = const()[name = string("reduce_mean_14_keep_dims_0"), val = bool(true)];
+ tensor reduce_mean_14_cast_fp16 = reduce_mean(axes = reduce_mean_14_axes_0, keep_dims = reduce_mean_14_keep_dims_0, x = square_4_cast_fp16)[name = string("reduce_mean_14_cast_fp16")];
+ fp16 add_8_y_0_to_fp16 = const()[name = string("add_8_y_0_to_fp16"), val = fp16(0x1.1p-20)];
+ tensor add_8_cast_fp16 = add(x = reduce_mean_14_cast_fp16, y = add_8_y_0_to_fp16)[name = string("add_8_cast_fp16")];
+ tensor sqrt_4_cast_fp16 = sqrt(x = add_8_cast_fp16)[name = string("sqrt_4_cast_fp16")];
+ tensor real_div_4_cast_fp16 = real_div(x = sub_8_cast_fp16, y = sqrt_4_cast_fp16)[name = string("real_div_4_cast_fp16")];
+ tensor reshape_17_shape_0 = const()[name = string("reshape_17_shape_0"), val = tensor([1, 512, 64, 64])];
+ tensor reshape_17_cast_fp16 = reshape(shape = reshape_17_shape_0, x = real_div_4_cast_fp16)[name = string("reshape_17_cast_fp16")];
+ tensor add_9_gamma_0_to_fp16 = const()[name = string("add_9_gamma_0_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(16310080)))];
+ tensor add_9_beta_0_to_fp16 = const()[name = string("add_9_beta_0_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(16311168)))];
+ fp16 add_9_epsilon_0_to_fp16 = const()[name = string("add_9_epsilon_0_to_fp16"), val = fp16(0x1.5p-17)];
+ tensor add_9_cast_fp16 = batch_norm(beta = add_9_beta_0_to_fp16, epsilon = add_9_epsilon_0_to_fp16, gamma = add_9_gamma_0_to_fp16, mean = add_1_mean_0_to_fp16, variance = add_1_variance_0_to_fp16, x = reshape_17_cast_fp16)[name = string("add_9_cast_fp16")];
+ tensor input_37_cast_fp16 = silu(x = add_9_cast_fp16)[name = string("input_37_cast_fp16")];
+ string hidden_states_17_pad_type_0 = const()[name = string("hidden_states_17_pad_type_0"), val = string("custom")];
+ tensor hidden_states_17_pad_0 = const()[name = string("hidden_states_17_pad_0"), val = tensor([1, 1, 1, 1])];
+ tensor hidden_states_17_strides_0 = const()[name = string("hidden_states_17_strides_0"), val = tensor([1, 1])];
+ tensor hidden_states_17_dilations_0 = const()[name = string("hidden_states_17_dilations_0"), val = tensor([1, 1])];
+ int32 hidden_states_17_groups_0 = const()[name = string("hidden_states_17_groups_0"), val = int32(1)];
+ tensor dec_mid_block_resnets_1_conv2_weight_to_fp16 = const()[name = string("dec_mid_block_resnets_1_conv2_weight_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(16312256)))];
+ tensor dec_mid_block_resnets_1_conv2_bias_to_fp16 = const()[name = string("dec_mid_block_resnets_1_conv2_bias_to_fp16"), val = tensor(BLOBFILE(path = string("@model_path/weights/weight.bin"), offset = uint64(21030912)))];
+ tensor hidden_states_17_cast_fp16 = conv(bias = dec_mid_block_resnets_1_conv2_bias_to_fp16, dilations = hidden_states_17_dilations_0, groups = hidden_states_17_groups_0, pad = hidden_states_17_pad_0, pad_type = hidden_states_17_pad_type_0, strides = hidden_states_17_strides_0, weight = dec_mid_block_resnets_1_conv2_weight_to_fp16, x = input_37_cast_fp16)[name = string("hidden_states_17_cast_fp16")];
+ tensor var_179_cast_fp16 = add(x = hidden_states_15_cast_fp16, y = hidden_states_17_cast_fp16)[name = string("op_179_cast_fp16")];
+ tensor reshape_20_shape_0 = const()[name = string("reshape_20_shape_0"), val = tensor([1, 32, 16, 64, 64])];
+ tensor