RICHERGIRL commited on
Commit
b44141d
·
verified ·
1 Parent(s): fb240fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -20
app.py CHANGED
@@ -6,26 +6,6 @@ from sklearn.ensemble import RandomForestClassifier
6
  from sklearn.preprocessing import LabelEncoder
7
  from utils import extract_features
8
 
9
- def initialize_fallback_model():
10
- """Creates and trains a simple fallback model"""
11
- print("Initializing fallback model...")
12
-
13
- # Simple training data
14
- X = np.array([[0,0,0], [1,1,1], [2,2,2]]) # Dummy encoded features
15
- y = np.array([0, 1, 0]) # Dummy target
16
-
17
- model = RandomForestClassifier(n_estimators=10)
18
- model.fit(X, y)
19
-
20
- encoders = {
21
- 'face_shape': LabelEncoder().fit(['Oval', 'Round', 'Square']),
22
- 'skin_tone': LabelEncoder().fit(['Fair', 'Medium', 'Dark']),
23
- 'face_size': LabelEncoder().fit(['Small', 'Medium', 'Large']),
24
- 'mask_style': LabelEncoder().fit(['StyleA', 'StyleB', 'StyleC']) # Added mask_style
25
- }
26
-
27
- return model, encoders
28
-
29
  def safe_load_model():
30
  """Safely loads model files with comprehensive fallback"""
31
  try:
@@ -77,5 +57,25 @@ demo = gr.Interface(
77
  description="Upload a photo to get a personalized mask recommendation!",
78
  )
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  if __name__ == "__main__":
81
  demo.launch()
 
6
  from sklearn.preprocessing import LabelEncoder
7
  from utils import extract_features
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def safe_load_model():
10
  """Safely loads model files with comprehensive fallback"""
11
  try:
 
57
  description="Upload a photo to get a personalized mask recommendation!",
58
  )
59
 
60
+ def initialize_fallback_model():
61
+ """Creates and trains a simple fallback model"""
62
+ print("Initializing fallback model...")
63
+
64
+ # Simple training data
65
+ X = np.array([[0,0,0], [1,1,1], [2,2,2]]) # Dummy encoded features
66
+ y = np.array([0, 1, 0]) # Dummy target
67
+
68
+ model = RandomForestClassifier(n_estimators=10)
69
+ model.fit(X, y)
70
+
71
+ encoders = {
72
+ 'face_shape': LabelEncoder().fit(['Oval', 'Round', 'Square']),
73
+ 'skin_tone': LabelEncoder().fit(['Fair', 'Medium', 'Dark']),
74
+ 'face_size': LabelEncoder().fit(['Small', 'Medium', 'Large']),
75
+ 'mask_style': LabelEncoder().fit(['StyleA', 'StyleB', 'StyleC']) # Added mask_style
76
+ }
77
+
78
+ return model, encoders
79
+
80
  if __name__ == "__main__":
81
  demo.launch()