marcossalinas commited on
Commit
adb3499
·
1 Parent(s): 26dd3ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -1,6 +1,26 @@
 
1
  import cv2
 
2
  import gradio as gr
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  def saludar(nombre):
5
  return f'Hola, { nombre }'
6
 
 
1
+ import numpy as np
2
  import cv2
3
+ import keras
4
  import gradio as gr
5
 
6
+ SIDE_IMG = 320
7
+
8
+ LIMIT_FOR_DISEASE = 0.8
9
+
10
+ def remove_borders_color(image):
11
+ image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
12
+ image_gray[image_gray < BLACK_TOLERANCE] = 0
13
+ y_nonzero, x_nonzero = np.nonzero(image_gray)
14
+ return image[np.min(y_nonzero):np.max(y_nonzero), np.min(x_nonzero): np.max(x_nonzero), ]
15
+
16
+ def resize_image_square(image, side):
17
+ return cv2.resize(image, (side, side), interpolation = cv2.INTER_LINEAR)
18
+
19
+ def get_image(path):
20
+ image = cv2.imread(path)
21
+ return resize_image_square(remove_borders_color(image), SIDE_IMG)
22
+
23
+
24
  def saludar(nombre):
25
  return f'Hola, { nombre }'
26