Spaces:
Sleeping
Sleeping
File size: 2,686 Bytes
032d5c8 be1cb53 b30daed be1cb53 b30daed be1cb53 b30daed be1cb53 b30daed be1cb53 b30daed be1cb53 b30daed be1cb53 b30daed be1cb53 b30daed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | ---
title: Grid2Frame
sdk: gradio
sdk_version: 6.1.0
app_file: app.py
license: mit
---
# Grid2Frame
Extract individual images from a grid, collage, storyboard, or contact-sheet style image.
Grid2Frame is a Python-only Gradio app powered by OpenCV. Upload a grid image, let the detector find the frame boundaries, preview the detected boxes, inspect the extracted frames, and download everything as a ZIP.
## Features
- Upload JPG, PNG, WebP, and other OpenCV-readable image formats.
- Detect variable grid layouts with dark, light, or automatic separator detection.
- Preview detected frame boundaries before downloading.
- Export individual frames as JPG, PNG, or WebP.
- Download all extracted frames as a ZIP.
- Run locally or deploy to free Python-friendly hosts such as Hugging Face Spaces.
## Demo Workflow
1. Upload a grid image.
2. Adjust `Sensitivity`, `Minimum frame`, or `Separator` if needed.
3. Click `Extract`.
4. Download the generated ZIP with `Download all frames`.
## Requirements
- Python 3.10+
- `pip`
The app dependencies are listed in [requirements.txt](requirements.txt).
## Run Locally
```bash
python3 -m venv .venv
.venv/bin/python3 -m pip install -r requirements.txt
.venv/bin/python3 app.py
```
Then open the local URL printed by Gradio, usually `http://127.0.0.1:7860`.
## CLI Usage
You can also run the detector without the UI:
```bash
.venv/bin/python3 scripts/extract_grid.py path/to/grid-image.png
```
The CLI prints JSON containing the detected image size, rows, columns, and crop regions.
## Deploy Free
### Hugging Face Spaces
Hugging Face Spaces is the recommended free host for the Python-only app.
1. Create a new Space.
2. Choose `Gradio` as the SDK.
3. Push this repository.
Spaces will install [requirements.txt](requirements.txt) and run [app.py](app.py).
## Project Structure
```text
.
βββ app.py # Gradio application
βββ grid2frame/
β βββ __init__.py
β βββ extractor.py # OpenCV detection and extraction logic
βββ scripts/
β βββ extract_grid.py # JSON-emitting CLI detector
βββ requirements.txt
βββ README.md
βββ LICENSE
```
## Branches
- `main`: Python-only Gradio app.
- `nextjs`: previous Next.js implementation preserved for reference.
## Contributing
Issues and pull requests are welcome. Good areas to improve include:
- Better detection for grids without solid separators.
- Manual crop correction tools.
- Batch upload support.
- More export naming options.
- Tests with a wider set of grid layouts.
See [CONTRIBUTING.md](CONTRIBUTING.md) for development notes.
## License
MIT. See [LICENSE](LICENSE).
|