dzmu commited on
Commit
8f72932
·
verified ·
1 Parent(s): 5b98df5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -147,17 +147,32 @@ def get_top_clip_clothing(probs, n=1):
147
  return top_items_with_probs
148
 
149
  # --- Core Logic ---
150
- def analyze_outfit(input_img: Image.Image):
151
- if isinstance(input_img, str): # If receiving filepath from API
152
- input_img = Image.open(input_img)
153
 
154
- if isinstance(input_img, np.ndarray): # If receiving numpy array
155
- input_img = Image.fromarray(input_img.astype('uint8'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  if input_img is None:
157
  return ("<p style='color: #FF5555; text-align: center;'>Please upload an image.</p>",
158
  None, "Error: No image provided.")
159
-
160
- img = input_img.convert("RGB").copy() # Ensure image is in RGB
161
  #def analyze_outfit(image):
162
  #if image is None:
163
  #return ("<p style='color: #FF5555; text-align: center;'>Please upload an image.</p>", None, "Error: No image provided.")
 
147
  return top_items_with_probs
148
 
149
  # --- Core Logic ---
150
+ #def analyze_outfit(input_img: Image.Image):
151
+ #if isinstance(input_img, str): # If receiving filepath from API
152
+ #input_img = Image.open(input_img)
153
 
154
+ # if isinstance(input_img, np.ndarray): # If receiving numpy array
155
+ #input_img = Image.fromarray(input_img.astype('uint8'))
156
+ #if input_img is None:
157
+ #return ("<p style='color: #FF5555; text-align: center;'>Please upload an image.</p>",
158
+ #None, "Error: No image provided.")
159
+
160
+ #img = input_img.convert("RGB").copy() # Ensure image is in RGB
161
+ def analyze_outfit(input_img):
162
+ # Add this filepath handling first
163
+ if isinstance(input_img, str): # If receiving filepath from API
164
+ try:
165
+ input_img = Image.open(input_img)
166
+ except Exception as e:
167
+ return (f"<p style='color: #FF5555;'>Error loading image: {e}</p>",
168
+ None, "Image loading error")
169
+
170
+ # Rest of your existing code continues unchanged...
171
  if input_img is None:
172
  return ("<p style='color: #FF5555; text-align: center;'>Please upload an image.</p>",
173
  None, "Error: No image provided.")
174
+
175
+ img = input_img.convert("RGB").copy()
176
  #def analyze_outfit(image):
177
  #if image is None:
178
  #return ("<p style='color: #FF5555; text-align: center;'>Please upload an image.</p>", None, "Error: No image provided.")