Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
add cross kernel
#2
by
edgarriba
- opened
app.py
CHANGED
@@ -14,9 +14,9 @@ def morphological_operators(filepath, operator, kernel, kernel_size):
|
|
14 |
device = 'cpu' # 'cuda:0' for GPU
|
15 |
kernels = {
|
16 |
"Ones": torch.ones(kernel_size,kernel_size).to(device),
|
17 |
-
"Eye": torch.eye(kernel_size).to(device)
|
|
|
18 |
}
|
19 |
-
#torch.tensor([[0, 1, 0],[1, 1, 1],[0, 1, 0]]).to(device)
|
20 |
|
21 |
operations = {
|
22 |
'Dilation': morph.dilation(img, kernels[kernel]),
|
@@ -46,7 +46,7 @@ iface = gr.Interface(morphological_operators,
|
|
46 |
[
|
47 |
gr.Image(type="filepath"),
|
48 |
gr.Dropdown(choices=["Dilation", "Erosion", "Open", "Close", "Gradient", "Bottom Hat", "Top Hat"]),
|
49 |
-
gr.Radio(choices=["Ones", "Eye"]),
|
50 |
gr.Slider(
|
51 |
minimum=1,
|
52 |
maximum=7,
|
|
|
14 |
device = 'cpu' # 'cuda:0' for GPU
|
15 |
kernels = {
|
16 |
"Ones": torch.ones(kernel_size,kernel_size).to(device),
|
17 |
+
"Eye": torch.eye(kernel_size).to(device),
|
18 |
+
"Cross": torch.tensor([[0, 1, 0],[1, 1, 1],[0, 1, 0]]).to(device),
|
19 |
}
|
|
|
20 |
|
21 |
operations = {
|
22 |
'Dilation': morph.dilation(img, kernels[kernel]),
|
|
|
46 |
[
|
47 |
gr.Image(type="filepath"),
|
48 |
gr.Dropdown(choices=["Dilation", "Erosion", "Open", "Close", "Gradient", "Bottom Hat", "Top Hat"]),
|
49 |
+
gr.Radio(choices=["Ones", "Eye", "Cross"]),
|
50 |
gr.Slider(
|
51 |
minimum=1,
|
52 |
maximum=7,
|