Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -138,7 +138,14 @@ class HairStyleClassifier:
|
|
| 138 |
predicted_class = torch.argmax(probabilities).item()
|
| 139 |
predicted_label = self.class_names[predicted_class]
|
| 140 |
return predicted_label
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
# Function to overlay a hairstyle on a background image
|
| 143 |
def process_image_menHair(background_image, x, y, placeholder_image_path, x_coordinate, y_coordinate):
|
| 144 |
placeholder_image = Image.open(placeholder_image_path)
|
|
@@ -173,6 +180,7 @@ def generate_funko_figurines(input_image):
|
|
| 173 |
background_image = Image.open(background_image_path)
|
| 174 |
x_coordinate = 90
|
| 175 |
y_coordinate = 50
|
|
|
|
| 176 |
dummy_eye(background_image, 245, 345, 'Data/AdobeColorFunko/EyezBrowz/MaleEye.png', x_coordinate, y_coordinate)
|
| 177 |
|
| 178 |
if predicted_style_label == 'Bandholz':
|
|
|
|
| 138 |
predicted_class = torch.argmax(probabilities).item()
|
| 139 |
predicted_label = self.class_names[predicted_class]
|
| 140 |
return predicted_label
|
| 141 |
+
def add_eyebrow(background_image, x_coordinate, y_coordinate, eyebrow_image_path):
|
| 142 |
+
eyebrow_image = Image.open(eyebrow_image_path)
|
| 143 |
+
target_size = (200, 200) # Adjust the size as needed
|
| 144 |
+
eyebrow_image = eyebrow_image.resize(target_size, Image.LANCZOS)
|
| 145 |
+
region_box = (x_coordinate, y_coordinate, x_coordinate + eyebrow_image.width, y_coordinate + eyebrow_image.height)
|
| 146 |
+
eyebrow_mask = eyebrow_image.split()[3] if eyebrow_image.mode == 'RGBA' else None
|
| 147 |
+
background_image.paste(eyebrow_image, region_box, mask=eyebrow_mask)
|
| 148 |
+
|
| 149 |
# Function to overlay a hairstyle on a background image
|
| 150 |
def process_image_menHair(background_image, x, y, placeholder_image_path, x_coordinate, y_coordinate):
|
| 151 |
placeholder_image = Image.open(placeholder_image_path)
|
|
|
|
| 180 |
background_image = Image.open(background_image_path)
|
| 181 |
x_coordinate = 90
|
| 182 |
y_coordinate = 50
|
| 183 |
+
add_eyebrow(background_image, 115, 80, "/content/drive/MyDrive/AdobeColorFunko/EyezBrowz/Eyebrow.png")
|
| 184 |
dummy_eye(background_image, 245, 345, 'Data/AdobeColorFunko/EyezBrowz/MaleEye.png', x_coordinate, y_coordinate)
|
| 185 |
|
| 186 |
if predicted_style_label == 'Bandholz':
|