frncscp commited on
Commit
e07bf57
1 Parent(s): 0bb248f

Update pages/Entorno de Ejecución.py

Browse files
Files changed (1) hide show
  1. pages/Entorno de Ejecución.py +7 -17
pages/Entorno de Ejecución.py CHANGED
@@ -45,7 +45,6 @@ with col_a:
45
  ultra_flag = False
46
  if ultra_button:
47
  ultra_flag = True
48
-
49
 
50
  # Create a dropdown menu to select the model
51
  model_choice = st.multiselect("Seleccione uno o varios modelos de clasificación", model_dict.keys())
@@ -67,36 +66,27 @@ with col_a:
67
  y_gorrito += tf.cast(model(tf.expand_dims(img/255., 0)), dtype=tf.float32)
68
  return y_gorrito / len(model_list)
69
 
70
- #for model in model_choice:
71
- #selected_models.append(model)
72
-
73
-
74
  # Set the image dimensions
75
  IMAGE_WIDTH = IMAGE_HEIGHT = 224
76
 
77
  uploaded_file = st.file_uploader(label = '',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
78
-
 
79
  with col_b:
80
  if st.button('¿Hay un patacón en la imagen?'):
81
  if len(selected_models) > 0 and ultra_flag:
82
  st.write('Debe elegir un solo método: Ultra-Patacotrón o selección múltiple.')
83
  elif uploaded_file is not None:
84
- # Load the image and resize it to the required dimensions
85
- #img = tf.io.read_file(uploaded_file)
86
  raw_img = tf.image.decode_image(uploaded_file.read(), channels=3)
87
  img = tf.image.resize(raw_img,(IMAGE_WIDTH, IMAGE_HEIGHT))
88
-
89
- #img = np.frombuffer(uploaded_file.read(), np.uint8)
90
- #img = cv2.imdecode(img, cv2.IMREAD_COLOR)
91
- #raw_img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
92
- #img = cv2.resize(img, (IMAGE_WIDTH, IMAGE_HEIGHT))
93
-
94
- # Convert the image to RGB and preprocess it for the model
95
- #img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
96
  # Pass the image to the model and get the prediction
97
  if ultra_flag:
98
  with st.spinner('Cargando ultra-predicción...'):
99
- ultraptctrn = [load_model(model_dict[model]) for model in ultraversions]
 
 
100
  y_gorrito = predict(ultraptctrn, img)
101
  else:
102
  with st.spinner('Cargando predicción...'):
 
45
  ultra_flag = False
46
  if ultra_button:
47
  ultra_flag = True
 
48
 
49
  # Create a dropdown menu to select the model
50
  model_choice = st.multiselect("Seleccione uno o varios modelos de clasificación", model_dict.keys())
 
66
  y_gorrito += tf.cast(model(tf.expand_dims(img/255., 0)), dtype=tf.float32)
67
  return y_gorrito / len(model_list)
68
 
 
 
 
 
69
  # Set the image dimensions
70
  IMAGE_WIDTH = IMAGE_HEIGHT = 224
71
 
72
  uploaded_file = st.file_uploader(label = '',type= ['jpg','png', 'jpeg', 'jfif', 'webp', 'heic'])
73
+ executed = False
74
+
75
  with col_b:
76
  if st.button('¿Hay un patacón en la imagen?'):
77
  if len(selected_models) > 0 and ultra_flag:
78
  st.write('Debe elegir un solo método: Ultra-Patacotrón o selección múltiple.')
79
  elif uploaded_file is not None:
80
+
 
81
  raw_img = tf.image.decode_image(uploaded_file.read(), channels=3)
82
  img = tf.image.resize(raw_img,(IMAGE_WIDTH, IMAGE_HEIGHT))
83
+
 
 
 
 
 
 
 
84
  # Pass the image to the model and get the prediction
85
  if ultra_flag:
86
  with st.spinner('Cargando ultra-predicción...'):
87
+ if not executed:
88
+ ultraptctrn = [load_model(model_dict[model]) for model in ultraversions]
89
+ executed = True
90
  y_gorrito = predict(ultraptctrn, img)
91
  else:
92
  with st.spinner('Cargando predicción...'):