Spaces:
Build error
Build error
Create Dockerfile
Browse files- Dockerfile +26 -0
Dockerfile
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from diffusers import StableDiffusionImg2ImgPipeline
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import torch
|
| 4 |
+
import face_recognition
|
| 5 |
+
import numpy as np
|
| 6 |
+
|
| 7 |
+
# Load the face image you want to "generate look-alikes" for
|
| 8 |
+
target_image = Image.open("target_face.jpg").convert("RGB")
|
| 9 |
+
|
| 10 |
+
# Load Stable Diffusion (use a model fine-tuned for faces!)
|
| 11 |
+
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
|
| 12 |
+
"SG161222/Realistic_Vision_V5.1_noVAE",
|
| 13 |
+
torch_dtype=torch.float16
|
| 14 |
+
).to("cuda")
|
| 15 |
+
|
| 16 |
+
# Generate a look-alike image
|
| 17 |
+
prompt = "portrait photo of a person with similar facial features"
|
| 18 |
+
generator = torch.manual_seed(42)
|
| 19 |
+
|
| 20 |
+
output = pipe(
|
| 21 |
+
prompt=prompt,
|
| 22 |
+
image=target_image,
|
| 23 |
+
strength=0.7,
|
| 24 |
+
guidance_scale=7.5,
|
| 25 |
+
num_inference_steps=30,
|
| 26 |
+
generator
|