Metadata-Version: 2.3
Name: gradio_point_promptable_image
Version: 0.0.2
Summary: A webcam-compatible Gradio input component enabling point-based prompting.
Author: ncstiles
License-Expression: MIT
Keywords: gradio-custom-component,gradio-template-Image
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.8
Requires-Dist: gradio<5.0,>=4.0
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown


# `gradio_point_promptable_image`

A webcam-compatible Gradio input component enabling point-based prompting.

## Installation

```bash
pip install gradio_point_promptable_image
```

## Usage

```python

import gradio as gr
from gradio_point_promptable_image import PointPromptableImage
import cv2

PURPLE = (177, 157, 217)

image_examples = [{"image": "images/cat.png", "points": []}]

def get_point_inputs(prompts):
    point_inputs = []
    for prompt in prompts:
        if prompt[2] == 1.0 and prompt[5] == 4.0:
            point_inputs.append((prompt[0], prompt[1]))

    return point_inputs

def process_input(input_dict):
    img, points = input_dict['image'], input_dict['points']

    point_inputs = get_point_inputs(points)

    for point in point_inputs:
        x, y = int(point[0]), int(point[1])
        cv2.circle(img, (x, y), 2, PURPLE, thickness=10)

    return img

demo = gr.Interface(
    process_input,
    PointPromptableImage(),
    gr.Image(),
    examples=image_examples,
)

if __name__ == "__main__":
    demo.launch()

```

## Acknowledgements

Special thanks to the creators of [gradio-image-prompter](https://github.com/PhyscalX/gradio-image-prompter/tree/main?tab=readme-ov-file) - this custom component is heavily adapted from their work.
