AP123 commited on
Commit
10ca3e2
1 Parent(s): a68f6ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -42,10 +42,14 @@ def transform_image(face_image):
42
  processed_face_image = Image.fromarray(face_image)
43
  else:
44
  raise ValueError("Unsupported image format")
45
-
46
- # Resize the face image and convert to tensor
 
 
 
 
47
  processed_face_image = processed_face_image.resize(desired_size, Image.LANCZOS)
48
- processed_face_tensor = transforms.ToTensor()(processed_face_image).unsqueeze(0).to("cuda")
49
 
50
  # Load the style image from the local path, resize it and convert to tensor
51
  style_image_path = "examples/soyjak2.jpg" # Ensure this path is correct
 
42
  processed_face_image = Image.fromarray(face_image)
43
  else:
44
  raise ValueError("Unsupported image format")
45
+
46
+ # Convert the processed face image to RGB format if it has only 1 channel
47
+ if processed_face_image.mode == 'L':
48
+ processed_face_image = processed_face_image.convert('RGB')
49
+
50
+ # Resize the face image
51
  processed_face_image = processed_face_image.resize(desired_size, Image.LANCZOS)
52
+
53
 
54
  # Load the style image from the local path, resize it and convert to tensor
55
  style_image_path = "examples/soyjak2.jpg" # Ensure this path is correct