User-2468 commited on
Commit
e59a62e
·
verified ·
1 Parent(s): 437f81b

Push model using huggingface_hub.

Browse files
Files changed (3) hide show
  1. README.md +10 -40
  2. config.json +6 -0
  3. model.safetensors +2 -2
README.md CHANGED
@@ -1,46 +1,16 @@
1
  ---
 
 
2
  tags:
3
- - image-to-image
4
  - colorization
 
 
 
5
  - unet
6
- - pytorch
7
- license: apache-2.0
8
  ---
9
 
10
- # Mini U-Net Colorizer
11
-
12
- A 3,651,004-parameter U-Net that colorizes grayscale photos. Classification-style
13
- (Zhang et al., "Colorful Image Colorization"): it predicts a distribution over
14
- 236 quantized CIE Lab `a`/`b` bins per pixel rather than regressing a
15
- single ab value directly, with color-bin loss weights derived from the real
16
- training-data distribution (rare/saturated colors weighted higher) so it
17
- doesn't just hedge toward desaturated averages. Decode with an annealed mean.
18
-
19
- - **Status:** Final (20 epochs complete)
20
- - **Input:** L channel normalized as `L/50 - 1` -> `[-1, 1]`, shape `(1, 256, 256)`
21
- - **Output:** logits over 236 ab bins, shape `(236, 256, 256)`
22
- - **Trained on:** `johnowhitaker/imagenette2-320` (None), warm-started from `User-2468/mini-unet-colorizer`
23
- - **Loss so far (weighted soft cross-entropy):** train 2.6135, val 2.7720
24
-
25
- ## Usage
26
-
27
- ```python
28
- import numpy as np, torch
29
- from skimage.color import rgb2lab, lab2rgb
30
- from PIL import Image
31
- # paste the SmallUNetColorizer class definition from the training script, then:
32
- model = SmallUNetColorizer.from_pretrained("User-2468/mini-unet-colorizer")
33
- model.eval()
34
-
35
- img = Image.open("photo.jpg").convert("RGB").resize((256, 256))
36
- lab = rgb2lab(np.asarray(img).astype("float32") / 255.0)
37
- L = torch.from_numpy(lab[:, :, 0:1] / 50.0 - 1.0).permute(2, 0, 1)[None]
38
-
39
- with torch.no_grad():
40
- logits = model(L)
41
- ab = model.decode(logits, temperature=0.38)[0].permute(1, 2, 0).numpy()
42
-
43
- L_out = (L[0, 0].numpy() + 1) * 50.0
44
- lab_out = np.concatenate([L_out[:, :, None], ab], axis=-1)
45
- rgb_out = np.clip(lab2rgb(lab_out), 0, 1)
46
- ```
 
1
  ---
2
+ license: apache-2.0
3
+ pipeline_tag: image-to-image
4
  tags:
5
+ - classification
6
  - colorization
7
+ - image-to-image
8
+ - model_hub_mixin
9
+ - pytorch_model_hub_mixin
10
  - unet
 
 
11
  ---
12
 
13
+ This model has been pushed to the Hub using the [PytorchModelHubMixin](https://huggingface.co/docs/huggingface_hub/package_reference/mixins#huggingface_hub.PyTorchModelHubMixin) integration:
14
+ - Code: [More Information Needed]
15
+ - Paper: [More Information Needed]
16
+ - Docs: [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
config.json CHANGED
@@ -946,5 +946,11 @@
946
  -35.0
947
  ]
948
  ],
 
 
 
 
 
 
949
  "in_ch": 1
950
  }
 
946
  -35.0
947
  ]
948
  ],
949
+ "context_dilations": [
950
+ 2,
951
+ 4,
952
+ 8
953
+ ],
954
+ "context_mid_ch": 96,
955
  "in_ch": 1
956
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:acffe0090532e4a6fa714b1e9488d6d2b7ffda4b25273c690e83deb9a55c2f43
3
- size 14629040
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c2b4ca6eb9b48a053dd64c7e38c7b84585fc81135f416b377409f701300301c9
3
+ size 15909320