emilios commited on
Commit
efe3f24
·
verified ·
1 Parent(s): 698bdd0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -2,18 +2,25 @@ import gradio
2
 
3
 
4
  import matplotlib.pyplot as plt
5
- from skimage import morphology
 
6
  import numpy as np
7
  import skimage
8
 
9
 
10
  def inference(img):
11
- grayscale = skimage.color.rgb2gray(img)
12
  #binarized = np.where(grayscale>0.1, 1, 0)
13
  #processed = morphology.remove_small_objects(grayscale.astype(bool), min_size=33, connectivity=4).astype(int)
14
- processed = morphology.remove_small_objects(grayscale , min_size=2, connectivity=4)
 
 
 
15
  #out = processed
16
 
 
 
 
17
  # black out pixels
18
  #mask_x, mask_y = np.where(processed == 0)
19
  #img[mask_x, mask_y, :3] = 0
@@ -22,7 +29,7 @@ def inference(img):
22
 
23
 
24
  #return img
25
- return processed
26
 
27
  # For information on Interfaces, head to https://gradio.app/docs/
28
  # For user guides, head to https://gradio.app/guides/
 
2
 
3
 
4
  import matplotlib.pyplot as plt
5
+ from skimage import morphology,measure
6
+ from skimage.measure import label
7
  import numpy as np
8
  import skimage
9
 
10
 
11
  def inference(img):
12
+ out = skimage.color.rgb2gray(img) # gray
13
  #binarized = np.where(grayscale>0.1, 1, 0)
14
  #processed = morphology.remove_small_objects(grayscale.astype(bool), min_size=33, connectivity=4).astype(int)
15
+
16
+ #out = morphology.remove_small_objects(out , min_size=2, connectivity=4)
17
+ #out = morphology.remove_small_holes(out , min_size=2, connectivity=4)
18
+
19
  #out = processed
20
 
21
+ out = morphology.remove_small_objects(label(edges), 2,) # noise_reduced
22
+
23
+
24
  # black out pixels
25
  #mask_x, mask_y = np.where(processed == 0)
26
  #img[mask_x, mask_y, :3] = 0
 
29
 
30
 
31
  #return img
32
+ return out
33
 
34
  # For information on Interfaces, head to https://gradio.app/docs/
35
  # For user guides, head to https://gradio.app/guides/