Smart Segments - Quickly Select Objects or Promote to new layers using Segment Anything V2 @Meta

I built a Krita plugin called Smart Segments that lets you easily select objects using Meta’s Segment Anything Model (SAM v2). Just run the tool, and it automatically finds everything on the current layer. You can click or shift-click to choose one or more segments, and it converts them into a selection. No more struggling with the magic wand or cutting stuff out by hand. It supports GPU and CPU, works on Linux and (hopefully) Windows, and macOS, and sets everything up on first run without needing to install anything manually. You can grab it here: GitHub - a904guy/Smart_Segments: KRITA Plugin - Smart Segments - Segment Anything Model 2

Screenshots showing usage available on on the link above.

8 Likes

HI Thanks a lot for your work and plugin. I am facing below issue while trying to run tool → scripts → Smart Segments
error: Failed to create virtual environment

installed the virtual env manually and able to proceed. but finally getting this errir.can you please help.

2025-08-13 15:21:40,278 - smart_segments_plugin - INFO - Dependencies loaded successfully
2025-08-13 15:21:40,325 - smart_segments_plugin - INFO - Converting layer ‘Background’ to numpy array…
2025-08-13 15:21:40,426 - smart_segments_plugin - INFO - Layer converted successfully: shape=(8000, 8000, 3), dtype=uint8
2025-08-13 15:21:40,429 - smart_segments_plugin - INFO - Creating segmentation session with image shape: (8000, 8000, 3)
2025-08-13 15:21:40,429 - smart_segments_plugin - ERROR - entering load_model
2025-08-13 15:21:40,429 - smart_segments_plugin - INFO - Using cached model sam2_hiera_large
2025-08-13 15:21:40,430 - smart_segments_plugin - ERROR - Failed to initialize predictor: Error inferring type for interpolation: InterpolationMode.BILINEAR: Expected <function Enum.generate_next_value at 0x0000029688CCF0A0> to be a function
2025-08-13 15:21:40,441 - smart_segments_plugin - ERROR - Smart Segments failed: Failed to set image in inference engine

can you please help?

The author seems not to be around anymore, and I don’t know if you have more success asking on GitHub, because the reported error there seems also gone unnoticed.
Link to issue-tracker:

Michelist

3 Likes

oh.. thats sad.. let me try to figure out and will get back if i could figure this out.. thanks a lot @Michelist

1 Like

Sorry I don’t have notifications on for this site. Can you give me your source image so I can try to recreate?

hello, i try also

Installing via web is presenting error too, I tried with pip not worked too

i have this is error also , using zip

2025-09-13 22:30:51,585 - smart_segments_plugin - INFO - Smart Segments Extension initialized
2025-09-13 22:30:51,707 - smart_segments_plugin - INFO - Setting up Smart Segments extension…
2025-09-13 22:30:51,707 - smart_segments_plugin - INFO - Smart Segments extension setup complete
2025-09-13 22:30:52,812 - smart_segments_plugin - INFO - Plugin actions created
2025-09-13 22:33:23,954 - smart_segments_plugin - INFO - Starting minimal setup process…
2025-09-13 22:33:24,002 - smart_segments_plugin - INFO - Creating MinimalBootstrap with project_root: C:\Users\bboy_\AppData\Roaming\krita
2025-09-13 22:33:24,002 - smart_segments_plugin - INFO - MinimalBootstrap created: <smart_segments.minimal_bootstrap.MinimalBootstrap object at 0x00000160194F3040>
2025-09-13 22:33:24,002 - smart_segments_plugin - INFO - Bootstrap type: <class ‘smart_segments.minimal_bootstrap.MinimalBootstrap’>
2025-09-13 22:33:28,616 - smart_segments_plugin - INFO - System check results: {‘platform’: ‘Windows’, ‘python_version’: ‘3.10.7’, ‘architecture’: ‘AMD64’, ‘has_internet’: True, ‘disk_space_gb’: 9.076728820800781, ‘can_create_venv’: False, ‘has_cuda’: True}
2025-09-13 22:33:29,549 - smart_segments_plugin - ERROR - Setup failed: Failed to create virtual environment
2025-09-13 22:33:29,549 - smart_segments_plugin - ERROR - Traceback (most recent call last):
File “C:\Users\bboy_\AppData\Roaming\krita\pykrita\smart_segments\smart_segments.py”, line 759, in _run_minimal_setup
raise Exception(“Failed to create virtual environment”)
Exception: Failed to create virtual environment

