File size: 1,991 Bytes
c8c874a
 
 
 
 
 
 
19fea29
 
 
 
 
 
c8c874a
 
 
 
 
 
 
 
 
 
 
8bce849
c8c874a
8bce849
c8c874a
8bce849
c8c874a
8bce849
 
c8c874a
8bce849
 
 
 
c8c874a
8bce849
 
 
c8c874a
8bce849
 
c8c874a
8bce849
 
 
 
c8c874a
8bce849
 
 
c8c874a
8bce849
 
c8c874a
8bce849
 
c8c874a
8bce849
 
 
 
 
 
 
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
---
license: creativeml-openrail-m
library_name: diffusers
tags:
- stable-diffusion
- stable-diffusion-diffusers
- text-to-image
- diffusers
- controlnet
- diffusers-training
- stable-diffusion
- stable-diffusion-diffusers
- text-to-image
- diffusers
- controlnet
- diffusers-training
base_model: stabilityai/stable-diffusion-2-1-base
inference: true
---

<!-- This model card has been generated automatically according to the information the training script had access to. You
should probably proofread and complete it, then remove this comment. -->


# controlnet_rough

Generate a roughness map from a photograph or basecolor (albedo) map.

# Usage

```
import argparse

from PIL import Image
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
from diffusers.utils import load_image
import torch

parser = argparse.ArgumentParser(description="Args for parser")
parser.add_argument("--seed", type=int, default=1, help="Seed for inference")
args = parser.parse_args()

base_model_path = "stabilityai/stable-diffusion-2-1-base"
controlnet_path = "sidnarsipur/controlnet_rough"

controlnet = ControlNetModel.from_pretrained(controlnet_path, torch_dtype=torch.float16)
pipe = StableDiffusionControlNetPipeline.from_pretrained(
    base_model_path, controlnet=controlnet, torch_dtype=torch.float16
)

pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
pipe.enable_xformers_memory_efficient_attention()
pipe.enable_model_cpu_offload()

control_image = load_image("inference/basecolor.png") #Change based on your image path
prompt = "Roughness Map" #Don't change!

if control_image.size[0] > 2048 or control_image.size[1] > 2048: #Optional
    control_image = control_image.resize((control_image.size[0] // 2, control_image.size[1] // 2))

generator = torch.manual_seed(args.seed)

image = pipe(
    prompt, num_inference_steps=50, generator=generator, image=control_image
).images[0]
image.save("inference/normal.png")
```