alejo2315 commited on
Commit
3bd86a9
1 Parent(s): e996c41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -101,12 +101,12 @@ if archivo_imagen is not None:
101
 
102
  ## Ingresamos el array de NumPy al modelo
103
  mask=model.predict(np.expand_dims(np.expand_dims(img_P,axis=-1),axis=0))
104
- mask=np.resize(mask,(224,224))
105
- predicted=np.array(mask>0.5).astype(int)
106
- img_seg_1=img_cv*mask
 
107
 
108
  ## Regresamos la imagen a su forma original y agregamos las máscaras de la segmentación
109
- """
110
  predicted = cv2.resize(predicted, (img.shape[1], img.shape[0]), interpolation=cv2.INTER_LANCZOS4)
111
  mask = np.uint8(predicted * 255) #
112
  _, mask = cv2.threshold(mask, thresh=0, maxval=255, type=cv2.THRESH_BINARY + cv2.THRESH_OTSU)
@@ -115,8 +115,7 @@ if archivo_imagen is not None:
115
  mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel, iterations=1)
116
  cnts, hieararch = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
117
  output = cv2.drawContours(convertir_one_channel(img), cnts, -1, (255, 0, 0), 3)
118
- """
119
- output=img_seg_1
120
  ## Si obtuvimos exitosamente un resultadod entonces lo mostramos en la interfaz
121
  if output is not None:
122
  st.subheader("Segmentación:")
 
101
 
102
  ## Ingresamos el array de NumPy al modelo
103
  mask=model.predict(np.expand_dims(np.expand_dims(img_P,axis=-1),axis=0))
104
+ #mask=np.resize(mask,(224,224))
105
+ #predicted=np.array(mask>0.5).astype(int)
106
+ #img_seg_1=img_cv*mask
107
+ predicted = mask[0]
108
 
109
  ## Regresamos la imagen a su forma original y agregamos las máscaras de la segmentación
 
110
  predicted = cv2.resize(predicted, (img.shape[1], img.shape[0]), interpolation=cv2.INTER_LANCZOS4)
111
  mask = np.uint8(predicted * 255) #
112
  _, mask = cv2.threshold(mask, thresh=0, maxval=255, type=cv2.THRESH_BINARY + cv2.THRESH_OTSU)
 
115
  mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel, iterations=1)
116
  cnts, hieararch = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
117
  output = cv2.drawContours(convertir_one_channel(img), cnts, -1, (255, 0, 0), 3)
118
+ #output=img_seg_1
 
119
  ## Si obtuvimos exitosamente un resultadod entonces lo mostramos en la interfaz
120
  if output is not None:
121
  st.subheader("Segmentación:")