Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -43,22 +43,21 @@ def transform_image(face_image):
|
|
43 |
else:
|
44 |
raise ValueError("Unsupported image format")
|
45 |
|
46 |
-
#
|
47 |
-
|
48 |
-
processed_face_image = processed_face_image.convert('RGB')
|
49 |
|
50 |
# Resize the face image to 1024x1024
|
51 |
processed_face_image = processed_face_image.resize(desired_size, Image.LANCZOS)
|
52 |
|
53 |
# Load the style image from the local path, resize it to 1024x1024, and convert to tensor
|
54 |
style_image_path = "examples/soyjak2.jpg" # Ensure this path is correct
|
55 |
-
style_image = Image.open(style_image_path).resize(desired_size, Image.LANCZOS)
|
56 |
style_image_tensor = transforms.ToTensor()(style_image).unsqueeze(0).to("cuda")
|
57 |
|
58 |
# Perform the transformation using the configured pipeline
|
59 |
image = pipeline(
|
60 |
prompt="soyjak",
|
61 |
-
ip_adapter_image=[style_image_tensor, processed_face_image], # Ensure these are tensors
|
62 |
negative_prompt="monochrome, lowres, bad anatomy, worst quality, low quality",
|
63 |
num_inference_steps=30,
|
64 |
generator=generator,
|
|
|
43 |
else:
|
44 |
raise ValueError("Unsupported image format")
|
45 |
|
46 |
+
# Ensure the processed face image is in RGB format
|
47 |
+
processed_face_image = processed_face_image.convert('RGB')
|
|
|
48 |
|
49 |
# Resize the face image to 1024x1024
|
50 |
processed_face_image = processed_face_image.resize(desired_size, Image.LANCZOS)
|
51 |
|
52 |
# Load the style image from the local path, resize it to 1024x1024, and convert to tensor
|
53 |
style_image_path = "examples/soyjak2.jpg" # Ensure this path is correct
|
54 |
+
style_image = Image.open(style_image_path).resize(desired_size, Image.LANCZOS).convert('RGB')
|
55 |
style_image_tensor = transforms.ToTensor()(style_image).unsqueeze(0).to("cuda")
|
56 |
|
57 |
# Perform the transformation using the configured pipeline
|
58 |
image = pipeline(
|
59 |
prompt="soyjak",
|
60 |
+
ip_adapter_image=[style_image_tensor, transforms.ToTensor()(processed_face_image).unsqueeze(0).to("cuda")], # Ensure these are tensors
|
61 |
negative_prompt="monochrome, lowres, bad anatomy, worst quality, low quality",
|
62 |
num_inference_steps=30,
|
63 |
generator=generator,
|