Akash473 commited on
Commit
c9fe872
·
1 Parent(s): 81864d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -6
app.py CHANGED
@@ -146,15 +146,15 @@ def process_image_menHair(background_image, x, y, placeholder_image_path, x_coor
146
  # Function to generate Funko figurines
147
  def generate_funko_figurines(input_image, background_image_paths):
148
  # Detect and classify beard style
149
- beard_classifier = BeardClassifier('path_to_beard_style_model', ['Bandholz', 'CleanShave', 'FullGoatee', 'Moustache', 'RapIndustryStandards', 'ShortBeard'])
150
  predicted_style_label = beard_classifier.classify_beard(input_image)
151
 
152
  # Detect and classify beard color
153
- beard_color_classifier = BeardColorClassifier('path_to_beard_color_model', ['Black', 'DarkBrown', 'Ginger', 'LightBrown', 'SaltAndPepper', 'White'])
154
  predicted_color_label = beard_color_classifier.classify_beard_color(input_image)
155
 
156
  # Classify hairstyle
157
- hair_style_classifier = HairStyleClassifier('path_to_hairstyle_model', ['Afro', 'Bald', 'Puff', 'Spike'])
158
  predicted_hairStyle_label = hair_style_classifier.classify_hair(input_image)
159
 
160
  # Process background images and apply beard style and color along with hair style and color
@@ -164,18 +164,63 @@ def generate_funko_figurines(input_image, background_image_paths):
164
  background_image = Image.open(background_image_path)
165
  x_coordinate = 90
166
  y_coordinate = 50
167
- dummy_eye(background_image, 245, 345, 'path_to_eye_image', x_coordinate, y_coordinate)
168
 
169
  if predicted_style_label == 'Bandholz':
170
- process_image_Beard(background_image, 320, 'path_to_beard_image', 50, 142)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  # Add other conditions for different beard styles
173
 
174
  # Overlay hairstyle
175
  if predicted_hairStyle_label == 'Afro':
176
  process_image_menHair(background_image, 336, 420, 'path_to_hairstyle_image', 41, 76)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
 
178
- # Add other conditions for different hairstyles
179
 
180
  # Convert the resulting image to base64
181
  buffered = BytesIO()
 
146
  # Function to generate Funko figurines
147
  def generate_funko_figurines(input_image, background_image_paths):
148
  # Detect and classify beard style
149
+ beard_classifier = BeardClassifier('Data/FunkoSavedModels/FunkoResnet18BeardStyle.pt', ['Bandholz', 'CleanShave', 'FullGoatee', 'Moustache', 'RapIndustryStandards', 'ShortBeard'])
150
  predicted_style_label = beard_classifier.classify_beard(input_image)
151
 
152
  # Detect and classify beard color
153
+ beard_color_classifier = BeardColorClassifier('Data/FunkoSavedModels/FunkoResnet18Color.pt', ['Black', 'DarkBrown', 'Ginger', 'LightBrown', 'SaltAndPepper', 'White'])
154
  predicted_color_label = beard_color_classifier.classify_beard_color(input_image)
155
 
156
  # Classify hairstyle
157
+ hair_style_classifier = HairStyleClassifier('Data/FunkoSavedModels/FunkoResnet18HairStyle.pt', ['Afro', 'Bald', 'Puff', 'Spike'])
158
  predicted_hairStyle_label = hair_style_classifier.classify_hair(input_image)
159
 
160
  # Process background images and apply beard style and color along with hair style and color
 
164
  background_image = Image.open(background_image_path)
165
  x_coordinate = 90
166
  y_coordinate = 50
167
+ dummy_eye(background_image, 245, 345, 'Data/AdobeColorFunko/EyezBrowz/MaleEye.png', x_coordinate, y_coordinate)
168
 
169
  if predicted_style_label == 'Bandholz':
170
+ process_image_Beard(background_image, 320,
171
+ "Data/AdobeColorFunko/Beard/Bandholz/{predicted_color_label}.png",
172
+ 50, 142)
173
+
174
+ if predicted_style_label == 'ShortBeard':
175
+ process_image_Beard(background_image, 300,
176
+ "Data/AdobeColorFunko/Beard/ShortBeard/{predicted_color_label}.png",
177
+ 62, 118)
178
+
179
+ if predicted_style_label == 'FullGoatee':
180
+ process_image_Beard(background_image, 230,
181
+ "Data/AdobeColorFunko/Beard/Goatee/{predicted_color_label}.png",
182
+ 96, 168)
183
+
184
+ if predicted_style_label == 'RapIndustryStandards':
185
+ process_image_Beard(background_image, 290,
186
+ "Data/AdobeColorFunko/Beard/RapIndustry/{predicted_color_label}.png",
187
+ 67, 120)
188
+
189
+ if predicted_style_label == 'Moustache':
190
+ process_image_Beard(background_image, 220,
191
+ "Data/AdobeColorFunko/Beard/Moustache/{predicted_color_label}.png",
192
+ 100, 160)
193
+
194
+ if predicted_style_label == 'CleanShave':
195
+ process_image_Beard(background_image, 220,
196
+ "Data/AdobeColorFunko/Beard/CleanShave/{predicted_color_label}.png",
197
+ 100, 160)
198
 
199
  # Add other conditions for different beard styles
200
 
201
  # Overlay hairstyle
202
  if predicted_hairStyle_label == 'Afro':
203
  process_image_menHair(background_image, 336, 420, 'path_to_hairstyle_image', 41, 76)
204
+ if predicted_hairStyle_label == 'Afro':
205
+ process_image_menHair(background_image, 336, 420,
206
+ "Data/AdobeColorFunko/MenHairstyle/Afro/{predicted_color_label}.png",
207
+ 41, 76)
208
+
209
+ if predicted_hairStyle_label == 'Puff':
210
+ process_image_menHair(background_image, 320, 420,
211
+ "Data/AdobeColorFunko/MenHairstyle/Puff/{predicted_color_label}.png",
212
+ 50, 68)
213
+
214
+ if predicted_hairStyle_label == 'Spike':
215
+ process_image_menHair(background_image, 310, 420,
216
+ "Data/AdobeColorFunko/MenHairstyle/Spike/{predicted_color_label}.png",
217
+ 50, 70)
218
+
219
+ if predicted_hairStyle_label == 'Bald':
220
+ process_image_menHair(background_image, 310, 420,
221
+ "Data/AdobeColorFunko/MenHairstyle/Bald/{predicted_color_label}.png",
222
+ 67, 120)
223
 
 
224
 
225
  # Convert the resulting image to base64
226
  buffered = BytesIO()