Repository: MiscellaneousStuff/meta-sam-demo Branch: main Commit: 89c3c1b61b78 Files: 66 Total size: 782.0 KB Directory structure: gitextract_jaanbdff/ ├── .eslintignore ├── .eslintrc ├── .gitignore ├── README.md ├── package.json ├── public/ │ ├── assets/ │ │ └── manifest.json │ ├── index.html │ ├── interactive_module_quantized_592547_2023_03_19_sam6_long_uncertain.onnx │ ├── interactive_module_quantized_592547_2023_03_20_sam6_long_all_masks_extra_data_with_ious.onnx │ ├── manifest.json │ ├── ort-wasm-simd-threaded.wasm │ ├── ort-wasm-simd.wasm │ ├── ort-wasm-threaded.wasm │ ├── ort-wasm.wasm │ └── robots.txt ├── src/ │ ├── App.css │ ├── App.test.tsx │ ├── App.tsx │ ├── assets/ │ │ ├── manifest.json │ │ └── scss/ │ │ └── App.scss │ ├── components/ │ │ ├── Canvas.tsx │ │ ├── Content.tsx │ │ ├── ErrorPage.tsx │ │ ├── FAQ.tsx │ │ ├── FeatureSummary.tsx │ │ ├── FeedbackModal.tsx │ │ ├── Footer.tsx │ │ ├── Gallery.tsx │ │ ├── Hero.tsx │ │ ├── HomePage.tsx │ │ ├── ImagePicker.tsx │ │ ├── LegalText.tsx │ │ ├── LoadingModal.tsx │ │ ├── MobileOptionNavBar.tsx │ │ ├── MobileSegmentDrawer.tsx │ │ ├── Navbar.tsx │ │ ├── PointsModal.tsx │ │ ├── SegmentDrawer.tsx │ │ ├── SegmentOptions.tsx │ │ ├── Sparkle.tsx │ │ ├── Stage.tsx │ │ ├── SvgMask.tsx │ │ ├── ToolTip.tsx │ │ ├── Video.tsx │ │ ├── helpers/ │ │ │ ├── CanvasHelper.tsx │ │ │ ├── ImageHelper.tsx │ │ │ ├── Interface.tsx │ │ │ ├── colors.tsx │ │ │ ├── custom_tracer.tsx │ │ │ ├── getFile.tsx │ │ │ ├── mask_utils.tsx │ │ │ ├── metaTheme.tsx │ │ │ ├── modelAPI.tsx │ │ │ └── photos.tsx │ │ └── hooks/ │ │ ├── Animation.tsx │ │ ├── context.tsx │ │ └── createContext.tsx │ ├── index.css │ ├── index.tsx │ ├── interactive_module_quantized_592547_2023_03_19_sam6_long_uncertain.onnx │ ├── interactive_module_quantized_592547_2023_03_20_sam6_long_all_masks_extra_data_with_ious.onnx │ ├── react-app-env.d.ts │ ├── reportWebVitals.ts │ └── setupTests.ts ├── tsconfig.json └── webpack.config.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintignore ================================================ src/components/Canvas.tsx src/components/ImagePicker.tsx src/components/Stage.tsx *.tsx ================================================ FILE: .eslintrc ================================================ { "extends": [ "react-app", "eslint-config-react-app/base" ] } ================================================ FILE: .gitignore ================================================ # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* lerna-debug.log* # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage *.lcov # nyc test coverage .nyc_output # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ # TypeScript v1 declaration files typings/ # TypeScript cache *.tsbuildinfo # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Microbundle cache .rpt2_cache/ .rts2_cache_cjs/ .rts2_cache_es/ .rts2_cache_umd/ # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env .env.test # parcel-bundler cache (https://parceljs.org/) .cache # Next.js build output .next # Nuxt.js build / generate output .nuxt dist # Gatsby files .cache/ # Comment in the public line in if your project uses Gatsby and *not* Next.js # https://nextjs.org/blog/next-9-1#public-directory-support # public # vuepress build output .vuepress/dist # Serverless directories .serverless/ # FuseBox cache .fusebox/ # DynamoDB Local files .dynamodb/ # TernJS port file .tern-port # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies /node_modules /.pnp .pnp.js # testing /coverage # production /build # misc .DS_Store .env.local .env.development.local .env.test.local .env.production.local npm-debug.log* yarn-debug.log* yarn-error.log* ================================================ FILE: README.md ================================================ # Meta's Segment Anything Model (SAM) Demo Site ## About This repository is based on their demo website, [segment-anything.com](https://segment-anything.com). ## Usage To use this repository, clone it and install the required packages by doing: ```bash git clone https://github.com/MiscellaneousStuff/meta-sam-demo cd meta-sam-demo npm i ``` Then run it like a regular react app: ```bash npm run start ``` To actually use the site when it is deployed, navigate to: `http://localhost:3000/`. By default, the site re-directs to the demo page, however, all of the original pages are included and you can uncomment out whatever you want to run. # Getting Started with Create React App This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). ## Available Scripts In the project directory, you can run: ### `npm start` Runs the app in the development mode.\ Open [http://localhost:3000](http://localhost:3000) to view it in the browser. The page will reload if you make edits.\ You will also see any lint errors in the console. ### `npm test` Launches the test runner in the interactive watch mode.\ See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. ### `npm run build` Builds the app for production to the `build` folder.\ It correctly bundles React in production mode and optimizes the build for the best performance. The build is minified and the filenames include the hashes.\ Your app is ready to be deployed! See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. ### `npm run eject` **Note: this is a one-way operation. Once you `eject`, you can’t go back!** If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. ## Learn More You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). To learn React, check out the [React documentation](https://reactjs.org/). ================================================ FILE: package.json ================================================ { "name": "meta-sam-rip", "version": "0.1.0", "private": true, "dependencies": { "@remix-run/router": "^1.5.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", "@types/jest": "^27.5.2", "@types/node": "^16.18.23", "@types/react": "^18.0.33", "@types/react-dom": "^18.0.11", "attr-accept": "^2.2.2", "copy-webpack-plugin": "^11.0.0", "css-loader": "^6.7.3", "file-selector": "^0.6.0", "its-fine": "^1.1.0", "konva": "^8.4.3", "lz-string": "^1.5.0", "node-sass": "^8.0.0", "onnxruntime-common": "^1.14.0", "onnxruntime-web": "^1.14.0", "process": "^0.11.10", "react": "^18.2.0", "react-cookie": "^4.1.1", "react-cookie-consent": "^8.0.1", "react-daisyui": "^3.1.2", "react-dom": "^18.2.0", "react-dropzone": "^14.2.3", "react-ga4": "^2.1.0", "react-icons": "^4.8.0", "react-konva": "^18.2.5", "react-photo-album": "^2.0.3", "react-reconciler": "^0.29.0", "react-router-dom": "^6.10.0", "react-scripts": "5.0.1", "react-swipeable": "^7.0.0", "sass": "^1.61.0", "scheduler": "^0.23.0", "style-loader": "^3.3.2", "swipeable": "^1.0.5", "tslib": "^2.5.0", "typescript": "^4.9.5", "underscore": "^1.13.6", "web-vitals": "^2.1.4" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": [ "react-app", "react-app/jest" ] }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] }, "devDependencies": { "@types/underscore": "^1.11.4", "webpack-cli": "^5.0.1" } } ================================================ FILE: public/assets/manifest.json ================================================ { "icons": [ { "src": "M_Favicon_16x16.png", "type": "image/png", "sizes": "16x16" }, { "src": "M_Favicon_32x32.png", "type": "image/png", "sizes": "32x32" }, { "src": "M_Favicon_192x192.png", "type": "image/png", "sizes": "192x192" }, { "src": "M_Favicon_512x512.png", "type": "image/png", "sizes": "512x512" } ], "start_url": ".", "display": "standalone", "theme_color": "#000000", "background_color": "#ffffff" } ================================================ FILE: public/index.html ================================================ React App
================================================ FILE: public/manifest.json ================================================ { "short_name": "React App", "name": "Create React App Sample", "icons": [ { "src": "favicon.ico", "sizes": "64x64 32x32 24x24 16x16", "type": "image/x-icon" }, { "src": "logo192.png", "type": "image/png", "sizes": "192x192" }, { "src": "logo512.png", "type": "image/png", "sizes": "512x512" } ], "start_url": ".", "display": "standalone", "theme_color": "#000000", "background_color": "#ffffff" } ================================================ FILE: public/robots.txt ================================================ # https://www.robotstxt.org/robotstxt.html User-agent: * Disallow: ================================================ FILE: src/App.css ================================================ .App { text-align: center; } .App-logo { height: 40vmin; pointer-events: none; } @media (prefers-reduced-motion: no-preference) { .App-logo { animation: App-logo-spin infinite 20s linear; } } .App-header { background-color: #282c34; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: calc(10px + 2vmin); color: white; } .App-link { color: #61dafb; } @keyframes App-logo-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } ================================================ FILE: src/App.test.tsx ================================================ import React from 'react'; import { render, screen } from '@testing-library/react'; import App from './App'; test('renders learn react link', () => { render(); const linkElement = screen.getByText(/learn react/i); expect(linkElement).toBeInTheDocument(); }); ================================================ FILE: src/App.tsx ================================================ import LZString from "lz-string"; import { InferenceSession, Tensor } from "onnxruntime-web"; import * as ort from 'onnxruntime-web'; import React, { useContext, useEffect, useState } from "react"; import { Navigate, Route, Routes, useNavigate } from "react-router-dom"; import "./assets/scss/App.scss"; import Footer from "./components/Footer"; import getFile from "./components/helpers/getFile"; import { handleImageScale } from "./components/helpers/ImageHelper"; import { modelScaleProps } from "./components/helpers/Interface"; import { getAllMasks, getBestPredMask, keepArrayForMultiMask, rleFrString, rleToImage, traceCompressedRLeStringToSVG, traceOnnxMaskToSVG, } from "./components/helpers/mask_utils"; import { modelData, setParmsandQueryEraseModel, setParmsandQueryModel, } from "./components/helpers/modelAPI"; import photos from "./components/helpers/photos"; import HomePage from "./components/HomePage"; import AppContext from "./components/hooks/createContext"; import LegalText from "./components/LegalText"; import NavBar from "./components/Navbar"; import Stage from "./components/Stage"; // import CookieText from "./CookieText"; // console.log("hi") // Onnxruntime ort.env.debug = false; // set global logging level ort.env.logLevel = 'verbose'; // override path of wasm files - for each file ort.env.wasm.numThreads = 2; ort.env.wasm.simd = true; // ort.env.wasm.proxy = true; ort.env.wasm.wasmPaths = { 'ort-wasm.wasm': '/ort-wasm.wasm', 'ort-wasm-simd.wasm': '/ort-wasm-simd.wasm', 'ort-wasm-threaded.wasm': '/ort-wasm-threaded.wasm', 'ort-wasm-simd-threaded.wasm': '/ort-wasm-simd-threaded.wasm' }; // ort.env.webgl.pack = true; const App = () => { const { click: [click, setClick], clicks: [clicks, setClicks], image: [image, setImage], prevImage: [prevImage, setPrevImage], svg: [, setSVG], svgs: [svgs, setSVGs], allsvg: [, setAllsvg], isErased: [, setIsErased], isModelLoaded: [, setIsModelLoaded], isLoading: [, setIsLoading], segmentTypes: [, setSegmentTypes], maskImg: [, setMaskImg], isErasing: [isErasing, setIsErasing], stickerTabBool: [stickerTabBool, setStickerTabBool], isMultiMaskMode: [isMultiMaskMode, setIsMultiMaskMode], isHovering: [isHovering, setIsHovering], showLoadingModal: [showLoadingModal, setShowLoadingModal], eraserText: [eraserText, setEraserText], predMask: [predMask, setPredMask], predMasks: [predMasks, setPredMasks], predMasksHistory: [predMasksHistory, setPredMasksHistory], isToolBarUpload: [isToolBarUpload, setIsToolBarUpload], } = useContext(AppContext)!; const [model, setModel] = useState(null); const [multiMaskModel, setMultiMaskModel] = useState( null ); const [tensor, setTensor] = useState(null); const [hasClicked, setHasClicked] = useState(false); const [mask, setMask] = useState< | string[] | Uint8Array | Float32Array | Int8Array | Uint16Array | Int16Array | Int32Array | BigInt64Array | Float64Array | Uint32Array | BigUint64Array | null >(null); const [modelScale, setModelScale] = useState(null); // useEffect(() => { // // Preload images // for (const photo of photos) { // const img = new Image(); // img.src = photo.src; // } // }, []); // console.log("WHY IS THIS NOT RUNNING?") useEffect(() => { const initModel = async () => { try { // if (process.env.MODEL_DIR === undefined) return; const MODEL_DIR = "./interactive_module_quantized_592547_2023_03_19_sam6_long_uncertain.onnx"; const URL: string = MODEL_DIR; // const URL: string = process.env.MODEL_DIR; const model = await InferenceSession.create(URL); setModel(model); } catch (e) { // console.log("MODEL:", e); console.error(e); } try { // console.log("MULTI MASK MODEL"); // if (process.env.MULTI_MASK_MODEL_DIR === undefined) return; const MULTI_MASK_MODEL_DIR = "./interactive_module_quantized_592547_2023_03_20_sam6_long_all_masks_extra_data_with_ious.onnx"; const URL2: string = MULTI_MASK_MODEL_DIR; // console.log("MULTI MASK MODEL URL:", URL2); // const URL2: string = process.env.MULTI_MASK_MODEL_DIR; const multiMaskModel = await InferenceSession.create(URL2); // console.log("multiMaskModel:", multiMaskModel); setMultiMaskModel(multiMaskModel); } catch (e) { // console.log("MULTI MASK MODEL:", e); console.error(e); } }; initModel(); }, []); const runMultiMaskModel = async () => { try { if ( multiMaskModel === null || clicks === null || tensor === null || modelScale === null || !hasClicked // only run for clicks ) return; if (stickerTabBool) return; const feeds = modelData({ clicks, tensor, modelScale, last_pred_mask: null, // Only 1 click allowed, so no last predicted mask exists }); if (feeds === undefined) return; // console.log("Running multiMaskModel"); const results = await multiMaskModel.run(feeds); const output = results["output"]; const areas = results["areas"].data; const uncertain_ious = results["uncertain_ious"].data; const ious = results["ious"].data; const allMasks = getAllMasks( output.data, output.dims[2], // height output.dims[1] // width ); // There are 3 // allMasksSorted will be a list of 1-3 masks, sorted by area. // The best mask is selected for rendering on the collapsed canvas. // You can loop through allMasksSorted // and render each one onto a separate layer in the multi // mask animation let sorted_indices = sortAndReturnIndices( // @ts-ignore Array(Number(areas[1]), Number(areas[2]), Number(areas[3])) ); // Keep only masks indices 1, 2, 3 sorted_indices.reverse(); let allMasksSorted = sortByIndices( [allMasks[1], allMasks[2], allMasks[3]], sorted_indices ); // Keep only 3 let allUncertainIoUSorted = sortByIndices( [uncertain_ious[1], uncertain_ious[2], uncertain_ious[3]], sorted_indices ); let allOverlapIoUsSorted = sortByIndices( [ious[0], ious[1], ious[2]], // Only 3 of these, not 4 sorted_indices ); // Filter bad and duplicate masks const keepArray = keepArrayForMultiMask( allUncertainIoUSorted, allOverlapIoUsSorted ); allMasksSorted = allMasksSorted.filter( (obj: any, i: number) => keepArray[i] ); allUncertainIoUSorted = allUncertainIoUSorted.filter( (obj: any, i: number) => keepArray[i] ); // Trace remaining masks const svgStrs = allMasksSorted.map((mask) => traceOnnxMaskToSVG(mask, output.dims[2], output.dims[1]) ); // Reversing the masks here because the DOM stacks elements // from bottom to top. In other words, the first element in // the array will be on the bottom, and the last element will // be on the top. setSVGs(svgStrs.reverse()); // Set the single svg to the best mask by uncertain iou. // This is used for display when the masks are collapsed. allUncertainIoUSorted = allUncertainIoUSorted.reverse(); const bestIdx = allUncertainIoUSorted.indexOf( Math.max(...allUncertainIoUSorted) ); setSVG(svgStrs[bestIdx]); // !!!!Multiple clicks are not allowed!!! setClick(null); setIsLoading(false); setIsModelLoaded((prev) => { return { ...prev, boxModel: true }; }); // console.log("multiMaskModel is loaded"); } catch (e) { // console.log(e); } }; const sortAndReturnIndices = (arr: Array) => { const indices = Array.from(arr.keys()); indices.sort((a, b) => arr[b] - arr[a]); return indices; }; const sortByIndices = (items: any, indices: Array) => { const result = []; for (var i = 0; i < indices.length; i++) { result.push(items[indices[i]]); } return result; }; const runModel = async () => { // console.log("Running singleMaskModel"); try { if ( model === null || clicks === null || tensor === null || modelScale === null ) return; if (stickerTabBool) return; const feeds = modelData({ clicks, tensor, modelScale, last_pred_mask: predMask, }); if (feeds === undefined) return; // const beforeONNX = Date.now(); const results = await model.run(feeds); // const afterONNX = Date.now(); // console.log(`ONNX took ${afterONNX - beforeONNX}ms`); const output = results[model.outputNames[0]]; if (hasClicked) { // const beforeSVG = Date.now(); const pred_mask = results[model.outputNames[1]]; setPredMask(pred_mask); if (!predMasksHistory) { setPredMasks([...(predMasks || []), pred_mask]); } const svgStr = traceOnnxMaskToSVG( output.data, output.dims[1], output.dims[0] ); setSVG(svgStr); setMask(output.data); // const afterSVG = Date.now(); // console.log(`SVG took ${afterSVG - beforeSVG}ms`); } else { // const beforeMask = Date.now(); setMaskImg(rleToImage(output.data, output.dims[0], output.dims[1])); // const afterMask = Date.now(); // console.log(`Mask took ${afterMask - beforeMask}ms`); } setClick(null); setIsLoading(false); setIsModelLoaded((prev) => { return { ...prev, boxModel: true }; }); // console.log("boxModel is loaded"); } catch (e) { // console.log(e); } }; useEffect(() => { // TODO: By default use the runModel function // When the multi mask mode is enabled, run runMultiMaskModel const runOnnx = async () => { if (isMultiMaskMode) { if (hasClicked) { // Only enable multi mask case, when there are clicks. // We don't want the hover feature for this mode runMultiMaskModel(); } } else { runModel(); } }; runOnnx(); }, [clicks, hasClicked, isMultiMaskMode]); const handleMagicErase = () => { if (image !== null) { setIsErased(true); setIsErasing(true); // setIsLoading(true); setEraserText({ isErase: true, isEmbedding: false }); const { height, width, uploadScale } = handleImageScale(image); setParmsandQueryEraseModel({ width, height, uploadScale, imgData: image, mask: mask || new Float32Array(), handlePredictedImage: handlePredictedImage, }); } }; const handlePredictedImage = (imgStr: string) => { const img = new Image(); img.src = imgStr; img.onload = () => { setEraserText({ isErase: false, isEmbedding: true }); // Set to the original image width and height img.width = image?.width || 0; img.height = image?.height || 0; handleImage(img); }; }; const handleImage = (img: HTMLImageElement = prevImage!) => { // Reset the image, mask and clicks setImage(img); setMaskImg(null); setSVG(null); setMask(null); setClick(null); setClicks(null); setIsModelLoaded({ boxModel: false, allModel: false }); setHasClicked(false); const { height, width, uploadScale } = handleImageScale(img); setParmsandQueryModel({ width, height, uploadScale, imgData: img, handleSegModelResults, handleAllModelResults, imgName: "", shouldDownload: false, shouldNotFetchAllModel: false, }); }; const handleSelectedImage = async ( data: File | URL, options?: { shouldNotFetchAllModel?: boolean; shouldDownload?: boolean } ) => { if (data instanceof File) { console.log("GOT FILE " + data.name); } else if (data instanceof URL) { console.log("GOT URL " + data.pathname); } else { console.log("GOT STRING " + data); } try { const shouldNotFetchAllModel = options?.shouldNotFetchAllModel; const shouldDownload = options?.shouldDownload; handleResetState(); // setIsLoading(true); setShowLoadingModal(true); let imgName: string = ""; if (data instanceof URL) { imgName = data.pathname; } else if (data instanceof String) { // TODO: find the right place where to replace it... data = new URL(data.replace('/assets/', '/public/assets/')); imgName = data.pathname; } imgName = imgName.substring(imgName.lastIndexOf("/") + 1); const imgData: File = data instanceof File ? data : await getFile(data); const img = new Image(); img.src = URL.createObjectURL(imgData); img.onload = () => { setIsToolBarUpload(false); const { height, width, scale, uploadScale } = handleImageScale(img); setModelScale({ onnxScale: scale / uploadScale, maskWidth: width * uploadScale, maskHeight: height * uploadScale, scale: scale, uploadScale: uploadScale, width: width, height: height, }); img.width = Math.round(width * scale); img.height = Math.round(height * scale); setImage(img); setPrevImage(img); setIsErased(false); setParmsandQueryModel({ width, height, uploadScale, imgData: img, handleSegModelResults, handleAllModelResults, imgName, shouldDownload, shouldNotFetchAllModel, }); }; } catch (error) { console.log(error); } }; // useEffect(() => { // // redirect after handleSelectedImage runs // if (image) navigate("/playground"); // }, [image]); const handleSegModelResults = ({ tensor }: { tensor: Tensor }) => { // console.log("handleSegModelResults"); setTensor(tensor); setIsLoading(false); setIsErasing(false); setShowLoadingModal(false); setEraserText({ isErase: false, isEmbedding: false }); // window.scrollTo(0, 0); }; const handleAllModelResults = ({ allJSON, image_height, }: { allJSON: { encodedMask: string; bbox: number[]; score: number; point_coord: number[]; uncertain_iou: number; area: number; }[]; image_height: number; }) => { // console.log("handleAllModelResults"); const allMaskSVG = allJSON.map( (el: { encodedMask: string; bbox: number[]; score: number; point_coord: number[]; uncertain_iou: number; area: number; }) => { const maskenc = LZString.decompressFromEncodedURIComponent( el.encodedMask ); const svg = traceCompressedRLeStringToSVG(maskenc, image_height); return { svg: svg, point_coord: el.point_coord }; } ); setAllsvg(allMaskSVG); setIsModelLoaded((prev) => { return { ...prev, allModel: true }; }); }; const handleResetState = () => { setMaskImg(null); setHasClicked(false); setClick(null); setClicks(null); setSVG(null); setSVGs(null); setAllsvg(null); setTensor(null); setImage(null); setPrevImage(null); setPredMask(null); setIsErased(false); setShowLoadingModal(false); setIsModelLoaded({ boxModel: false, allModel: false }); setSegmentTypes("Click"); setIsLoading(false); setIsMultiMaskMode(false); setIsHovering(null); setPredMasks(null); }; return ( <> } /> {/*