mlboydaisuke commited on
Commit
aba8417
·
verified ·
1 Parent(s): 59e713a

Add files using upload-large-folder tool

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ sam3_float16.aimodel/main.mlirb filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ SAM License
2
+ Last Updated: November 19, 2025
3
+
4
+ “Agreement” means the terms and conditions for use, reproduction, distribution and modification of the SAM Materials set forth herein.
5
+
6
+
7
+ “SAM Materials” means, collectively, Documentation and the models, software and algorithms, including machine-learning model code, trained model weights, inference-enabling code, training-enabling code, fine-tuning enabling code, and other elements of the foregoing distributed by Meta and made available under this Agreement.
8
+
9
+ “Documentation” means the specifications, manuals and documentation accompanying
10
+ SAM Materials distributed by Meta.
11
+
12
+
13
+ “Licensee” or “you” means you, or your employer or any other person or entity (if you are entering into this Agreement on such person or entity’s behalf), of the age required under applicable laws, rules or regulations to provide legal consent and that has legal authority to bind your employer or such other person or entity if you are entering in this Agreement on their behalf.
14
+
15
+
16
+ “Meta” or “we” means Meta Platforms Ireland Limited (if you are located in or, if you are an entity, your principal place of business is in the EEA or Switzerland) or Meta Platforms, Inc. (if you are located outside of the EEA or Switzerland).
17
+
18
+
19
+ “Sanctions” means any economic or trade sanctions or restrictions administered or enforced by the United States (including the Office of Foreign Assets Control of the U.S. Department of the Treasury (“OFAC”), the U.S. Department of State and the U.S. Department of Commerce), the United Nations, the European Union, or the United Kingdom.
20
+
21
+
22
+ “Trade Controls” means any of the following: Sanctions and applicable export and import controls.
23
+
24
+ By using or distributing any portion or element of the SAM Materials, you agree to be bound by this Agreement.
25
+
26
+
27
+ 1. License Rights and Redistribution.
28
+
29
+
30
+ a. Grant of Rights. You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Meta’s intellectual property or other rights owned by Meta embodied in the SAM Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the SAM Materials.
31
+
32
+ b. Redistribution and Use.
33
+ i. Distribution of SAM Materials, and any derivative works thereof, are subject to the terms of this Agreement. If you distribute or make the SAM Materials, or any derivative works thereof, available to a third party, you may only do so under the terms of this Agreement and you shall provide a copy of this Agreement with any such SAM Materials.
34
+
35
+
36
+ ii. If you submit for publication the results of research you perform on, using, or otherwise in connection with SAM Materials, you must acknowledge the use of SAM Materials in your publication.
37
+
38
+
39
+ iii. Your use of the SAM Materials must comply with applicable laws and regulations, including Trade Control Laws and applicable privacy and data protection laws.
40
+ iv. Your use of the SAM Materials will not involve or encourage others to reverse engineer, decompile or discover the underlying components of the SAM Materials.
41
+ v. You are not the target of Trade Controls and your use of SAM Materials must comply with Trade Controls. You agree not to use, or permit others to use, SAM Materials for any activities subject to the International Traffic in Arms Regulations (ITAR) or end uses prohibited by Trade Controls, including those related to military or warfare purposes, nuclear industries or applications, espionage, or the development or use of guns or illegal weapons.
42
+ 2. User Support. Your use of the SAM Materials is done at your own discretion; Meta does not process any information nor provide any service in relation to such use. Meta is under no obligation to provide any support services for the SAM Materials. Any support provided is “as is”, “with all faults”, and without warranty of any kind.
43
+
44
+
45
+ 3. Disclaimer of Warranty. UNLESS REQUIRED BY APPLICABLE LAW, THE SAM MATERIALS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, AND META DISCLAIMS ALL WARRANTIES OF ANY KIND, BOTH EXPRESS AND IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE SAM MATERIALS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR USE OF THE SAM MATERIALS AND ANY OUTPUT AND RESULTS.
46
+
47
+ 4. Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS AGREEMENT, FOR ANY LOST PROFITS OR ANY DIRECT OR INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN IF META OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
48
+
49
+ 5. Intellectual Property.
50
+
51
+
52
+ a. Subject to Meta’s ownership of SAM Materials and derivatives made by or for Meta, with respect to any derivative works and modifications of the SAM Materials that are made by you, as between you and Meta, you are and will be the owner of such derivative works and modifications.
53
+
54
+ b. If you institute litigation or other proceedings against Meta or any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the SAM Materials, outputs or results, or any portion of any of the foregoing, constitutes infringement of intellectual property or other rights owned or licensable by you, then any licenses granted to you under this Agreement shall terminate as of the date such litigation or claim is filed or instituted. You will indemnify and hold harmless Meta from and against any claim by any third party arising out of or related to your use or distribution of the SAM Materials.
55
+
56
+ 6. Term and Termination. The term of this Agreement will commence upon your acceptance of this Agreement or access to the SAM Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein. Meta may terminate this Agreement if you are in breach of any term or condition of this Agreement. Upon termination of this Agreement, you shall delete and cease use of the SAM Materials. Sections 3, 4 and 7 shall survive the termination of this Agreement.
57
+
58
+ 7. Governing Law and Jurisdiction. This Agreement will be governed and construed under the laws of the State of California without regard to choice of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement. The courts of California shall have exclusive jurisdiction of any dispute arising out of this Agreement.
59
+
60
+
61
+ 8. Modifications and Amendments. Meta may modify this Agreement from time to time; provided that they are similar in spirit to the current version of the Agreement, but may differ in detail to address new problems or concerns. All such changes will be effective immediately. Your continued use of the SAM Materials after any modification to this Agreement constitutes your agreement to such modification. Except as provided in this Agreement, no modification or addition to any provision of this Agreement will be binding unless it is in writing and signed by an authorized representative of both you and Meta.
README.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: sam-license
4
+ license_link: https://huggingface.co/facebook/sam3/blob/main/LICENSE
5
+ base_model: facebook/sam3
6
+ pipeline_tag: image-segmentation
7
+ tags:
8
+ - coreai
9
+ - apple
10
+ - aimodel
11
+ - apple-silicon
12
+ - segmentation
13
+ - sam3
14
+ ---
15
+
16
+ # SAM 3 — official Apple Core AI export
17
+
18
+ A pre-converted **`.aimodel` segmenter bundle from Apple's official
19
+ [coreai-models](https://github.com/apple/coreai-models) export recipe — unmodified**, with
20
+ the exact environment, hashes, and measured performance published.
21
+
22
+ [SAM 3](https://huggingface.co/facebook/sam3) (Segment Anything Model 3, Meta) is a unified,
23
+ **promptable** segmentation model. This bundle is the **image + text-prompt** variant: give
24
+ it an image and a phrase (`cat`, `the red car`) and it returns instance masks, boxes, and
25
+ per-instance scores — open-vocabulary, no fixed class list. It runs on the **stock** Core AI
26
+ runtime via Apple's `CoreAIImageSegmenter` (no engine patch).
27
+
28
+ ```bash
29
+ # from an apple/coreai-models checkout (gated model — accept the SAM license + hf auth login first)
30
+ uv run models/sam3/export.py --dtype float16
31
+ ```
32
+
33
+ ## Why a pre-converted bundle?
34
+
35
+ An `.aimodel` is a build artifact, not a pure function of the recipe — the toolchain and OS
36
+ lowering matter, and the source checkpoint is **gated**. This is the exact, hash-stamped
37
+ bundle behind the published numbers, so you can drop it in and reproduce them without a
38
+ conversion environment or accepting the upstream license just to get the converted graph.
39
+
40
+ ## Bundle layout & integrity
41
+
42
+ A segmenter bundle directory (`metadata.json` schema 0.2 + the `.aimodel` + a CLIP `tokenizer/`):
43
+
44
+ ```
45
+ sam3_float16.aimodel/ main.mlirb + main.hash + metadata.json
46
+ tokenizer/ tokenizer.json + tokenizer_config.json
47
+ metadata.json kind: segmenter, assets.main → sam3_float16.aimodel
48
+ ```
49
+
50
+ | File | Contents | SHA-256 |
51
+ |---|---|---|
52
+ | `sam3_float16.aimodel/main.mlirb` | float16 weights + graph (~1.5 GB) | `be9484b4c5fa75f9011668c481e27de253e1db55fcde39a1ba0cab8698706620` |
53
+ | `sam3_float16.aimodel/main.hash` | graph hash | `9f631da3be044ad5de56a1d29af88394e7e725e3cf52f50ac556dcce9cdd568c` |
54
+
55
+ ## Measured
56
+
57
+ Apple's official `image-segmenter` CLI, **M4 Max**, the COCO two-cats image (640×480, resized
58
+ to 1008×1008 internally), text prompt `cat`:
59
+
60
+ | Metric | Value |
61
+ |---|---|
62
+ | Inference (warm, incl. pre/post-processing) | **0.55 s** |
63
+ | Output | 2 high-confidence instance masks for "cat" (scores **0.97** and **0.96**); spurious queries fall below the 0.5 threshold |
64
+
65
+ **float16 vs float32 fidelity** (same recipe, both exported and run through the engine): top-2
66
+ scores differ by **≤ 1e-4** (0.9746 vs 0.9747, 0.9646 vs 0.9645), bounding boxes within **1 px**,
67
+ and the top-3 masks have **identical** foreground pixel counts. float16 is shipped (half the
68
+ size, iOS-friendly); float32 reproduces with `--dtype float32`.
69
+
70
+ ## Export environment
71
+
72
+ - macOS 27.0 beta · Xcode 27.0 beta
73
+ - `coreai-core 1.0.0b1` · `coreai-torch 0.4.0` · `transformers 5.x`
74
+ - apple/coreai-models recipe `models/sam3/export.py` (unmodified upstream)
75
+
76
+ ## Run it
77
+
78
+ ```bash
79
+ # CLI (from an apple/coreai-models checkout)
80
+ swift run -c release image-segmenter \
81
+ --model <downloaded-bundle-dir> --prompt "cat" --image cats.jpg
82
+ ```
83
+
84
+ Or in the [CoreAISegment sample app](https://github.com/john-rocky/coreai-model-zoo/tree/main/apps/CoreAISegment)
85
+ (macOS + iOS): pick an image, type a prompt, tap Segment.
86
+
87
+ ```swift
88
+ import CoreAIImageSegmenter
89
+ let segmenter = try await ImageSegmenter(resourcesAt: "<bundle-dir>")
90
+ let result = try await segmenter.segment(image: cgImage, prompt: "cat")
91
+ // result.segments: [Segment] — each has .mask, .box, .score
92
+ ```
93
+
94
+ iOS bundles should be AOT-compiled before device use:
95
+ `xcrun coreai-build compile <ir>.aimodel --platform iOS --architecture h18p`
96
+ (h18p = iPhone 17 Pro), then point `metadata.json` `assets.main` at the `.aimodelc`.
97
+
98
+ ## License
99
+
100
+ SAM 3 is distributed under Meta's **SAM License** (see `LICENSE` and the
101
+ [upstream model card](https://huggingface.co/facebook/sam3)). This bundle is a format
102
+ conversion of those weights and inherits that license; review it before use.
103
+
104
+ ---
105
+ Maintained alongside [coreai-model-zoo](https://github.com/john-rocky/coreai-model-zoo)
106
+ (see [`official/`](https://github.com/john-rocky/coreai-model-zoo/tree/main/official) for the
107
+ other unmodified official-recipe conversions).
metadata.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata_version": "0.2",
3
+ "kind": "segmenter",
4
+ "name": "sam3_float16",
5
+ "assets": {
6
+ "main": "sam3_float16.aimodel"
7
+ }
8
+ }
sam3_float16.aimodel/main.hash ADDED
@@ -0,0 +1 @@
 
 
1
+ ������u�hā�}�S��U��9�� ���pf
sam3_float16.aimodel/main.mlirb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be9484b4c5fa75f9011668c481e27de253e1db55fcde39a1ba0cab8698706620
3
+ size 1663478532
sam3_float16.aimodel/metadata.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "creationDate" : "20260623T071546Z",
3
+ "license" : "SAM License",
4
+ "author" : "N. Carion et al.",
5
+ "description" : "SAM 3 is a unified foundation model for promptable segmentation in images and videos. It can detect, segment, and track objects using text or visual prompts such as points, boxes, and masks. This variant is explicitly for image segmentation. Source: https:\/\/github.com\/facebookresearch\/sam3",
6
+ "assetVersion" : "2.0"
7
+ }
tokenizer/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer/tokenizer_config.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<|startoftext|>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "do_lower_case": true,
7
+ "eos_token": "<|endoftext|>",
8
+ "errors": "replace",
9
+ "is_local": false,
10
+ "local_files_only": true,
11
+ "max_length": 32,
12
+ "model_max_length": 32,
13
+ "pad_token": "<|endoftext|>",
14
+ "processor_class": "Sam3VideoProcessor",
15
+ "tokenizer_class": "CLIPTokenizer",
16
+ "unk_token": "<|endoftext|>"
17
+ }