|
Download README.md from Druudik1/texture-brush: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/Druudik1/texture-brush/resolve/main/README.md
- Command line
-
hf download hf://Druudik1/texture-brush/README.md
-
curl -L -o README.md https://huggingface.co/Druudik1/texture-brush/resolve/main/README.md
1.53 kB
| license: mit | |
| This repository contains trained `GeneralNeuralRenderer` that learned to mimic `TextureBrush` (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 `TextureBrush`: | |
| ```python | |
| from PIL import Image | |
| from huggingface_hub import hf_hub_download | |
| from painting.brushes import TextureBrush, GeneralNeuralRenderer | |
| import torchvision.transforms.functional as TF | |
| def load_texture(source: str, device: str): | |
| img = Image.open(source).convert("L") | |
| tensor = TF.pil_to_tensor(img).float() / 255.0 | |
| return tensor.to(device) | |
| # Specify your device and output canvas size. | |
| device = "cuda" | |
| out_canvas_size = 512 | |
| brush = TextureBrush( | |
| large_vertical=load_texture("./assets/textures/large_vertical_brush.png", device), | |
| large_horizontal=load_texture("./assets/textures/large_horizontal_brush.png", device), | |
| small_vertical=load_texture("./assets/textures/small_vertical_brush.png", device), | |
| small_horizontal=load_texture("./assets/textures/small_horizontal_brush.png", device), | |
| 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/texture-brush", filename="neural_renderer.pt") | |
| differentiable_brush.load_state_dict( | |
| torch.load(weights, map_location=device, weights_only=True) | |
| ) | |
| ``` |