File size: 970 Bytes
e666e39
 
 
 
 
 
 
 
d7380ce
 
e666e39
d7380ce
e666e39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
---

---
license: mit
---

This repository contains trained `GeneralNeuralRenderer` that learned to mimic `RectangleBrush` (these are 
components of my [Stylized Neural Painting paper reimplementation](https://github.com/Druudik/stylized-neural-painting)).

Use the following code snippet to load it and create the corresponding `RectangleBrush`:
```python
from huggingface_hub import hf_hub_download
from painting.brushes import RectangleBrush, GeneralNeuralRenderer

# Specify your device and output canvas size.
device = "cuda"
out_canvas_size = 512

brush = RectangleBrush(canvas_size=out_canvas_size, device=device)
differentiable_brush = GeneralNeuralRenderer(
  brush_params_count=brush.brush_params_count,
  canvas_size=128,
  device=device,
)

weights = hf_hub_download(repo_id="Druudik1/rectangle-brush", filename="neural_renderer.pt")
differentiable_brush.load_state_dict(
    torch.load(weights, map_location=device, weights_only=True)
)
```