Spaces:
Runtime error
Runtime error
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() |