File size: 1,570 Bytes
0bf753b
 
9cbebf5
a76dcb0
ea89a71
efe3f24
b8e825d
a76dcb0
4a8795e
 
 
efe3f24
37e4718
ff5248c
efe3f24
 
 
 
5153767
ea89a71
fd89db2
 
33cb75c
efe3f24
 
a76dcb0
698bdd0
 
a76dcb0
 
c6d3f67
0dbf7df
ed850a8
fd89db2
4a8795e
 
 
 
 
 
 
 
a76dcb0
 
cc6872c
 
4a8795e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import gradio


import matplotlib.pyplot as plt
from skimage import morphology,measure,feature
from skimage.measure import label
import numpy as np
import skimage


def inference(img):
  out = skimage.color.rgb2gray(img) # gray
  #binarized = np.where(grayscale>0.1, 1, 0)
  #processed = morphology.remove_small_objects(grayscale.astype(bool), min_size=33, connectivity=4).astype(int)
    
  #out = morphology.remove_small_objects(out , min_size=2, connectivity=4)
  #out = morphology.remove_small_holes(out , min_size=2, connectivity=4)

  #out = processed
  #edges = get_edges(img.copy())
  #edges = feature.canny(out, sigma=3) # edge detect via canny with sigma 3 
  #out = morphology.remove_small_objects(label(edges), 2,) # noise_reduced
  #out = morphology.remove_small_objects( out , 2,) # noise_reduced


  # black out pixels
  #mask_x, mask_y = np.where(processed == 0)
  #img[mask_x, mask_y, :3] = 0
  #mask_x, mask_y = np.where(processed == 0)
  #im[mask_x, mask_y, :3] = 0


  #return img
  return out

# For information on Interfaces, head to https://gradio.app/docs/
# For user guides, head to https://gradio.app/guides/
# For Spaces usage, head to https://huggingface.co/docs/hub/spaces
iface = gradio.Interface(
  fn=inference,
  inputs='image',
  outputs='image',
  title='Noise Removal w skimage', 
  description='Remove Noise with skimage.morphology!',
  examples=["detail_with_lines_and_noise.jpg", "lama.webp", "dT4KW.png"])  
  #examples=["detail_with_lines_and_noise.jpg", "lama.webp", "test_lines.jpg","llama.jpg", "dT4KW.png"])  

iface.launch()