Daniel00611 commited on
Commit
1a61e89
verified
1 Parent(s): 8f728a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -29,10 +29,13 @@ model_path = hf_hub_download(repo_id="Daniel00611/InceptionV3_72", filename="Inc
29
  model = load_model(model_path)
30
 
31
  def preprocess_image(img, target_size=(299, 299)):
32
- img = img.resize(target_size) # Redimensionar la imagen
33
- img_array = np.array(img) # Convertir a array de NumPy
34
- img_array = np.expand_dims(img_array, axis=0) # Expandir dimensi贸n para lote
35
- img_array = preprocess_input(img_array) # Preprocesar la imagen
 
 
 
36
  return img_array
37
 
38
  # Modelo para recibir la imagen en formato Base64
 
29
  model = load_model(model_path)
30
 
31
  def preprocess_image(img, target_size=(299, 299)):
32
+ # Convertir a RGB si la imagen no est谩 en ese formato
33
+ if img.mode != "RGB":
34
+ img = img.convert("RGB")
35
+ img = img.resize(target_size)
36
+ img_array = img_to_array(img)
37
+ img_array = np.expand_dims(img_array, axis=0)
38
+ img_array = preprocess_input(img_array)
39
  return img_array
40
 
41
  # Modelo para recibir la imagen en formato Base64