# Image Semantic Filter (`bfarrington/image-semantic-filter`) Actor

Easily search a dataset of images with natural language queries. E.g. Searching a dataset of street view images for construction sites or social media images for products.

- **URL**: https://apify.com/bfarrington/image-semantic-filter.md
- **Developed by:** [Ben Farrington](https://apify.com/bfarrington) (community)
- **Categories:** AI, Agents, Social media
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 image classifieds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Image Semantic Filter — keep only the images that match your description

**Filter any set of images by meaning.** Give this actor a list of image URLs — or point it at another Actor's dataset — and a plain-English description. It scores every image on how well it matches, using CLIP AI vision, and returns only the ones you want, each with a match rating. No API key — you pay a small flat fee per image classified.

````

"a red sports car"        → keep car photos that are actually red sports cars
"person wearing a hat"    → filter a scraped photo set down to hatted people
"food on a plate"         → pull the food shots out of a mixed image dump
"logo on a white background" → find clean product images among the noise

````

### Why this actor?

- ✅ **No API key, no setup** — nothing to configure, no third-party billing account, no quota
- ✅ **Simple pay-per-event pricing** — a small flat fee per image classified, billed by Apify; no external per-image API charges, scoring runs on a local AI model
- ✅ **Chains off any scraper** — feed it the dataset from an Instagram, e-commerce, or Google Images Actor and curate the output in one step
- ✅ **Semantic, not keyword** — CLIP understands objects, colors, scenes and concepts ("something to sit on" finds chairs and benches)
- ✅ **Keeps your data** — every original field of a source-dataset item is carried through to the results, plus a `match` rating

### What can you use it for?

- 🛒 **Curate scraped product images** — keep only photos matching a style, angle, or setting
- 🧹 **Clean image dumps** — filter a mixed set down to the subject you care about
- 🖼️ **Moderate & sort** — bucket a large image set by how well it matches a description
- 🔎 **Find needles** — locate the few on-target images inside thousands of scraped URLs

### How it works

1. **You provide** a description plus images — a list of URLs, a source dataset ID, or both
2. **AI ranking** — a CLIP vision model scores every image against your description (semantic matching, not keywords)
3. **You receive** the matching images as dataset items, each with a `match` rating (`match`, `ambiguous`, or `no_match`). Set a minimum match level to drop the rest automatically

### Input

| Field | Default | Description |
|---|---|---|
| `searchPrompt` | — | What to look for, in plain English |
| `imageUrls` | `[]` | Direct image URLs to score |
| `datasetId` | — | Apify dataset (e.g. a scraper's output) to read image URLs from |
| `imageUrlField` | `imageUrl` | Field in each source item holding the URL (supports nested `image.url`) |
| `minMatch` | `any` | Keep only images at this level or better (`any` / `ambiguous` / `match`) |
| `maxImages` | 1000 | Maximum images to download and score |

Provide `imageUrls`, a `datasetId`, or both.

### Output

One dataset item per kept image, streamed in as it's scored. When the image came from a source dataset, the original item's fields are included alongside the match rating.

```json
{
    "imageUrl": "https://example.com/photos/car-42.jpg",
    "match": "match"
}
````

Export to JSON, CSV, or Excel. Sort or filter on the `match` field to get the strongest matches first.

### FAQ

**Where do the images come from?**
From you — either a list of URLs or another Apify Actor's dataset. This Actor doesn't scrape or store images; it reads the URLs you provide and returns the ones that match.

**What do the match ratings mean?**
`match` means a confident visual match; `ambiguous` is borderline and worth a look; `no_match` probably doesn't contain what you described. Use `minMatch` to drop everything below a level, or keep all and filter the dataset yourself.

**Can I filter another Actor's results?**
Yes — that's the main use. Run a scraper, then pass its dataset ID here with `imageUrlField` set to the field holding the image URL. Every original field is carried through, so the output is your scraped data minus the images that don't match.

**Does it re-host the images?**
No. The output references your original image URLs, so make sure they stay reachable. Images behind expiring/signed links may not load later.

**Can I search for multiple things?**
One description per run. Start parallel runs for multiple descriptions over the same images.

**How am I charged?**
Pay-per-event: one flat charge per image classified. Every image that gets scored counts, including ones filtered out by `minMatch` — you're paying for the AI classification, not just the kept results. Cap a run's cost with `maxImages`.

***

*semantic image search · CLIP visual filter · image dataset curation · filter scraped images by content · AI image classification by prompt*

# Actor input Schema

## `searchPrompt` (type: `string`):

Plain-language description of the images you want to keep, e.g. "a red sports car", "person wearing a hat", "food on a plate".

## `imageUrls` (type: `array`):

List of direct image URLs to score. Use this, a source dataset, or both.

## `datasetId` (type: `string`):

ID of an Apify dataset (e.g. the output of a scraper) to read image URLs from. Every original field of each item is carried through to the results.

## `imageUrlField` (type: `string`):

Name of the field in each source-dataset item that holds the image URL. Supports nested fields with dots, e.g. "image.url".

## `minMatch` (type: `string`):

Only keep images at this match level or better. "Keep all" returns every image with its match rating.

## `maxImages` (type: `integer`):

Maximum number of images to download and score. Keeps runs bounded on large inputs.

## Actor input object example

```json
{
  "searchPrompt": "a dog",
  "imageUrls": [],
  "imageUrlField": "imageUrl",
  "minMatch": "any",
  "maxImages": 1000
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `resultsCsv` (type: `string`):

No description

## `run` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "searchPrompt": "a dog",
    "imageUrls": []
};

// Run the Actor and wait for it to finish
const run = await client.actor("bfarrington/image-semantic-filter").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "searchPrompt": "a dog",
    "imageUrls": [],
}

# Run the Actor and wait for it to finish
run = client.actor("bfarrington/image-semantic-filter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchPrompt": "a dog",
  "imageUrls": []
}' |
apify call bfarrington/image-semantic-filter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=bfarrington/image-semantic-filter",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Image Semantic Filter",
        "description": "Easily search a dataset of images with natural language queries. E.g. Searching a dataset of street view images for construction sites or social media images for products.",
        "version": "0.1",
        "x-build-id": "DKqwJA7CiAZ0tScwC"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/bfarrington~image-semantic-filter/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-bfarrington-image-semantic-filter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/bfarrington~image-semantic-filter/runs": {
            "post": {
                "operationId": "runs-sync-bfarrington-image-semantic-filter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/bfarrington~image-semantic-filter/run-sync": {
            "post": {
                "operationId": "run-sync-bfarrington-image-semantic-filter",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "searchPrompt"
                ],
                "properties": {
                    "searchPrompt": {
                        "title": "What to look for",
                        "type": "string",
                        "description": "Plain-language description of the images you want to keep, e.g. \"a red sports car\", \"person wearing a hat\", \"food on a plate\"."
                    },
                    "imageUrls": {
                        "title": "Image URLs",
                        "type": "array",
                        "description": "List of direct image URLs to score. Use this, a source dataset, or both."
                    },
                    "datasetId": {
                        "title": "Source dataset ID",
                        "type": "string",
                        "description": "ID of an Apify dataset (e.g. the output of a scraper) to read image URLs from. Every original field of each item is carried through to the results."
                    },
                    "imageUrlField": {
                        "title": "Image URL field",
                        "type": "string",
                        "description": "Name of the field in each source-dataset item that holds the image URL. Supports nested fields with dots, e.g. \"image.url\".",
                        "default": "imageUrl"
                    },
                    "minMatch": {
                        "title": "Minimum match level",
                        "enum": [
                            "any",
                            "ambiguous",
                            "match"
                        ],
                        "type": "string",
                        "description": "Only keep images at this match level or better. \"Keep all\" returns every image with its match rating.",
                        "default": "any"
                    },
                    "maxImages": {
                        "title": "Max images",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of images to download and score. Keeps runs bounded on large inputs.",
                        "default": 1000
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
