Spiral gives your agent every tool with one account. Browse the tools →

Gemini CLI · Image

How to Use EVF-SAM2 in Gemini CLI

EVF-SAM2 turns an English description into a selection mask for an existing image. Use it to isolate a named object or select hair and background regions with semantic segmentation for later editing.

Prompts to try with EVF-SAM2 in Gemini CLI

Copy an example into Gemini CLI, or ask in your own words.

Use EVF-SAM2 on assets/product.jpg to select 'the shoe on the left.' Save the binary mask beside the original and create an overlay for review.

EVF-SAM2Gemini CLI
Try asking
  • Use EVF-SAM2 on assets/portrait.jpg with semantic segmentation to select 'hair.' Save the mask and add a preview so I can inspect the selection.

  • Use EVF-SAM2 on assets/room.jpg to select 'the chair beside the window.' Prepare the mask for a later recoloring step.

  • Use EVF-SAM2 on assets/table.jpg to select 'the plate' and exclude 'the fork.' Show the resulting selection over the original.

  • Use EVF-SAM2 on the project's sample landscape image with semantic segmentation to select 'sea.' Add the mask to our image-editing preview.

How to set up EVF-SAM2 in Gemini CLI

Pick the way that suits you. Each takes about two minutes.

Use Spiral's MCP server

  1. Add the server

    Or add it to ~/.gemini/settings.json yourself:

    gemini mcp add --scope user --transport http spiral https://api.spiral.ai/mcp
  2. Sign in

    Start gemini and run:

    /mcp auth spiral
  3. Check it

    In Gemini CLI, run /mcp. From your shell:

    gemini mcp list

Use the Spiral skill

  1. Send Gemini CLI this message

    Your agent reads Spiral's skill and sets itself up.

    set up https://spiral.ai/SKILL.md
  2. Sign in or paste a key

    Approve Spiral in the browser, or give the agent a key from the console.

Use the Spiral CLI

  1. Install and sign in

    Installs the Spiral CLI, signs you in and adds its skill to your coding agents.

    npx -y spiral-cli@latest init

Call the Spiral API

  1. Create an API key

    In the console, under API keys.

  2. Run EVF-SAM2

    One request; the result comes back by polling or a webhook.

    curl https://api.spiral.ai/v1/runs \
      -H "Authorization: Bearer $SPIRAL_API_KEY" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: $(uuidgen)" \
      -d '{
        "provider": "fal",
        "model": "fal-ai/evf-sam",
        "input": {
          "prompt": "Cat in the middle of the image",
          "image_url": "https://storage.googleapis.com/falserverless/web-examples/evf-sam2/evfsam2-cat.png"
        }
      }'

Then paste one of the prompts above: Gemini CLI finds EVF-SAM2 on Spiral, shows the price and runs it.

EVF-SAM2 providers and prices

Spiral runs EVF-SAM2 through fal. Open a card for today's price, with every fee included.

falImage
EVF-SAM2 Segmentation
fal-ai/evf-sam

Settings you can ask for

EVF-SAM2 works from your prompt and image URL. Ask Gemini CLI for any of these in your prompt.

SettingAllowed valuesDefaultDescription
Negative promptwhat to leave out, in words

Areas to exclude from segmentation (will be subtracted from prompt results)

Semantic typeon or offoff

Enable semantic level segmentation for body parts, background or multi objects

Mask onlyon or offon

Output only the binary mask instead of masked image

Use grounding dinoon or offoff

Use GroundingDINO instead of SAM for segmentation

Revert maskon or offoff

Invert the mask (background becomes foreground and vice versa)

Blur mask0 to 500

Apply Gaussian blur to the mask. Value determines kernel size (must be odd number)

Expand mask0 to 200

Expand/dilate the mask by specified pixels

Fill holeson or offoff

Fill holes in the mask using morphological operations

Every API field of EVF-SAM2 Segmentation is on its tool page: open its card above.

What can you do with EVF-SAM2 in Gemini CLI?

Turn image assets in your project into selections for editing and annotation. Use EVF-SAM2 to describe the target in English, then build a review step around the returned mask.

Product selections for recoloring

Use EVF-SAM2 to mask a specific shoe, bag, or chair in a product photo, then pass the selection to an editing tool.

Background replacement preparation

Use EVF-SAM2 with semantic segmentation to select a photo's background before replacing it in a separate editing step.

Hair color previews

Use EVF-SAM2 with semantic segmentation to select hair for a color preview. Inspect the selection before applying the edit.

One object in a crowded photo

Use EVF-SAM2 to select a target by its location or relationship to another object, such as the cup beside a plate.

Draft annotation masks

Use EVF-SAM2 to propose object masks from English descriptions, then have an annotator review them before adding them to a dataset.

Landscape editing selections

Use EVF-SAM2 with semantic segmentation to select a region such as the sea for a later color adjustment.

Questions about EVF-SAM2 in Gemini CLI

Can Gemini CLI use EVF-SAM2?

Yes. Add Spiral to Gemini CLI as an MCP server, and Gemini CLI can find and run EVF-SAM2 like any built-in tool.

How much does EVF-SAM2 cost in Gemini CLI?

$0.0065 per run at the default inputs. You pay from your Spiral balance as you go, with no subscription, and a failed run is not charged. Your Gemini CLI plan is separate.

Do I need a fal account to use EVF-SAM2 in Gemini CLI?

No. Spiral runs EVF-SAM2 on its own fal account. You sign in to Spiral once and never paste a key.

How long does it take to set up EVF-SAM2 in Gemini CLI?

About two minutes: add the server, then sign in, then check it.

Does Gemini CLI wait while EVF-SAM2 runs?

EVF-SAM2 runs in the background. Gemini CLI starts the run, checks on it and gives you the image when it's ready.

What is EVF-SAM2 useful for?

Use EVF-SAM2 to select a region in an existing image by describing it. The resulting mask can serve as the selection for a later edit, such as changing a product's color or replacing a background.

How do I select one object when several look alike?

Name the object and add a visible detail or location, such as 'the red cup beside the plate.' EVF-SAM supports spatial descriptions, so a relationship to another object can help distinguish your target.

Which language should I use for EVF-SAM2 prompts?

Use English. The official demo specifies English-only support, so translate other languages before submitting the target description.

Can EVF-SAM2 select hair or a background region?

Yes. Use semantic segmentation for body parts, background regions, or multiple objects, then describe the region you want.

How do I exclude something from a selection?

Describe the region to keep in the positive description and the unwanted region in the negative description. EVF-SAM2 subtracts the negative selection from the positive result.

Get started

Start using EVF-SAM2 in Gemini CLI

One Spiral account for every tool your agent needs. No subscription; you pay per run.

Paste this into Gemini CLI:

Set up Gemini CLI

set up https://spiral.ai/SKILL.md
Are you an AI agent? See setup options