Spaces:
Running
Running
File size: 2,632 Bytes
ef35929 7472bd0 30436f6 7472bd0 30436f6 7472bd0 30436f6 6fd550f 30436f6 fb59b22 30436f6 fb59b22 30436f6 fb59b22 30436f6 |
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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
---
title: Comic Panel Extractor
emoji: π
colorFrom: indigo
colorTo: purple
sdk: docker
pinned: false
---
https://jebin2-comic-panel-extractor.hf.space/
# π Comic Panel Extractor
Automatically extract panels from comic pages using YOLO segmentation and image processing.
> **Note:** Currently using pretrained model from [mosesb/best-comic-panel-detection](https://huggingface.co/mosesb/best-comic-panel-detection) until custom training is complete. The model downloads automatically on first run.
## Installation
```bash
git clone https://github.com/jebin2/comic-panel-extractor.git
cd comic-panel-extractor
pip install -e .
```
## Usage
### Extract Panels
**Web Interface:**
```bash
serve-comic-panel-extractor
# Visit http://localhost:7860
```
**CLI:**
```bash
comic-panel-extractor path/to/comic.jpg
```
**Python:**
```python
from comic_panel_extractor.main import ComicPanelExtractor
from comic_panel_extractor.config import Config, load_config
config = load_config()
config.input_path = "comic.jpg"
extractor = ComicPanelExtractor(config)
panels, data, paths = extractor.extract_panels_from_comic()
```
### Annotate Data
Visit `http://localhost:7860/annotate`
**Shortcuts:**
- Click/drag for boxes
- `S` = Save
- `D` = Auto-detect
- `Delete` = Remove
### Train Model
**1. Setup Dataset:**
```bash
# Add to .env
SOURCE_PATH=/path/to/images
# Create dataset (80/10/10 split)
python -m comic_panel_extractor.create_dataset
```
**2. Configure Training (.env):**
```env
EPOCH=200
YOLO_BASE_MODEL_NAME=yolo11s-seg
YOLO_MODEL_NAME=comic_panel
```
**3. Train:**
```bash
python -m comic_panel_extractor.train
```
### Run Inference
```bash
python -m comic_panel_extractor.inference
```
```python
from comic_panel_extractor.yolo_manager import YOLOManager
with YOLOManager() as yolo:
yolo.load_model('weights.pt')
yolo.annotate_images(['image.jpg'], 'output')
```
## Configuration
```python
config = load_config()
config.min_width_ratio = 0.15 # Min panel width (% of image)
config.min_height_ratio = 0.15 # Min panel height (% of image)
config.min_area_ratio = 0.05 # Min panel area (% of image)
```
## Docker
```bash
docker build -t comic-panel-extractor .
docker run -p 7860:7860 comic-panel-extractor
```
## API Endpoints
**Extract:**
- `POST /api/extract/convert` - Upload & extract panels
**Annotate:**
- `GET /api/annotate/images` - List images
- `GET /api/annotate/annotations/{image}` - Get annotations
- `GET /api/annotate/detect_annotations/{image}` - Auto-detect
- `POST /api/annotate/annotations` - Save annotations
## Author
Jebin Einstein E - jebineinstein@gmail.com |