2025-09-13 22:35:47,688 - smart_segments_plugin - INFO - Starting minimal setup process…
2025-09-13 22:35:47,726 - smart_segments_plugin - INFO - Creating MinimalBootstrap with project_root: C:\Users\bboy_\AppData\Roaming\krita
2025-09-13 22:35:47,726 - smart_segments_plugin - INFO - MinimalBootstrap created: <smart_segments.minimal_bootstrap.MinimalBootstrap object at 0x00000160347B1D20>
2025-09-13 22:35:47,727 - smart_segments_plugin - INFO - Bootstrap type: <class ‘smart_segments.minimal_bootstrap.MinimalBootstrap’>
2025-09-13 22:35:52,217 - smart_segments_plugin - INFO - System check results: {‘platform’: ‘Windows’, ‘python_version’: ‘3.10.7’, ‘architecture’: ‘AMD64’, ‘has_internet’: True, ‘disk_space_gb’: 9.069587707519531, ‘can_create_venv’: False, ‘has_cuda’: True}
2025-09-13 22:35:53,151 - smart_segments_plugin - ERROR - Setup failed: Failed to create virtual environment
2025-09-13 22:35:53,152 - smart_segments_plugin - ERROR - Traceback (most recent call last):
File “C:\Users\bboy_\AppData\Roaming\krita\pykrita\smart_segments\smart_segments.py”, line 759, in _run_minimal_setup
raise Exception(“Failed to create virtual environment”)
Exception: Failed to create virtual environment

2025-09-13 22:43:06,195 - smart_segments_plugin - INFO - Smart Segments Extension initialized
2025-09-13 22:43:06,393 - smart_segments_plugin - INFO - Setting up Smart Segments extension…
2025-09-13 22:43:06,393 - smart_segments_plugin - INFO - Smart Segments extension setup complete
2025-09-13 22:43:07,581 - smart_segments_plugin - INFO - Plugin actions created
2025-09-13 22:43:47,118 - smart_segments_plugin - INFO - Starting minimal setup process…
2025-09-13 22:43:47,165 - smart_segments_plugin - INFO - Creating MinimalBootstrap with project_root: C:\Users\bboy_\AppData\Roaming\krita
2025-09-13 22:43:47,165 - smart_segments_plugin - INFO - MinimalBootstrap created: <smart_segments.minimal_bootstrap.MinimalBootstrap object at 0x000001E0B31E5FC0>
2025-09-13 22:43:47,165 - smart_segments_plugin - INFO - Bootstrap type: <class ‘smart_segments.minimal_bootstrap.MinimalBootstrap’>
2025-09-13 22:43:48,272 - smart_segments_plugin - INFO - System check results: {‘platform’: ‘Windows’, ‘python_version’: ‘3.10.7’, ‘architecture’: ‘AMD64’, ‘has_internet’: True, ‘disk_space_gb’: 9.05007553100586, ‘can_create_venv’: False, ‘has_cuda’: True}
2025-09-13 22:43:49,204 - smart_segments_plugin - ERROR - Setup failed: Failed to create virtual environment
2025-09-13 22:43:49,204 - smart_segments_plugin - ERROR - Traceback (most recent call last):
File “C:\Users\bboy_\AppData\Roaming\krita\pykrita\smart_segments\smart_segments.py”, line 759, in _run_minimal_setup
raise Exception(“Failed to create virtual environment”)
Exception: Failed to create virtual environment

2025-09-13 22:47:05,875 - smart_segments_plugin - INFO - Starting minimal setup process…
2025-09-13 22:47:05,915 - smart_segments_plugin - INFO - Creating MinimalBootstrap with project_root: C:\Users\bboy_\AppData\Roaming\krita
2025-09-13 22:47:05,915 - smart_segments_plugin - INFO - MinimalBootstrap created: <smart_segments.minimal_bootstrap.MinimalBootstrap object at 0x000001E0B31E7FD0>
2025-09-13 22:47:05,915 - smart_segments_plugin - INFO - Bootstrap type: <class ‘smart_segments.minimal_bootstrap.MinimalBootstrap’>
2025-09-13 22:47:06,978 - smart_segments_plugin - INFO - System check results: {‘platform’: ‘Windows’, ‘python_version’: ‘3.10.7’, ‘architecture’: ‘AMD64’, ‘has_internet’: True, ‘disk_space_gb’: 9.033706665039062, ‘can_create_venv’: False, ‘has_cuda’: True}
2025-09-13 22:47:07,896 - smart_segments_plugin - ERROR - Setup failed: Failed to create virtual environment
2025-09-13 22:47:07,896 - smart_segments_plugin - ERROR - Traceback (most recent call last):
File “C:\Users\bboy_\AppData\Roaming\krita\pykrita\smart_segments\smart_segments.py”, line 759, in _run_minimal_setup
raise Exception(“Failed to create virtual environment”)
Exception: Failed to create virtual environment

