https://github.com/hamza-cpp/paddle_layout
https://github.com/hamza-cpp/paddle_layout
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hamza-cpp/paddle_layout
- Owner: Hamza-cpp
- Created: 2025-03-14T19:31:37.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-03-14T20:13:05.000Z (11 months ago)
- Last Synced: 2025-03-14T21:27:38.332Z (11 months ago)
- Language: Python
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Document Layout API
A Flask-based REST API for document layout analysis using PaddlePaddle's PP-DocLayout model.
## Overview
This API provides an endpoint for analyzing document layouts from uploaded images using PP-DocLayout-L, a model that can detect and classify document components such as text blocks, tables, figures, and more.
## API Endpoints
### Health Check
```
GET /health
```
Returns the health status of the API and whether GPU is enabled.
**Example Response:**
```json
{
"status": "healthy",
"gpu_enabled": false
}
```
### Document Layout Analysis
```
POST /predict
```
Analyzes the layout of a document from an uploaded file.
**Request:**
- Content-Type: multipart/form-data
- Body:
- `file`: The document file to analyze
**Example Response:**
```json
{
"message": "Prediction successful",
"inference_time": 1.2345,
"device": "CPU",
"results": [
{
"page_index": 0,
"data": [
{
"category": "text",
"bbox": [100, 100, 500, 200],
"score": 0.98
},
{
"category": "table",
"bbox": [100, 300, 500, 600],
"score": 0.95
}
]
}
]
}
```
## Usage
1. Start the server:
```bash
python app.py
```
2. The API will be available at
3. To analyze a document, send a POST request to the /predict endpoint with a file upload:
```bash
curl -X POST -F "file=@example.pdf" http://localhost:5000/predict
```