File size: 3,316 Bytes
670a324
 
e620c8c
670a324
 
 
4af514d
670a324
 
 
0f14689
 
670a324
 
4af514d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44c5cfa
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
---
title: CanvasAI
emoji: πŸ“š
colorFrom: red
colorTo: indigo
sdk: gradio
sdk_version: 6.22.0
python_version: '3.12'
app_file: app.py
pinned: false
short_description: AI Image Enhancer, Colourizer and Outpainter
startup_duration_timeout: 1h
---

# CanvasAI

Three AI image tools in one interface β€” upscale and sharpen any photo, colorize black and white images automatically, or extend a scene beyond its original borders.

---

## Tools

### ✨ Enhancement
Real-ESRGAN upscales images 2Γ— or 4Γ—, reconstructing fine detail rather than stretching pixels. Processes large images in tiles to stay within VRAM limits.

### 🎨 Colorization
DDColor adds natural color to black and white images without changing structure or composition. Post-processed with LAB color space smoothing to reduce color patchiness, and a saturation boost to compensate for DDColor's tendency to under-saturate. Fully automatic β€” no prompt needed.

### πŸ”² Outpainting
Extends your image in any direction using Stable Diffusion 2 Inpainting. BLIP reads the image and generates an appropriate prompt automatically. Uses a multi-pass 64px incremental approach with feathered mask blending for coherent results.

---

## How the Outpainting Works

The pipeline extends 64 pixels at a time rather than all at once. Each small pass gives SD 87%+ original image context β€” SD extrapolates naturally from what it can see. One large extension gives SD only 60-70% context, and the generated content becomes incoherent.

The mask uses GaussianBlur feathering so the boundary between original and generated content is a soft gradient rather than a hard cut. The mask is resized with LANCZOS (not NEAREST) to preserve this gradient when scaling to SD's 768Γ—768 input size.

---

## Honest Limitations

**Enhancement** does not deblur. It upscales and sharpens existing detail. Blurry input produces larger blurry output.

**Colorization** works well on portraits, street scenes, and landscapes. Complex fabric patterns and heavily degraded photographs may produce inconsistent colors. Results will not match commercial colorization tools.

**Outpainting** quality varies by input. Works best on simple consistent backgrounds at 25% extension or below. Struggles with complex foreground subjects near edges and high extension percentages. The multi-pass approach significantly improves over single-pass but does not eliminate the underlying model's limitations.

---

## Tips for Best Results

- Enhancement: works on any image, best on photographs with existing sharp detail
- Colorization: portraits and outdoor scenes colorize most consistently
- Outpainting: use Horizontal or Vertical (not Both), keep extension at 25%, use the custom prompt field if BLIP misreads your image

---

## Models Used

| Model | Purpose |
|---|---|
| RealESRGAN_x4plus | Super resolution |
| stable-diffusion-2-inpainting | Scene extension |
| blip-image-captioning-base | Auto prompt generation |
| cv_ddcolor_image-colorization | B&W colorization |

---

## Privacy

Images are processed in memory and not stored permanently. Uploaded images are deleted when your session ends. Do not upload sensitive or private images.

---

## GitHub

Full code, architecture notes, and documentation:
[github.com/Mohit485/CanvasAI](https://github.com/Mohit485/CanvasAI)