2025-09-13 22:48:59,872 - smart_segments_plugin - INFO - Starting minimal setup process…
2025-09-13 22:48:59,912 - smart_segments_plugin - INFO - Creating MinimalBootstrap with project_root: C:\Users\bboy_\AppData\Roaming\krita
2025-09-13 22:48:59,913 - smart_segments_plugin - INFO - MinimalBootstrap created: <smart_segments.minimal_bootstrap.MinimalBootstrap object at 0x000001E0B31E57B0>
2025-09-13 22:48:59,913 - smart_segments_plugin - INFO - Bootstrap type: <class ‘smart_segments.minimal_bootstrap.MinimalBootstrap’>
2025-09-13 22:49:00,974 - smart_segments_plugin - INFO - System check results: {‘platform’: ‘Windows’, ‘python_version’: ‘3.10.7’, ‘architecture’: ‘AMD64’, ‘has_internet’: True, ‘disk_space_gb’: 9.032150268554688, ‘can_create_venv’: False, ‘has_cuda’: True}
2025-09-13 22:49:01,909 - smart_segments_plugin - ERROR - Setup failed: Failed to create virtual environment
2025-09-13 22:49:01,910 - smart_segments_plugin - ERROR - Traceback (most recent call last):
File “C:\Users\bboy_\AppData\Roaming\krita\pykrita\smart_segments\smart_segments.py”, line 759, in _run_minimal_setup
raise Exception(“Failed to create virtual environment”)
Exception: Failed to create virtual environment

2025-09-13 22:56:20,765 - smart_segments_plugin - INFO - Starting minimal setup process…
2025-09-13 22:56:20,814 - smart_segments_plugin - INFO - Creating MinimalBootstrap with project_root: C:\Users\bboy_\AppData\Roaming\krita
2025-09-13 22:56:20,814 - smart_segments_plugin - INFO - MinimalBootstrap created: <smart_segments.minimal_bootstrap.MinimalBootstrap object at 0x000001E0B31E58A0>
2025-09-13 22:56:20,814 - smart_segments_plugin - INFO - Bootstrap type: <class ‘smart_segments.minimal_bootstrap.MinimalBootstrap’>
2025-09-13 22:56:21,885 - smart_segments_plugin - INFO - System check results: {‘platform’: ‘Windows’, ‘python_version’: ‘3.10.7’, ‘architecture’: ‘AMD64’, ‘has_internet’: True, ‘disk_space_gb’: 9.021316528320312, ‘can_create_venv’: False, ‘has_cuda’: True}
2025-09-13 22:56:22,799 - smart_segments_plugin - ERROR - Setup failed: Failed to create virtual environment
2025-09-13 22:56:22,799 - smart_segments_plugin - ERROR - Traceback (most recent call last):
File “C:\Users\bboy_\AppData\Roaming\krita\pykrita\smart_segments\smart_segments.py”, line 759, in _run_minimal_setup
raise Exception(“Failed to create virtual environment”)
Exception: Failed to create virtual environment

It failed to create a separate python process (Venv), which is required because it’s a difference version of python than what comes with Krita.

‘disk_space_gb’: 9.033706665039062

Is that oly 9 gbs of free disk space??? It’s going to need around 15gb at least.

Do you have Windows/AV or something running protection? Some info on what’s potentially blocking that process might help if it turns out you have what you need and the script is failing for another reason. But I would not rule out clearing up space as a potential fix.

a904guy

Reckon this user has enough free space for ensurepip/venv? It seems like it’s not there when they’ve gone to attempt to start the venv.

And if it’s not that, I reckon you should check out ACLY’s work to see what he does.

You can use this project as reference:

-S

Yeah, it looks like on the windows side the python executable shipped doesn’t contain the venv module which should be builtin. Regarding disk space, the python modules will be a lot of disk space, multiple gigabytes worth of tools, the models themselves are less than a gigabyte. You’ll need about 5-6gb total with all the latest changes to SAM architecture.

1 Like

Everyone with windows related problems, I’ve got a issue open where I’m debugging the windows install and setup process here: Error · Issue #1 · a904guy/Smart_Segments · GitHub

I’ve got it working in windows, I’ll have a release built soon.

2 Likes

Grab the 1.0.1 fix for Windows here: Release 1.0.1 · a904guy/Smart_Segments · GitHub

I had to require that you download a copy of python since the python for windows appears to be embedded into the krita executable (I can’t work with that). So if you don’t have python 3.10 installed it will ask you to do it, and tell you how.

If you still have problems send me the log from:
C:\Users\{User}\AppData\Roaming\krita\pykrita\smart_segments\logs\smart_segments.log

1 Like

Yeah. It’s the same case for Linux too. I’ve got these kind of errors in the past when trying to run plugins for Krita in the past. I had to adapt the plugin with my own venv server, then the author made it automatically setup.

Glad you got it working! Thanks for doing this for the community.

-s

Having 5 to 6 gb as a requirement for a simple selection tool is to much. That needs optimization. It looks cool but I am not even gonna try knowing that.

Glad I built it for myself realistically!