m9jaex commited on
Commit
6df4679
·
1 Parent(s): 115023b

Add progress tracking and asynchronous processing to image manipulation features

Browse files

Update API documentation and add new asynchronous endpoints for image processing, along with progress and result retrieval endpoints.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 2cb6c3f4-ce08-4bde-a268-54e2cdd3f036
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 05390401-1966-4200-a81a-4e10cbd0de6a
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/96765cf9-2c9b-4430-9c18-e5af0801dd36/2cb6c3f4-ce08-4bde-a268-54e2cdd3f036/2ZGkGrx

Files changed (1) hide show
  1. replit.md +43 -4
replit.md CHANGED
@@ -34,13 +34,19 @@ An AI-powered image processing API with multiple features:
34
  - `GET /docs` - Swagger API documentation
35
  - `GET /health` - Health check
36
  - `GET /model-info` - Model information
37
- - `POST /enhance` - Enhance/upscale image (Real-ESRGAN)
 
 
 
38
  - `POST /enhance/base64` - Enhance image (returns base64)
39
- - `POST /remove-background` - Remove image background (BiRefNet)
 
40
  - `POST /remove-background/base64` - Remove background (returns base64)
41
- - `POST /denoise` - Reduce image noise (OpenCV NLM)
 
42
  - `POST /denoise/base64` - Denoise image (returns base64)
43
- - `POST /docscan` - Scan document (auto-crop, align, HD enhance)
 
44
  - `POST /docscan/base64` - Scan document (returns base64)
45
 
46
  ## Document Scanner Features
@@ -59,7 +65,40 @@ The `/docscan` endpoint provides:
59
  3. Upload all files: `app.py`, `enhancer.py`, `document_scanner.py`, `templates/`, `requirements.txt`, `Dockerfile`, `README.md`
60
  4. The Space will auto-build the container and download AI models
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  ## Recent Changes
 
 
 
 
 
 
 
63
  - 2025-11-28: Added document scanning feature
64
  - Auto-crop with edge detection and contour finding
65
  - Perspective correction for skewed documents
 
34
  - `GET /docs` - Swagger API documentation
35
  - `GET /health` - Health check
36
  - `GET /model-info` - Model information
37
+ - `GET /progress/{job_id}` - Get async job progress
38
+ - `GET /result/{job_id}` - Get completed job result
39
+ - `POST /enhance` - Enhance/upscale image (Real-ESRGAN) - supports `async_mode=true`
40
+ - `POST /enhance/async` - Start async enhancement with progress tracking
41
  - `POST /enhance/base64` - Enhance image (returns base64)
42
+ - `POST /remove-background` - Remove image background (BiRefNet) - supports `async_mode=true`
43
+ - `POST /remove-background/async` - Start async background removal with progress
44
  - `POST /remove-background/base64` - Remove background (returns base64)
45
+ - `POST /denoise` - Reduce image noise (OpenCV NLM) - supports `async_mode=true`
46
+ - `POST /denoise/async` - Start async denoising with progress
47
  - `POST /denoise/base64` - Denoise image (returns base64)
48
+ - `POST /docscan` - Scan document (auto-crop, align, HD enhance) - supports `async_mode=true`
49
+ - `POST /docscan/async` - Start async document scan with progress
50
  - `POST /docscan/base64` - Scan document (returns base64)
51
 
52
  ## Document Scanner Features
 
65
  3. Upload all files: `app.py`, `enhancer.py`, `document_scanner.py`, `templates/`, `requirements.txt`, `Dockerfile`, `README.md`
66
  4. The Space will auto-build the container and download AI models
67
 
68
+ ## Progress Tracking API
69
+ All image processing endpoints support async mode with progress tracking:
70
+
71
+ 1. Start a job with `async_mode=true` or use the `/async` endpoints
72
+ 2. Receive a `job_id` in the response
73
+ 3. Poll `/progress/{job_id}` to get current progress (0-100%)
74
+ 4. When complete, fetch result from `/result/{job_id}`
75
+
76
+ Example response from progress endpoint:
77
+ ```json
78
+ {
79
+ "job_id": "abc-123",
80
+ "status": "processing",
81
+ "progress": 45.0,
82
+ "message": "Enhancing image (4 tiles)...",
83
+ "current_step": 2,
84
+ "total_steps": 5
85
+ }
86
+ ```
87
+
88
+ ## Performance Optimizations
89
+ - **Tile processing**: Images processed in 256px tiles for memory efficiency
90
+ - **Max input size**: 512x512 for enhance (auto-resized), 2048x2048 for docscan
91
+ - **Default scale**: 2x (faster than 4x, still good quality)
92
+ - **Background threading**: Server stays responsive during processing
93
+
94
  ## Recent Changes
95
+ - 2025-11-28: Added progress tracking and async processing
96
+ - New progress_tracker.py module with thread-safe job tracking
97
+ - /progress/{job_id} and /result/{job_id} endpoints
98
+ - async_mode parameter on all image processing endpoints
99
+ - Dedicated /async endpoints for each feature
100
+ - Automatic cleanup of old jobs and result files
101
+ - Performance optimizations: tile=256, max_size=512, default scale=2
102
  - 2025-11-28: Added document scanning feature
103
  - Auto-crop with edge detection and contour finding
104
  - Perspective correction for skewed documents