### Setup and Run Python Example Source: https://docs.eyepop.ai/developer-documentation/deployment/eyepop-on-premise-ai-runtime Provides the shell commands to set up a Python virtual environment, install the EyePop SDK, and run the local inference demo script with an image URL. ```shell python3 -m venv .venv && \ . .venv/bin/activate && \ pip install eyepop && \ python demo.py "https://example.com/image.jpg" ``` -------------------------------- ### Installation Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk Instructions for installing the EyePop.ai SDK for React/Node.js and for use in the browser. ```APIDOC ## Installation ### React/Node ```shell npm install --save @eyepop.ai/eyepop ``` ### Browser ```html ``` ``` -------------------------------- ### Getting Started: Visual Intelligence Pop Template (JavaScript) Source: https://docs.eyepop.ai/developer-documentation/eyepop.ai-visual-intelligence/visual-intelligence This JavaScript template provides a starting point for building a Visual Intelligence Pop. It outlines the structure for defining components, including inference abilities like object detection and image content analysis, and demonstrates how to configure prompts with null safety. ```javascript const MyVisualIntelligence = { components: [{ type: PopComponentType.INFERENCE, ability: "eyepop.[YOUR_DETECTOR]:latest", // Choose your detector confidenceThreshold: 0.8, // Adjust as needed forward: { operator: { type: ForwardOperatorType.CROP, }, targets: [{ type: PopComponentType.INFERENCE, ability: 'eyepop.image-contents:latest', params: { prompts: [{ prompt: "[YOUR QUESTION HERE]. If you are unable to provide an answer, set classLabel to null" }] } }] } }] }; ``` -------------------------------- ### Install EyePop.ai Node SDK Source: https://docs.eyepop.ai/developer-documentation/self-service-training/dataset-sdk-node Installs the EyePop.ai Node SDK using npm. This is the first step to using the SDK in your Node.js project. ```bash npm install --save @eyepop.ai/eyepop ``` -------------------------------- ### Validate Docker Installation Source: https://docs.eyepop.ai/developer-documentation/deployment/eyepop-on-premise-ai-runtime Verifies that Docker is installed and running correctly on the system. It executes the 'hello-world' container to confirm basic Docker functionality. ```shell docker --version docker run --rm hello-world ``` -------------------------------- ### Install EyePop SDK and Dependencies Source: https://docs.eyepop.ai/developer-documentation/sdks/python-sdk/composable-pops Installs the necessary Python packages for the EyePop SDK, including requests, pillow, webui, and pybars3. Ensure you have an EyePop developer key before proceeding. ```bash pip install eyepop-sdk requests pillow webui pybars3 ``` -------------------------------- ### Install EyePop Python SDK Source: https://docs.eyepop.ai/developer-documentation/sdks/python-sdk Installs the EyePop Python SDK using pip. This is the first step to using the SDK in your Python projects. ```bash pip install eyepop ``` -------------------------------- ### Eyepop AI Common Usage Patterns Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/composable-pops Demonstrates common configurations for Eyepop AI inference components, including person detection, visual intelligence with prompt engineering, and custom object labeling. These examples showcase the basic structure for defining inference tasks. ```javascript { type: PopComponentType.INFERENCE, ability: "eyepop.person:latest", // Detect people confidenceThreshold: 0.8 } { type: PopComponentType.INFERENCE, ability: "eyepop.image-contents:latest", // Visual intelligence params: { prompts: [{ prompt: "What is this person wearing?" }] } } { type: PopComponentType.INFERENCE, ability: "eyepop.localize-objects:latest", // Custom object labels params: { prompts: [ {prompt: 'dog', label: 'Best Friend'} ] } } ``` -------------------------------- ### Install Python Dependencies for EyePop SDK Source: https://docs.eyepop.ai/developer-documentation/deployment/windows-application-runtime Commands to set up a Python virtual environment and install the EyePop SDK. This ensures that the necessary libraries are available for the Python script. ```powershell python -m venv .venv source .venv/bin/activate pip install eyepop ``` -------------------------------- ### Start Model Training Source: https://docs.eyepop.ai/developer-documentation/self-service-training/dataset-sdk-node Initiates the training process for a new model. You provide the dataset details, model configuration, and optionally a pre-trained model UUID for iterative training. ```APIDOC ## POST /models ### Description Starts the training process for a new model using a specified dataset. ### Method POST ### Endpoint `/models` ### Parameters #### Query Parameters - **apiKey** (string) - Required - Your EyePop.ai API key for authentication. #### Request Body - **datasetUUID** (string) - Required - The UUID of the dataset to use for training. - **datasetVersion** (string) - Required - The version of the dataset. - **modelData** (object) - Required - Configuration for the model training. - **name** (string) - Required - The name of the model. - **description** (string) - Optional - A description for the model. - **task** (string) - Required - The type of task, e.g., `"object_detection"` or `"image_classification"`. - **pretrained_model_uuid** (string) - Optional - UUID of a pre-trained model to start from. - **extra_params** (object) - Optional - Additional parameters for training, including augmentation intents. - **trainer** (object) - **preprocessor** (object) - **augment_intent** (object) - Configuration for data augmentation. ### Request Example ```json { "datasetUUID": "dataset-uuid-12345", "datasetVersion": "1.0.0", "modelData": { "name": "Accessory Model", "description": "This is my new model", "task": "object_detection", "pretrained_model_uuid": "pretrained-model-uuid-xyz", "extra_params": { "trainer": { "preprocessor": { "augment_intent": { "noise_level": "small", "upside_down_ok": true, "color_important": true, "exists_outdoors": false, "weather_allowed": false, "rotation_allowed": "medium", "occlusion_allowed": false, "camera_motion_important": false } } } } } } ``` ### Response #### Success Response (200) - **uuid** (string) - The UUID of the newly created and training model. #### Response Example ```json { "uuid": "model-uuid-7890" } ``` ``` -------------------------------- ### Start Model Training (Node.js) Source: https://docs.eyepop.ai/developer-documentation/self-service-training/dataset-sdk-node Initiates model training based on the prepared dataset. The task type is inferred from dataset tags. Optionally, a pretrained model can be specified. ```javascript const modelData = { name: "Accessory Model", description: "This is my new model", task: 'object_detection', // or 'image_classification' pretrained_model_uuid: pretrainedModelUUID, // optional model to start training from - useful for iterative training extra_params: { trainer: { preprocessor: { augment_intent: { } // your selected augmentations } } } }; const model = await client.createModel(datasetUUID, datasetVersion, modelData, true); console.log(model.uuid); // New model UUID ``` -------------------------------- ### Start EyePop CPU AI Runtime Source: https://docs.eyepop.ai/developer-documentation/deployment/eyepop-on-premise-ai-runtime Creates and starts a Docker container for the EyePop AI Runtime (CPU version). It maps the runtime's API port to the host, mounts a provisioning file, and streams logs. ```shell docker create \ --name eyepop-runtime-1 \ --restart unless-stopped \ --publish 127.0.0.1:8080:8080 \ --volume $HOME/eyepop-instance.yml:/etc/eyepop-instance.yml \ registry.eyepop.ai/ai/runtime-cpu:latest && \ docker start eyepop-runtime-1 && \ docker logs -f eyepop-runtime-1 ``` -------------------------------- ### Confirm GPU Setup with CUDA Source: https://docs.eyepop.ai/developer-documentation/deployment/eyepop-on-premise-ai-runtime Verifies that the NVIDIA Container Toolkit is correctly configured and that the system can access the GPUs. This command should be run within a Docker environment that has GPU access enabled. ```shell docker run --rm --gpus all nvidia/cuda:12.9.1-cudnn-runtime-ubuntu24.04 nvidia-smi ``` -------------------------------- ### SDK Initialization Source: https://docs.eyepop.ai/developer-documentation/sdks/javascript-sdk Initializes the EyePop SDK with provided configuration. This function starts media streaming, uploading, and enables drawing on a canvas. ```APIDOC ## POST /init ### Description Initializes the EyePop SDK with a configuration object. This function is essential for starting media processing and visualization. ### Method POST ### Endpoint /init ### Parameters #### Request Body - **config** (object) - Required - The configuration object for the SDK. - **config.input** (object) - Optional - Specifies the media input type and source. - **config.input.name** (string) - Required - The name of the input media. Options: "webcam_on_page", "screen", "webcam_off_site", "url", "file_upload". - **config.input.url** (string) - Required if name is "url" - The URL of the input media. - **config.draw** (array) - Optional - An array of drawing configurations to enable visualizations. - **config.draw[i]** (object) - Represents a single drawing pass. - **config.draw[i].type** (string) - Required - The type of drawing. Options: "box", "pose", "hand", "face", "posefollow", "clip", "custom". - **config.draw[i].targets** (array) - Optional - An array of strings specifying what to draw on. Options: "*", "people", specific object labels. - **config.draw[i].anchors** (array) - Optional - An array of strings specifying anchor points for drawing (e.g., "right eye"). - **config.draw[i].image** (string) - Optional - A path to an image to be used for drawing. - **config.draw[i].scale** (number) - Optional - A number to scale the anchored image by. ### Request Example ```java var config = {}; EyePopSDK.EyePopAPI.FetchPopConfig(pop_endpoint, token) .then((response) => { config = response; // First we set our input type config.input = { "name": "url", // "webcam_on_page", "screen", "webcam_off_site", "url", "file_upload" "url": url }; // Then we enable the following visualization config.draw = [ { "type": "box", "targets": [ "*" ] }, { "type": "pose", "targets": [ "*" ] }, { "type": "hand", "targets": [ "*" ] }, { "type": "face", "targets": [ "*" ] }, ] EyePopSDK.EyePopSDK.init(config); } ); ``` ### Response #### Success Response (200) - **status** (string) - Indicates the initialization status. #### Response Example ```json { "status": "initialized" } ``` ``` -------------------------------- ### Install EyePop Render 2D for Node.js Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/render-2d-visualization Installs the EyePop.ai and EyePop.ai-render-2d packages for Node.js applications using npm. ```shell npm install --save @eyepop.ai/eyepop @eyepop.ai/eyepop-render-2d ``` -------------------------------- ### Install JavaScript SDK via npm Source: https://docs.eyepop.ai/developer-documentation/sdks/javascript-sdk Install the EyePop.ai JavaScript SDK into your project using npm. This is the recommended method for Node.js environments and modern web development workflows. ```bash npm install @eyepop.ai/javascript-sdk ``` -------------------------------- ### Start EyePop GPU AI Runtime Source: https://docs.eyepop.ai/developer-documentation/deployment/eyepop-on-premise-ai-runtime Creates and starts a Docker container for the EyePop AI Runtime with GPU acceleration enabled. It maps the API port, mounts the provisioning file, and explicitly enables all available GPUs. ```shell docker create \ --name eyepop-runtime-1 \ --restart unless-stopped \ --publish 127.0.0.1:8080:8080 \ --gpus=all \ --volume $HOME/eyepop-instance.yml:/etc/eyepop-instance.yml \ registry.eyepop.ai/ai/runtime-cuda-12.9-nvidia-580-server:latest ``` -------------------------------- ### Initialize EyePop SDK with Configuration Source: https://docs.eyepop.ai/developer-documentation/sdks/javascript-sdk Initializes the EyePop SDK with a given configuration object. The configuration includes setting the media input source and defining drawing parameters for visualizations. This function starts media streaming, uploading, and drawing on a canvas. ```javascript var config = {}; EyePopSDK.EyePopAPI.FetchPopConfig(pop_endpoint, token) .then((response) => { config = response; // First we set our input type config.input = { "name": "url", // "webcam_on_page", "screen", "webcam_off_site", "url", "file_upload" "url": url }; // Then we enable the following visualization config.draw = [ { "type": "box", "targets": [ "*" ] }, { "type": "pose", "targets": [ "*" ] }, { "type": "hand", "targets": [ "*" ] }, { "type": "face", "targets": [ "*" ] }, ] EyePopSDK.EyePopSDK.init(config); } ); ``` -------------------------------- ### Basic SDK Usage for Image Upload and Display Source: https://docs.eyepop.ai/developer-documentation/sdks/javascript-sdk A fundamental example demonstrating how to use the EyePopSDK in HTML and JavaScript. It includes file upload, video display elements, and canvas for rendering, along with SDK initialization. ```html
``` -------------------------------- ### Install EyePop Browser SDK (CDN) Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk Includes the EyePop.ai SDK in an HTML file via a CDN link. This is suitable for client-side browser applications. ```html ``` -------------------------------- ### Eyepop AI: Running a Pop Pipeline Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/composable-pops Demonstrates how to connect to an Eyepop worker endpoint, change the active Pop configuration, process an image, and render the results. This covers the runtime execution of a configured pipeline. ```javascript const endpoint = await EyePop.workerEndpoint({ popId: TransientPopId.Transient, logger }).connect() await endpoint.changePop(OBJECT_SEGMENTATION) const results = await endpoint.process({ path: 'image.jpg' }) for await (const result of results) { Render2d.renderer(ctx, [Render2d.renderPose(), Render2d.renderText(), Render2d.renderContour()]) .draw(result) } ``` -------------------------------- ### Custom Render Interface Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/render-2d-visualization Defines the interface for custom rendering implementations in Eyepop AI. Requires implementing `start` and `draw` methods. ```typescript export interface Render { start(context: CanvasRenderingContext2D, style: Style): void draw(element: any, xOffset: number, yOffset: number, xScale: number, yScale: number, streamTime: StreamTime): void } export interface RenderRule { readonly render: Render readonly target : string } ``` -------------------------------- ### Render 2D Predictions in Browser Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/render-2d-visualization Illustrates rendering 2D predictions from EyePop.ai within a web browser. This example utilizes HTML file input and canvas elements, requiring the EyePop SDK and the render-2d library to be included. ```html ``` -------------------------------- ### Run a Composable Pop with EyePop SDK (Python) Source: https://docs.eyepop.ai/developer-documentation/sdks/python-sdk/composable-pops Demonstrates how to run a Composable Pop using the EyePop SDK. It initializes a worker endpoint, sets a predefined Pop (e.g., '2d-body-points'), uploads an image, and then iterates through the prediction results, printing them in JSON format. ```python from eyepop import EyePopSdk import json with EyePopSdk.workerEndpoint() as endpoint: endpoint.set_pop(pop_examples["2d-body-points"]) # choose a pop job = endpoint.upload("my-image.jpg") # or use endpoint.load_from(url) for result in job.predict(): print(json.dumps(result, indent=2)) ``` -------------------------------- ### Understanding Eyepop AI Response Format (JavaScript) Source: https://docs.eyepop.ai/developer-documentation/eyepop.ai-visual-intelligence/visual-intelligence Demonstrates the structured JSON response format from Eyepop AI's Visual Intelligence, including examples for successful analysis and cases of uncertainty. The response includes category, classLabel, confidence, and a unique ID. ```javascript { "category": "Age and Fashion Style", // Your prompt/question "classLabel": "20s, Casual", // The AI's answer "confidence": 0.85, // Confidence score "id": "unique-id" // Result identifier } { "category": "Age and Fashion Style", "classLabel": null, // Indicates uncertainty "confidence": 0.12, // Low confidence "id": "unique-id" } ``` -------------------------------- ### Security & Safety: Detect Safety Compliance (JavaScript) Source: https://docs.eyepop.ai/developer-documentation/eyepop.ai-visual-intelligence/visual-intelligence This JavaScript example focuses on detecting safety compliance by analyzing whether individuals are wearing required safety equipment. The prompt specifies checks for hard hats, safety vests, and safety glasses, with a requirement to set classLabel to null if an item is not clearly visible. ```javascript const securityCompliancePrompt = { prompt: "Is this person wearing required safety equipment: Hard hat (yes/no), Safety vest (yes/no), Safety glasses (yes/no). For each item, if you cannot clearly see it, set classLabel to null" }; ``` -------------------------------- ### Visual Intelligence Architecture Pattern (JavaScript) Source: https://docs.eyepop.ai/developer-documentation/eyepop.ai-visual-intelligence/visual-intelligence Demonstrates the core 'Detect → Crop → Analyze' architecture pattern for Visual Intelligence. It shows how to chain components, starting with object detection, cropping the detected regions, and then analyzing these crops with natural language prompts using the 'eyepop.image-contents:latest' ability. ```javascript { components: [{ // 1. DETECT: Find objects in the image type: PopComponentType.INFERENCE, ability: "eyepop.person:latest", // 2. CROP: Extract detected regions forward: { operator: { type: ForwardOperatorType.CROP, }, // 3. ANALYZE: Send crops to Visual Intelligence targets: [{ type: PopComponentType.INFERENCE, ability: 'eyepop.image-contents:latest', params: { prompts: [{ prompt: "What is the person's age range and fashion style?" }] } }] } }] } ``` -------------------------------- ### General Structure for Building Custom Pops (Python) Source: https://docs.eyepop.ai/developer-documentation/sdks/python-sdk/composable-pops Illustrates the general structure for defining custom Composable Pops using the EyePop SDK. It highlights the use of InferenceComponent with model and categoryName, and the flexible forward parameter which can be CropForward or FullForward, along with options like ContourFinderComponent and ComponentParams. ```python InferenceComponent( model='your-model:latest', categoryName='your-label', forward=CropForward( boxPadding=0.25, targets=[...] ) ) # Use: # • CropForward for passing regions # • FullForward to process the whole image # • ContourFinderComponent for polygon detection # • ComponentParams to pass prompts or ROI ``` -------------------------------- ### Initialize EyePop.ai Client (Node.js) Source: https://docs.eyepop.ai/developer-documentation/self-service-training/dataset-sdk-node Initializes the EyePop.ai client with your API key. This client instance is used to interact with the EyePop.ai API for various operations. ```javascript import { EyePopClient } from '@eyepop.ai/eyepop'; const client = new EyePopClient({ apiKey: 'YOUR_API_KEY' }); ``` -------------------------------- ### Run EyePop AI Inference Locally (Python) Source: https://docs.eyepop.ai/developer-documentation/deployment/eyepop-on-premise-ai-runtime Demonstrates how to use the EyePop Python SDK to load a model and perform inference on a given image URL. It requires the 'eyepop' package and a local runtime instance. ```python import asyncio, sys, json from eyepop import EyePopSdk, Job from eyepop.worker.worker_types import Pop, InferenceComponent async def on_ready(job: Job, url: str): while result := await job.predict(): print(url, json.dumps(result, indent=2)) async def main(pop: Pop, url: str): async with EyePopSdk.workerEndpoint(is_local_mode=True, is_async=True) as endpoint: await endpoint.set_pop(pop) job = await endpoint.load_from(url) await on_ready(job, url) asyncio.run(main( Pop(components=[InferenceComponent(model='eyepop.common-objects:latest')]), sys.argv[1] )) ``` -------------------------------- ### Eyepop AI: Object Tracking Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/composable-pops Sets up a pipeline to detect objects and then track their movements across video frames. This utilizes the TRACING component for continuous object monitoring. ```javascript const OBJECT_TRACKING = { components: [{ type: PopComponentType.INFERENCE, inferenceTypes: [InferenceType.OBJECT_DETECTION], modelUuid: 'yolov7:...', forward: { operator: { type: ForwardOperatorType.CROP }, targets: [{ type: PopComponentType.TRACING }] } }] } ``` -------------------------------- ### Define a Pop for Person Detection (Python) Source: https://docs.eyepop.ai/developer-documentation/sdks/python-sdk/composable-pops Creates a Composable Pop that uses the 'eyepop.person:latest' model to detect people. The detected objects are categorized under 'person'. ```python Pop(components=[ InferenceComponent( model='eyepop.person:latest', categoryName="person" ) ]) ``` -------------------------------- ### Configuration and Authentication Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk Details on how to configure the EyePop SDK with Pop ID and authentication credentials, including API Key, Session, and Current Browser Session. ```APIDOC ## Configuration The EyePop SDK needs to be configured with the **Pop Id** and your **Authentication Credentials**. ### Authentication Methods 1. **Api Key**: Server-side only. 2. **Session generated from Api Key**: Server-side generated session. 3. **Current Browser Session**: For developers running client code in the same browser session logged into their EyePop Dashboard. ### Configuration via Environment (Server Side) We recommend using dotenv to add `EYEPOP_SECRET_KEY="My API Key"` to your `.env` file. Environment variables used by default: * `EYEPOP_POP_ID`: The Pop Id to use as an endpoint. * `EYEPOP_SECRET_KEY`: Your Secret Api Key. * `EYEPOP_URL`: (Optional) URL of the EyePop API service. ### Authentication with Api Key **Configuration and authorization with explicit defaults:** ```typescript import { EyePop } from '@eyepop.ai/eyepop' (async() => { const endpoint = EyePop.workerEndpoint({ popId: process.env['EYEPOP_POP_ID'], auth : {secretKey: process.env['EYEPOP_SECRET_KEY']}, }) await endpoint.connect() // do work .... await endpoint.disconnect() }) ``` **Equivalent, but shorter:** ```typescript import { EyePop } from '@eyepop.ai/eyepop' (async() => { const endpoint = await EyePop.workerEndpoint().connect() // do work .... await endpoint.disconnect() }) ``` ### Authentication with Session generated from Api Key **Server Side:** ```javascript import { EyePop } from '@eyepop.ai/eyepop' const getSession = async function (req, res) { const endpoint = await EyePop.workerEndpoint().connect(); res.setHeader("Content-Type", "application/json"); res.writeHead(200); res.end(JSON.stringify(await endpoint.session())); }; const server = http.createServer(getSession); server.listen(8080, '127.0.0.1'); ``` **Client Side:** ```javascript import { EyePop } from '@eyepop.ai/eyepop' (async() => { const session = await (await fetch("http://127.0.0.1:8080")).json(); const endpoint = await EyePop.workerEndpoint({ auth: { session: session } }).connect(); // do work .... await endpoint.disconnect(); })(); ``` ### Authentication with Current Browser Session ```html ``` ``` -------------------------------- ### Uninstall EyePop Runtime (Shell) Source: https://docs.eyepop.ai/developer-documentation/deployment/eyepop-on-premise-ai-runtime This snippet demonstrates how to stop and remove the EyePop runtime container using Docker commands. It requires Docker to be installed and the runtime container to be running. ```shell docker stop eyepop-runtime-1 && docker rm eyepop-runtime-1 ``` -------------------------------- ### Blur Object (Blackout) Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/render-2d-visualization Applies a blackout effect to a specified object, intended for blurring. The `target` parameter uses a JSONPath expression to select the object, for example, faces. ```typescript Render2d.renderBlur(target = '$..objects[?(@.classLabel=="face")]') ``` -------------------------------- ### Eyepop AI: Text on Detected Objects Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/composable-pops Configures a pipeline to detect objects and then extract text within those detected objects using OCR. This involves chaining object detection with a text recognition model. ```javascript const TEXT_ON_OBJECTS = { components: [{ type: PopComponentType.INFERENCE, inferenceTypes: [InferenceType.OBJECT_DETECTION], modelUuid: 'yolov7:...', // your object detector forward: { operator: { type: ForwardOperatorType.CROP }, targets: [{ type: PopComponentType.INFERENCE, inferenceTypes: [InferenceType.OBJECT_DETECTION], modelUuid: 'eyepop-text:...', forward: { operator: { type: ForwardOperatorType.CROP }, targets: [{ type: PopComponentType.INFERENCE, inferenceTypes: [InferenceType.OCR], modelUuid: 'PARSeq:...' }] } }] } }] } ``` -------------------------------- ### Eyepop AI: Reusable Tracking Pop Function Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/composable-pops Provides a factory function to create reusable object tracking Pop configurations. This function allows dynamic creation of tracking Pops by specifying the model UUID. ```javascript function makeTrackingPop(modelUuid: string) { return { components: [{ type: PopComponentType.INFERENCE, inferenceTypes: [InferenceType.OBJECT_DETECTION], modelUuid, forward: { operator: { type: ForwardOperatorType.CROP }, targets: [{ type: PopComponentType.TRACING }] } }] } } ``` -------------------------------- ### Asynchronous Image Upload and Processing with Callbacks Source: https://docs.eyepop.ai/developer-documentation/sdks/python-sdk Handles large batches of images by uploading and processing them asynchronously. Uses a callback function `on_ready` to process results as they become available, preventing memory and performance issues associated with synchronous processing of large datasets. Requires the `asyncio` and `eyepop` libraries. ```python import asyncio from eyepop import EyePopSdk from eyepop import Job async def async_upload_photos(file_paths: list[str]): async def on_ready(job: Job): print(await job.predict()) async with EyePopSdk.workerEndpoint(is_async=True) as endpoint: for file_path in file_paths: await endpoint.upload(file_path, on_ready) asyncio.run(async_upload_photos(['examples/example.jpg'] * 100000000)) ``` -------------------------------- ### Eyepop AI: Segmentation and Contour Extraction Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/composable-pops Sets up a pipeline for object detection followed by semantic segmentation to identify object masks, and then extracts polygon contours from these masks. This is useful for precise shape and area analysis. ```javascript const OBJECT_SEGMENTATION = { components: [{ type: PopComponentType.INFERENCE, inferenceTypes: [InferenceType.OBJECT_DETECTION], modelUuid: 'yolov7:...', forward: { operator: { type: ForwardOperatorType.CROP, crop: { boxPadding: 0.25 } }, targets: [{ type: PopComponentType.INFERENCE, inferenceTypes: [InferenceType.SEMANTIC_SEGMENTATION], modelUuid: 'EfficientSAM:...', forward: { operator: { type: ForwardOperatorType.FULL }, targets: [{ type: PopComponentType.CONTOUR_FINDER, contourType: ContourType.POLYGON }] } }] } }] } ``` -------------------------------- ### Import Core EyePop SDK Components Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/composable-pops Imports essential types and classes from the EyePop SDK for building Composable Pops. This includes enums for different component types, states, and core classes like EyePop. ```javascript import { ContourType, EndpointState, EyePop, ForwardOperatorType, InferenceType, PopComponentType, TransientPopId } from '@eyepop.ai/eyepop' ``` -------------------------------- ### Process Video from URL (TypeScript) Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk This snippet demonstrates how to process a video file by providing its public URL. The SDK will process each frame of the video, and the results will be streamed back asynchronously. ```typescript import { EyePop } from '@eyepop.ai/eyepop' const example_video_url = 'https://demo-eyepop-videos.s3.amazonaws.com/test1_vlog.mp4'; (async() => { const endpoint = await EyePop.workerEndpoint().connect() try { let results = await endpoint.process({url: example_image_url}) for await (let result of results) { console.log(result) } } finally { await endpoint.disconnect() } })(); ``` -------------------------------- ### Dataset Creation Source: https://docs.eyepop.ai/developer-documentation/self-service-training/dataset-sdk-node Creates a new dataset, which serves as the primary container for your model's training data. You specify the dataset name, labels, and tags (e.g., 'object' for object detection or 'classification' for image classification). ```APIDOC ## POST /datasets ### Description Creates a new dataset to hold training data for a model. ### Method POST ### Endpoint `/datasets` ### Parameters #### Query Parameters - **apiKey** (string) - Required - Your EyePop.ai API key for authentication. #### Request Body - **name** (string) - Required - The name of the dataset. - **labels** (array[string]) - Required - A list of labels to be used for training. - **tags** (array[string]) - Required - Tags indicating the model type, e.g., `['object']` for object detection or `['classification']` for image classification. ### Request Example ```json { "name": "Accessories Demo", "labels": ["eye glasses", "handbag", "earrings", "shoes"], "tags": ["object"] } ``` ### Response #### Success Response (200) - **uuid** (string) - The unique identifier for the newly created dataset. - **name** (string) - The name of the dataset. - **labels** (array[string]) - The labels associated with the dataset. - **tags** (array[string]) - The tags associated with the dataset. #### Response Example ```json { "uuid": "dataset-uuid-12345", "name": "Accessories Demo", "labels": ["eye glasses", "handbag", "earrings", "shoes"], "tags": ["object"] } ``` ``` -------------------------------- ### Create Dataset (Node.js) Source: https://docs.eyepop.ai/developer-documentation/self-service-training/dataset-sdk-node Creates a new dataset for model training. Datasets define the model type (object detection or classification) and the labels the model will recognize. ```javascript const dataset = await client.createDataset( 'Accessories Demo', ['eye glasses', 'handbag', 'earrings', 'shoes'], // Labels ['object'] // Tags: 'object' for object detection, 'classification' for classification ); ``` -------------------------------- ### Define a Pop for Semantic Segmentation with Contours (Python) Source: https://docs.eyepop.ai/developer-documentation/sdks/python-sdk/composable-pops Builds a Composable Pop for semantic segmentation that also extracts contours. It uses the 'eyepop.sam.small:latest' model and the ContourFinderComponent to identify polygonal contours with an area threshold of 0.005. ```python Pop(components=[ InferenceComponent( model='eyepop.sam.small:latest', forward=FullForward( targets=[ ContourFinderComponent( contourType=ContourType.POLYGON, areaThreshold=0.005 ) ] ) ) ]) ``` -------------------------------- ### EyePop SDK Callbacks Source: https://docs.eyepop.ai/developer-documentation/sdks/javascript-sdk Callbacks for synchronizing video, drawing, and handling predictions. ```APIDOC ## EyePop SDK Callbacks ### Description These are callback methods provided by the EyePop SDK that are fired at different stages of the frame processing and prediction lifecycle. They are useful for synchronizing external processes like drawing loops with the video feed and for reacting to prediction results. ### `lastmsg` **Description**: The last message received from the Pop WebSocket. Useful for synchronizing video and the drawing loop. **Example**: ```java EyePopSDK.EyePopAPI.instance.OnDrawFrame = function () { var closestIndex = findClosestIndex(cached_data, video.currentTime); EyePopSDK.EyePopAPI.instance.lastmsg = cached_data[ closestIndex ]; } ``` ### `OnDrawFrame()` **Description**: The callback method fired at the beginning of the draw loop. **Example**: ```javascript EyePopSDK.EyePopAPI.instance.OnDrawFrame = function () { console.log("Drawing frame"); } ``` ### `OnDrawFrameEnd(jsonData)` **Description**: The callback method fired at the end of the draw loop. **Parameters**: - **jsonData** (object) - Data associated with the end of the draw frame. **Example**: ```javascript EyePopSDK.EyePopAPI.instance.OnDrawFrameEnd = function (jsonData) { console.log("Finished drawing frame: ", jsonData); } ``` ### `OnPrediction(jsonData)` **Description**: The callback method fired when a new prediction message is received. **Parameters**: - **jsonData** (object) - The prediction data received. **Example**: ```javascript EyePopSDK.EyePopAPI.instance.OnPrediction = function () { console.log("Finished drawing frame"); } ``` ### `OnPredictionTarget()` **Description**: The callback method fired when a target is found in the prediction data. **Example**: ```javascript EyePopSDK.EyePopAPI.instance.OnPredictionTarget = function () { console.log("Target found!"); } ``` ### `OnPredictionEnd()` **Description**: The callback method fired when the analysis is completed. **Example**: ```javascript EyePopSDK.EyePopAPI.instance.OnPredictionEnd = function () { console.log("Analyzed 100%"); } ``` ### `onPredictionEndBase()` **Description**: The callback method fired when the Pop has closed for any reason. **Example**: ```javascript EyePopSDK.EyePopAPI.instance.OnPredictionEndBase = function () { console.error("Pop socket closed!"); } ``` ``` -------------------------------- ### Apply Rendering Rules to 2D Renderer Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/render-2d-visualization Demonstrates how to apply custom rendering rules to the 2D renderer in Eyepop AI. This allows for selective visualization of prediction results. ```javascript // ... Render2d.renderer(context,[Render2.renderFace()]).draw(result); // ... ``` -------------------------------- ### Authenticate with EyePop Docker Registry Source: https://docs.eyepop.ai/developer-documentation/deployment/eyepop-on-premise-ai-runtime Logs the Docker client into the EyePop private container registry using provided credentials. This is necessary to pull EyePop runtime images. ```shell docker login registry.eyepop.ai -u -p ``` -------------------------------- ### Eyepop AI: Detect Objects and Pose on People Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/composable-pops Configures a pipeline to perform general object detection and, specifically, detect human poses when a person is identified. This involves separate components for object detection and keypoint estimation on detected people. ```javascript const OBJECT_PLUS_PERSON = { components: [ { type: PopComponentType.INFERENCE, inferenceTypes: [InferenceType.OBJECT_DETECTION], modelUuid: 'yolov7:...' }, { type: PopComponentType.INFERENCE, inferenceTypes: [InferenceType.OBJECT_DETECTION], modelUuid: 'eyepop-person:...', categoryName: 'person', confidenceThreshold: 0.8, forward: { operator: { type: ForwardOperatorType.CROP }, targets: [{ type: PopComponentType.INFERENCE, inferenceTypes: [InferenceType.KEY_POINTS], categoryName: '2d-body-points', modelUuid: 'Mediapipe:...' }] } } ] } ``` -------------------------------- ### Define Inference Pop Component with Ability Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk/composable-pops Demonstrates how to define an inference component within a Pop, specifying its type as INFERENCE and utilizing a specific AI model ability like 'eyepop.person:latest'. This is a fundamental building block for creating AI pipelines. ```javascript { type: PopComponentType.INFERENCE, ability: "eyepop.person:latest" // Any ability from the list below } ``` -------------------------------- ### Connect with API Key (Shorter TypeScript) Source: https://docs.eyepop.ai/developer-documentation/sdks/react-node-sdk A more concise way to configure and connect to the EyePop API using default environment variables for API key authentication. ```typescript import { EyePop } from '@eyepop.ai/eyepop' (async() => { const endpoint = await EyePop.workerEndpoint().connect() // do work .... await endpoint.disconnect() }) ``` -------------------------------- ### Provide Points or Boxes to a Pop (Python) Source: https://docs.eyepop.ai/developer-documentation/sdks/python-sdk/composable-pops Shows how to pass specific points or bounding boxes as Region of Interest (ROI) parameters to a Pop job. This allows for targeted processing within an image, using ComponentParams to define the ROI coordinates. ```python params = [ ComponentParams(componentId=1, values={ "roi": { "points": [{"x": 100, "y": 150}], "boxes": [{"topLeft": {"x": 10, "y": 20}, "bottomRight": {"x": 200, "y": 300}}] } }) ] job = endpoint.upload("image.jpg", params=params) ``` -------------------------------- ### Upload and Process Batches of Images with Python SDK Source: https://docs.eyepop.ai/developer-documentation/sdks/python-sdk Uploads and processes a batch of images efficiently by queuing all jobs first and then collecting results. This method optimizes performance by processing images in parallel. ```python from eyepop import EyePopSdk def upload_photos(file_paths: list[str]): with EyePopSdk.workerEndpoint() as endpoint: jobs = [] for file_path in file_paths: jobs.append(endpoint.upload(file_path)) for job in jobs: print(job.predict()) upload_photos(['examples/example.jpg'] * 100) ```