Spaces:
Sleeping
Sleeping
Commit Β·
b30daed
1
Parent(s): 52d4309
Prepare open source release
Browse files- CONTRIBUTING.md +27 -0
- LICENSE +21 -0
- README.md +76 -9
CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contributing
|
| 2 |
+
|
| 3 |
+
Thanks for helping improve Grid2Frame.
|
| 4 |
+
|
| 5 |
+
## Development Setup
|
| 6 |
+
|
| 7 |
+
```bash
|
| 8 |
+
python3 -m venv .venv
|
| 9 |
+
.venv/bin/python3 -m pip install -r requirements.txt
|
| 10 |
+
.venv/bin/python3 app.py
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
## Checks
|
| 14 |
+
|
| 15 |
+
Run these before opening a pull request:
|
| 16 |
+
|
| 17 |
+
```bash
|
| 18 |
+
.venv/bin/python3 -m py_compile app.py grid2frame/extractor.py scripts/extract_grid.py
|
| 19 |
+
.venv/bin/python3 scripts/extract_grid.py path/to/sample-grid.png
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
## Pull Requests
|
| 23 |
+
|
| 24 |
+
- Keep changes focused.
|
| 25 |
+
- Include before/after notes for detection changes.
|
| 26 |
+
- Avoid committing generated images, ZIP files, virtual environments, or caches.
|
| 27 |
+
- Add sample dimensions and expected row/column counts when reporting detection issues.
|
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 Emmanuel Crown
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
CHANGED
|
@@ -1,8 +1,31 @@
|
|
| 1 |
# Grid2Frame
|
| 2 |
|
| 3 |
-
Extract individual images from a grid or contact-sheet style image.
|
| 4 |
|
| 5 |
-
Grid2Frame is
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
## Run Locally
|
| 8 |
|
|
@@ -12,18 +35,62 @@ python3 -m venv .venv
|
|
| 12 |
.venv/bin/python3 app.py
|
| 13 |
```
|
| 14 |
|
| 15 |
-
Then open the local URL printed by Gradio.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
## Deploy Free
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
|
| 21 |
1. Create a new Space.
|
| 22 |
-
2.
|
| 23 |
-
3. Push this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
##
|
| 28 |
|
| 29 |
-
|
|
|
|
| 1 |
# Grid2Frame
|
| 2 |
|
| 3 |
+
Extract individual images from a grid, collage, storyboard, or contact-sheet style image.
|
| 4 |
|
| 5 |
+
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.
|
| 6 |
+
|
| 7 |
+
## Features
|
| 8 |
+
|
| 9 |
+
- Upload JPG, PNG, WebP, and other OpenCV-readable image formats.
|
| 10 |
+
- Detect variable grid layouts with dark, light, or automatic separator detection.
|
| 11 |
+
- Preview detected frame boundaries before downloading.
|
| 12 |
+
- Export individual frames as JPG, PNG, or WebP.
|
| 13 |
+
- Download all extracted frames as a ZIP.
|
| 14 |
+
- Run locally or deploy to free Python-friendly hosts such as Hugging Face Spaces.
|
| 15 |
+
|
| 16 |
+
## Demo Workflow
|
| 17 |
+
|
| 18 |
+
1. Upload a grid image.
|
| 19 |
+
2. Adjust `Sensitivity`, `Minimum frame`, or `Separator` if needed.
|
| 20 |
+
3. Click `Extract`.
|
| 21 |
+
4. Download the generated ZIP with `Download all frames`.
|
| 22 |
+
|
| 23 |
+
## Requirements
|
| 24 |
+
|
| 25 |
+
- Python 3.10+
|
| 26 |
+
- `pip`
|
| 27 |
+
|
| 28 |
+
The app dependencies are listed in [requirements.txt](requirements.txt).
|
| 29 |
|
| 30 |
## Run Locally
|
| 31 |
|
|
|
|
| 35 |
.venv/bin/python3 app.py
|
| 36 |
```
|
| 37 |
|
| 38 |
+
Then open the local URL printed by Gradio, usually `http://127.0.0.1:7860`.
|
| 39 |
+
|
| 40 |
+
## CLI Usage
|
| 41 |
+
|
| 42 |
+
You can also run the detector without the UI:
|
| 43 |
+
|
| 44 |
+
```bash
|
| 45 |
+
.venv/bin/python3 scripts/extract_grid.py path/to/grid-image.png
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
The CLI prints JSON containing the detected image size, rows, columns, and crop regions.
|
| 49 |
|
| 50 |
## Deploy Free
|
| 51 |
|
| 52 |
+
### Hugging Face Spaces
|
| 53 |
+
|
| 54 |
+
Hugging Face Spaces is the recommended free host for the Python-only app.
|
| 55 |
|
| 56 |
1. Create a new Space.
|
| 57 |
+
2. Choose `Gradio` as the SDK.
|
| 58 |
+
3. Push this repository.
|
| 59 |
+
|
| 60 |
+
Spaces will install [requirements.txt](requirements.txt) and run [app.py](app.py).
|
| 61 |
+
|
| 62 |
+
## Project Structure
|
| 63 |
+
|
| 64 |
+
```text
|
| 65 |
+
.
|
| 66 |
+
βββ app.py # Gradio application
|
| 67 |
+
βββ grid2frame/
|
| 68 |
+
β βββ __init__.py
|
| 69 |
+
β βββ extractor.py # OpenCV detection and extraction logic
|
| 70 |
+
βββ scripts/
|
| 71 |
+
β βββ extract_grid.py # JSON-emitting CLI detector
|
| 72 |
+
βββ requirements.txt
|
| 73 |
+
βββ README.md
|
| 74 |
+
βββ LICENSE
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## Branches
|
| 78 |
+
|
| 79 |
+
- `main`: Python-only Gradio app.
|
| 80 |
+
- `nextjs`: previous Next.js implementation preserved for reference.
|
| 81 |
+
|
| 82 |
+
## Contributing
|
| 83 |
+
|
| 84 |
+
Issues and pull requests are welcome. Good areas to improve include:
|
| 85 |
+
|
| 86 |
+
- Better detection for grids without solid separators.
|
| 87 |
+
- Manual crop correction tools.
|
| 88 |
+
- Batch upload support.
|
| 89 |
+
- More export naming options.
|
| 90 |
+
- Tests with a wider set of grid layouts.
|
| 91 |
|
| 92 |
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development notes.
|
| 93 |
|
| 94 |
+
## License
|
| 95 |
|
| 96 |
+
MIT. See [LICENSE](LICENSE).
|