Spaces:
Runtime error
Runtime error
import gradio | |
import matplotlib.pyplot as plt | |
from skimage import morphology | |
import numpy as np | |
import skimage | |
def inference(img): | |
grayscale = skimage.color.rgb2gray(im) | |
binarized = np.where(grayscale>0.1, 1, 0) | |
processed = morphology.remove_small_objects(binarized.astype(bool), min_size=2, connectivity=2).astype(int) | |
out = processed | |
# black out pixels | |
#mask_x, mask_y = np.where(processed == 0) | |
#im[mask_x, mask_y, :3] = 0 | |
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() |