Update README.md
Browse files
README.md
CHANGED
@@ -27,6 +27,37 @@ Our data can be found in the following link: [RCID Dataset](https://huggingface.
|
|
27 |
|
28 |
The code is released on [Color Illusion](https://github.com/mao1207/RCID)
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
## License
|
31 |
|
32 |
The source code of this repository is released under the Apache License 2.0. The model license and dataset license are listed on their corresponding webpages.
|
|
|
27 |
|
28 |
The code is released on [Color Illusion](https://github.com/mao1207/RCID)
|
29 |
|
30 |
+
## How to Use the Model
|
31 |
+
|
32 |
+
To generate a realistic image from a simplified image and a text prompt using the Color Diffusion model, you can use the following code:
|
33 |
+
|
34 |
+
```python
|
35 |
+
import random
|
36 |
+
import torch
|
37 |
+
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
|
38 |
+
from diffusers.utils import load_image
|
39 |
+
|
40 |
+
# Set device
|
41 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
42 |
+
|
43 |
+
# Load the models
|
44 |
+
controlnet = ControlNetModel.from_pretrained("controlnet_model_path", torch_dtype=torch.float32).to(device)
|
45 |
+
pipe = StableDiffusionControlNetPipeline.from_pretrained("base_model_path", controlnet=controlnet, torch_dtype=torch.float32).to(device)
|
46 |
+
|
47 |
+
# Load your simplified image
|
48 |
+
simplified_image = load_image("path_to_simplified_image.png")
|
49 |
+
|
50 |
+
# Define the text prompt
|
51 |
+
prompt = "A photorealistic image of a sunset over the ocean."
|
52 |
+
|
53 |
+
# Generate realistic image
|
54 |
+
generator = torch.manual_seed(random.randint(0, 100000))
|
55 |
+
generated_image = pipe(prompt, num_inference_steps=50, generator=generator, image=simplified_image).images[0]
|
56 |
+
|
57 |
+
# Save the generated image
|
58 |
+
generated_image.save("generated_image.png")
|
59 |
+
‘’‘
|
60 |
+
|
61 |
## License
|
62 |
|
63 |
The source code of this repository is released under the Apache License 2.0. The model license and dataset license are listed on their corresponding webpages.
|