Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -232,7 +232,7 @@ class WomenHairColorClassifier:
|
|
| 232 |
# Function to classify beard style
|
| 233 |
class BeardClassifier:
|
| 234 |
def __init__(self, model_path, class_names):
|
| 235 |
-
self.model = torch.hub.load('pytorch/vision', '
|
| 236 |
num_ftrs = self.model.fc.in_features
|
| 237 |
self.model.fc = torch.nn.Linear(num_ftrs, len(class_names))
|
| 238 |
self.load_model(model_path)
|
|
@@ -282,7 +282,7 @@ class BeardClassifier:
|
|
| 282 |
# Function to classify beard color
|
| 283 |
class BeardColorClassifier:
|
| 284 |
def __init__(self, model_path, class_names):
|
| 285 |
-
self.model = torch.hub.load('pytorch/vision', '
|
| 286 |
num_ftrs = self.model.fc.in_features
|
| 287 |
self.model.fc = torch.nn.Linear(num_ftrs, len(class_names))
|
| 288 |
self.load_model(model_path)
|
|
@@ -333,7 +333,7 @@ class BeardColorClassifier:
|
|
| 333 |
# Function to classify hairstyle
|
| 334 |
class HairStyleClassifier:
|
| 335 |
def __init__(self, model_path, class_names):
|
| 336 |
-
self.model = torch.hub.load('pytorch/vision', '
|
| 337 |
num_ftrs = self.model.fc.in_features
|
| 338 |
self.model.fc = torch.nn.Linear(num_ftrs, len(class_names))
|
| 339 |
self.load_model(model_path)
|
|
@@ -381,7 +381,7 @@ class HairStyleClassifier:
|
|
| 381 |
|
| 382 |
class MenHairColorClassifier:
|
| 383 |
def __init__(self, model_path, class_names):
|
| 384 |
-
self.model = torch.hub.load('pytorch/vision', '
|
| 385 |
num_ftrs = self.model.fc.in_features
|
| 386 |
self.model.fc = torch.nn.Linear(num_ftrs, len(class_names))
|
| 387 |
self.load_model(model_path)
|
|
@@ -521,19 +521,19 @@ def generate_funko_figurines(input_image):
|
|
| 521 |
y_coordinate = 50
|
| 522 |
dummy_eye(background_image, x, y, placeholder_image_path, x_coordinate, y_coordinate)
|
| 523 |
# Detect and classify beard style
|
| 524 |
-
beard_classifier = BeardClassifier('Data/FunkoSavedModels/
|
| 525 |
predicted_style_label = beard_classifier.classify_beard(input_image)
|
| 526 |
|
| 527 |
# Detect and classify beard color
|
| 528 |
-
beard_color_classifier = BeardColorClassifier('Data/FunkoSavedModels/
|
| 529 |
predicted_color_label = beard_color_classifier.classify_beard_color(input_image)
|
| 530 |
|
| 531 |
# Classify hairstyle
|
| 532 |
-
hair_style_classifier = HairStyleClassifier('Data/FunkoSavedModels/
|
| 533 |
predicted_hairStyle_label = hair_style_classifier.classify_hair(input_image)
|
| 534 |
|
| 535 |
#classify menHairColor
|
| 536 |
-
menhair_color_classifier = MenHairColorClassifier('Data/FunkoSavedModels/
|
| 537 |
predicted_menhairColor_label = menhair_color_classifier.classify_menHair_color(input_image)
|
| 538 |
|
| 539 |
if predicted_style_label == 'Bandholz':
|
|
|
|
| 232 |
# Function to classify beard style
|
| 233 |
class BeardClassifier:
|
| 234 |
def __init__(self, model_path, class_names):
|
| 235 |
+
self.model = torch.hub.load('pytorch/vision', 'resnet50', pretrained=False)
|
| 236 |
num_ftrs = self.model.fc.in_features
|
| 237 |
self.model.fc = torch.nn.Linear(num_ftrs, len(class_names))
|
| 238 |
self.load_model(model_path)
|
|
|
|
| 282 |
# Function to classify beard color
|
| 283 |
class BeardColorClassifier:
|
| 284 |
def __init__(self, model_path, class_names):
|
| 285 |
+
self.model = torch.hub.load('pytorch/vision', 'resnet50', pretrained=False)
|
| 286 |
num_ftrs = self.model.fc.in_features
|
| 287 |
self.model.fc = torch.nn.Linear(num_ftrs, len(class_names))
|
| 288 |
self.load_model(model_path)
|
|
|
|
| 333 |
# Function to classify hairstyle
|
| 334 |
class HairStyleClassifier:
|
| 335 |
def __init__(self, model_path, class_names):
|
| 336 |
+
self.model = torch.hub.load('pytorch/vision', 'resnet50', pretrained=False)
|
| 337 |
num_ftrs = self.model.fc.in_features
|
| 338 |
self.model.fc = torch.nn.Linear(num_ftrs, len(class_names))
|
| 339 |
self.load_model(model_path)
|
|
|
|
| 381 |
|
| 382 |
class MenHairColorClassifier:
|
| 383 |
def __init__(self, model_path, class_names):
|
| 384 |
+
self.model = torch.hub.load('pytorch/vision', 'resnet50', pretrained=False)
|
| 385 |
num_ftrs = self.model.fc.in_features
|
| 386 |
self.model.fc = torch.nn.Linear(num_ftrs, len(class_names))
|
| 387 |
self.load_model(model_path)
|
|
|
|
| 521 |
y_coordinate = 50
|
| 522 |
dummy_eye(background_image, x, y, placeholder_image_path, x_coordinate, y_coordinate)
|
| 523 |
# Detect and classify beard style
|
| 524 |
+
beard_classifier = BeardClassifier('Data/FunkoSavedModels/FunkoResnet50BeardStyle.pt', ['Bandholz', 'CleanShave', 'FullGoatee', 'Moustache', 'RapIndustryStandards', 'ShortBeard'])
|
| 525 |
predicted_style_label = beard_classifier.classify_beard(input_image)
|
| 526 |
|
| 527 |
# Detect and classify beard color
|
| 528 |
+
beard_color_classifier = BeardColorClassifier('Data/FunkoSavedModels/FunkoResnet50BeardColor.pt', ['Black', 'DarkBrown', 'Ginger', 'LightBrown', 'SaltAndPepper', 'White'])
|
| 529 |
predicted_color_label = beard_color_classifier.classify_beard_color(input_image)
|
| 530 |
|
| 531 |
# Classify hairstyle
|
| 532 |
+
hair_style_classifier = HairStyleClassifier('Data/FunkoSavedModels/FunkoResnet50MenHairStyle.pt', ['Afro', 'Bald', 'Puff', 'Spike'])
|
| 533 |
predicted_hairStyle_label = hair_style_classifier.classify_hair(input_image)
|
| 534 |
|
| 535 |
#classify menHairColor
|
| 536 |
+
menhair_color_classifier = MenHairColorClassifier('Data/FunkoSavedModels/FunkoResnet50MenHairColor.pt', ['Black', 'DarkBrown', 'Ginger', 'LightBrown', 'SaltAndPepper', 'White'])
|
| 537 |
predicted_menhairColor_label = menhair_color_classifier.classify_menHair_color(input_image)
|
| 538 |
|
| 539 |
if predicted_style_label == 'Bandholz':
|