
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
A powerful Python package for object detection using advanced vision and reasoning models, including OpenAI's models and Google's Gemini.
Comparison of detection results across different models - showing the superior performance of the advanced reasoning model
Multiple Detection Models:
Tool-Use Reasoning: Our advanced model uses innovative grid-based reasoning for precise object detection
How the advanced reasoning model works under the hood - using grid cells for precise localization
Simple API: One function for all your detection needs
CLI Support: Command-line interface for quick testing
pip install spatial-reasoning
Or install from source:
git clone https://github.com/QasimWani/spatial-reasoning.git
cd spatial_reasoning
pip install -e .
For improved performance with transformer models, you can optionally install Flash Attention:
pip install flash-attn --no-build-isolation
Note: Flash Attention requires CUDA development tools and must be compiled for your specific PyTorch/CUDA version. The package will work without it, just with slightly reduced performance.
Create a .env
file in your project root:
# .env
OPENAI_API_KEY=your-openai-api-key-here
GEMINI_API_KEY=your-google-gemini-api-key-here
Get your API keys:
from spatial_reasoning import detect
# Detect objects in an image
result = detect(
image_path="https://ix-cdn.b2e5.com/images/27094/27094_3063d356a3a54cc3859537fd23c5ba9d_1539205710.jpeg", # or image-path
object_of_interest="farthest scooter in the image",
task_type="advanced_reasoning_model"
)
# Access results
bboxes = result['bboxs']
visualized_image = result['visualized_image']
print(f"Found {len(bboxes)} objects")
# Save the result
visualized_image.save("output.jpg")
# Basic usage
spatial-reasoning --image-path "image.jpg" --object-of-interest "person" # "advanced_reasoning_model" used by default
# With specific model
spatial-reasoning --image-path "image.jpg" --object-of-interest "cat" --task-type "gemini"
# From URL with custom parameters
vision-evals \
--image-path "https://example.com/image.jpg" \
--object-of-interest "text in image" \
--task-type "advanced_reasoning_model" \
--task-kwargs '{"nms_threshold": 0.7}'
advanced_reasoning_model
(default) - Best accuracy, uses tool-use reasoningvanilla_reasoning_model
- Faster, standard detectionvision_model
- Uses GroundingDino + (optional) SAM2 for segmentationgemini
- Google's Gemini modelMIT License
FAQs
A PyPI package for object detection using advanced vision models
We found that spatial-reasoning demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.