AI_Lab_CAM / README.md
Aditya7864's picture
update the code
444ff93
|
Raw
History Blame Contribute Delete
3.9 kB
---
title: CV Lab Camera Studio
emoji: πŸ“·
colorFrom: indigo
colorTo: blue
sdk: gradio
sdk_version: 5.50.0
app_file: app.py
pinned: false
short_description: Computer vision, AR filters, and image analysis laboratory.
license: mit
---
# CV Lab Camera
CV Lab Camera is a Gradio application and developer suite for computer vision, scientific image analysis, geometric transformations, morphology, neural style transfer, AR face overlays, and batch dataset processing.
---
## Developer Quickstart
### 1. Web App
Launch the interactive Gradio laboratory:
```bash
python app.py
```
### 2. Command Line Interface (CLI)
Process images directly from your terminal or shell scripts:
```bash
# Apply built-in filter
python cli.py filter --input input.jpg --filter Sepia --output result.jpg
# Apply geometric transformation
python cli.py transform --input input.jpg --op Rotation --angle 45 --output result.jpg
# Apply morphological operation
python cli.py morph --input input.jpg --op Opening --size 5 --output result.jpg
# Apply AR face overlay
python cli.py ar --input face.jpg --filter Glasses --output ar_result.jpg
# Apply neural style transfer
python cli.py style --input content.jpg --style-image style.jpg --output stylized.jpg
# Batch process dataset
python cli.py batch --dir ./my_dataset --filter Grayscale --output-zip processed.zip
```
### 3. Python Developer SDK (`developer_api.py`)
Import CV Lab functions directly in your Python code:
```python
from developer_api import process_image, generate_python_snippet
# Process image programmatically
result, meta = process_image(
image_input="photo.png",
operation_type="filter",
operation_name="Sepia",
output_path="output_sepia.png"
)
# Generate copy-pasteable Python code
code = generate_python_snippet("Sepia", {"contrast": 1.2})
print(code)
```
---
## Architecture Overview
```
AI_Lab_CAM/
β”œβ”€β”€ app.py # Gradio UI Web App (interactive tabs & code generator)
β”œβ”€β”€ cli.py # Developer Command Line Interface (CLI)
β”œβ”€β”€ developer_api.py # Developer SDK / Python API wrapper
β”œβ”€β”€ batch/
β”‚ └── dataset_processor.py # Batch directory/zip processing with manifest.json
β”œβ”€β”€ cv_ops/
β”‚ β”œβ”€β”€ analysis.py # Intensity histograms & pixel statistics
β”‚ β”œβ”€β”€ morphology.py # Thresholding & morphological operations
β”‚ └── transforms.py # Translation, rotation, scaling, reflection
β”œβ”€β”€ filters/
β”‚ β”œβ”€β”€ builtin.py # Pure NumPy / OpenCV filter functions
β”‚ β”œβ”€β”€ custom.py # Custom kernel & pipeline JSON parsers
β”‚ └── registry.py # Filter registry & saved JSON persistence
β”œβ”€β”€ models/
β”‚ β”œβ”€β”€ face_filters.py # OpenCV AR face landmark detector & filter engine
β”‚ └── style_transfer.py # TensorFlow Hub Magenta neural style transfer
β”œβ”€β”€ saved_filters/ # Saved custom filter JSONs
β”œβ”€β”€ saved_ar_filters/ # Saved custom AR filter JSONs
β”œβ”€β”€ tests/ # Pytest suite
└── requirements.txt # Python dependencies
```
---
## Custom Filters & AR Filters
### Image Processing Filter Pipelines
Save multi-step filter pipelines as JSON:
```json
[
{"operation": "Grayscale", "params": {}},
{"operation": "Sharpen", "params": {"amount": 1.4}}
]
```
### Custom AR Face Filters
Design landmark-based AR overlays attached to `head_top`, `forehead`, `eyes`, `nose`, `mouth`, `chin`:
```json
{
"elements": [
{
"landmark": "forehead",
"shape": "crown",
"color": [255, 215, 0],
"scale": 1.0,
"offset_y": -0.15
},
{
"landmark": "eyes",
"shape": "visor",
"color": [0, 255, 255],
"scale": 1.0
}
]
}
```
---
## Testing
Run the test suite:
```bash
pytest
```