Skip to content

Commit 4d9ce61

Browse files
committed
refactor(models): move FastSAM from object_detection to instance_segmentation
FastSAM is consumed via useInstanceSegmentation, so its accessor belongs in models.instance_segmentation. Move fastsam_s/fastsam_x and update demo apps and docs accordingly.
1 parent 190d38b commit 4d9ce61

6 files changed

Lines changed: 15 additions & 15 deletions

File tree

apps/computer-vision/app/instance_segmentation/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import ImageWithMasks, {
2323
} from '../../components/ImageWithMasks';
2424
import { StatsBar } from '../../components/StatsBar';
2525
const instanceSegmentation = models.instance_segmentation;
26-
const objectDetection = models.object_detection;
2726

2827
const MODELS: ModelOption<InstanceSegmentationModelSources>[] = [
2928
{ label: 'Yolo26N', value: instanceSegmentation.yolo26n() },
@@ -35,8 +34,8 @@ const MODELS: ModelOption<InstanceSegmentationModelSources>[] = [
3534
label: 'RF-DeTR Nano',
3635
value: instanceSegmentation.rf_detr_nano(),
3736
},
38-
{ label: 'FastSAM-S', value: objectDetection.fastsam_s() },
39-
{ label: 'FastSAM-X', value: objectDetection.fastsam_x() },
37+
{ label: 'FastSAM-S', value: instanceSegmentation.fastsam_s() },
38+
{ label: 'FastSAM-X', value: instanceSegmentation.fastsam_x() },
4039
];
4140

4241
export default function InstanceSegmentationScreen() {

apps/computer-vision/app/segment_anything/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,22 @@ import ImageWithMasks, {
4545
} from '../../components/ImageWithMasks';
4646
import { getImage } from '../../utils';
4747
import ColorPalette from '../../colors';
48-
const objectDetection = models.object_detection;
48+
const instanceSegmentation = models.instance_segmentation;
4949

5050
type PromptMode = 'point' | 'box' | 'text';
5151

5252
const MODELS: ModelOption<InstanceSegmentationModelSources>[] = [
53-
{ label: 'FastSAM-S', value: objectDetection.fastsam_s() },
54-
{ label: 'FastSAM-X', value: objectDetection.fastsam_x() },
53+
{ label: 'FastSAM-S', value: instanceSegmentation.fastsam_s() },
54+
{ label: 'FastSAM-X', value: instanceSegmentation.fastsam_x() },
5555
];
5656

5757
export default function SegmentAnythingScreen() {
5858
const { setGlobalGenerating } = useContext(GeneratingContext);
5959

6060
const [selectedModel, setSelectedModel] =
61-
useState<InstanceSegmentationModelSources>(objectDetection.fastsam_s());
61+
useState<InstanceSegmentationModelSources>(
62+
instanceSegmentation.fastsam_s()
63+
);
6264
const [mode, setMode] = useState<PromptMode>('point');
6365
const [inferenceTime, setInferenceTime] = useState<number | null>(null);
6466

apps/computer-vision/components/vision_camera/tasks/InstanceSegmentationTask.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
DisplayInstance,
1919
} from '../../../components/ImageWithMasks';
2020
const instanceSegmentation = models.instance_segmentation;
21-
const objectDetection = models.object_detection;
2221

2322
type InstSegModelId =
2423
| 'instanceSegmentationYolo26n'
@@ -49,11 +48,11 @@ export default function InstanceSegmentationTask({
4948
preventLoad: activeModel !== 'instanceSegmentationRfdetr',
5049
});
5150
const fastsamS = useInstanceSegmentation({
52-
model: objectDetection.fastsam_s(),
51+
model: instanceSegmentation.fastsam_s(),
5352
preventLoad: activeModel !== 'instanceSegmentationFastsamS',
5453
});
5554
const fastsamX = useInstanceSegmentation({
56-
model: objectDetection.fastsam_x(),
55+
model: instanceSegmentation.fastsam_x(),
5756
preventLoad: activeModel !== 'instanceSegmentationFastsamX',
5857
});
5958

docs/docs/03-hooks/02-computer-vision/useInstanceSegmentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ import {
155155
selectByText,
156156
} from 'react-native-executorch';
157157
const model = useInstanceSegmentation({
158-
model: models.object_detection.fastsam_x(),
158+
model: models.instance_segmentation.fastsam_x(),
159159
});
160160

161161
try {

docs/docs/05-utilities/model-registry.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Each leaf is a **function**. Call it (optionally with `{ quant, backend }`) to g
2525
| `llm` | `llama3_2_3b`, `qwen3_4b`, `smollm2_1_1_7b`, `phi_4_mini_4b`, `bielik_v3_0_1_5b`, `lfm2_5_1_2b_instruct`, `lfm2_5_vl_1_6b`, `lfm2_5_vl_450m`, … |
2626
| `classification` | `efficientnet_v2_s` |
2727
| `privacy_filter` | `openai`, `nemotron` |
28-
| `object_detection` | `ssdlite_320_mobilenet_v3_large`, `yolo26n``yolo26x`, `rf_detr_nano`, `fastsam_s`, `fastsam_x` |
28+
| `object_detection` | `ssdlite_320_mobilenet_v3_large`, `yolo26n``yolo26x`, `rf_detr_nano` |
2929
| `pose_estimation` | `yolo26n` |
3030
| `semantic_segmentation` | `deeplab_v3_resnet50`, `lraspp_mobilenet_v3_large`, `fcn_resnet101`, `selfie_segmentation`, … |
31-
| `instance_segmentation` | `yolo26n``yolo26x`, `rf_detr_nano` |
31+
| `instance_segmentation` | `yolo26n``yolo26x`, `rf_detr_nano`, `fastsam_s`, `fastsam_x` |
3232
| `style_transfer` | `candy`, `mosaic`, `rain_princess`, `udnie` |
3333
| `speech_to_text` | `whisper_tiny_en`, `whisper_base`, `whisper_small_en`, … |
3434
| `text_to_speech` | nested by model family + language: `kokoro.en_us.{heart, river, sarah, adam, …}`, `kokoro.en_gb.{emma, daniel}`, `kokoro.fr.siwis`, `kokoro.es.{dora, alex}`, `kokoro.it.{sara, nicola}`, `kokoro.pt.{dora, santa}`, `kokoro.hi.{alpha, omega, psi}`, `kokoro.pl.mateusz`, `kokoro.de.anna` |

packages/react-native-executorch/src/constants/modelRegistry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,6 @@ export const models = {
506506
yolo26m: base(M.YOLO26M),
507507
yolo26l: base(M.YOLO26L),
508508
yolo26x: base(M.YOLO26X),
509-
fastsam_s: variant(FASTSAM_S_VARIANTS),
510-
fastsam_x: variant(FASTSAM_X_VARIANTS),
511509
},
512510
pose_estimation: {
513511
yolo26n: base(M.YOLO26N_POSE),
@@ -540,6 +538,8 @@ export const models = {
540538
yolo26l: base(M.YOLO26L_SEG),
541539
yolo26x: base(M.YOLO26X_SEG),
542540
rf_detr_nano: variant(RF_DETR_NANO_SEG_VARIANTS),
541+
fastsam_s: variant(FASTSAM_S_VARIANTS),
542+
fastsam_x: variant(FASTSAM_X_VARIANTS),
543543
},
544544
style_transfer: {
545545
candy: variant(STYLE_TRANSFER_CANDY_VARIANTS),

0 commit comments

Comments
 (0)