Create .sample
Browse files
.sample
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import StableDiffusionImg2ImgPipeline
|
2 |
+
import torch
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
# Load the pipeline
|
6 |
+
pipe = StableDiffusionImg2ImgPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
|
7 |
+
pipe = pipe.to("cuda") # Use "cuda" if you have a GPU; otherwise, use "cpu"
|
8 |
+
|
9 |
+
# Load the input image
|
10 |
+
init_image = Image.open("path/to/your/image.jpg").convert("RGB")
|
11 |
+
|
12 |
+
# Define the prompt for transformation
|
13 |
+
prompt = "A futuristic cityscape at sunset, with neon lights and high-tech buildings"
|
14 |
+
|
15 |
+
# Run the image-to-image pipeline
|
16 |
+
output = pipe(prompt=prompt, init_image=init_image, strength=0.75, guidance_scale=7.5)
|
17 |
+
|
18 |
+
# Save the result
|
19 |
+
output.images[0].save("path/to/save/transformed_image.jpg")
|