Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import numpy as np
|
3 |
+
from scipy.ndimage import gaussian_filter
|
4 |
+
|
5 |
+
def main():
|
6 |
+
st.title("Image Denoising with Diffusion")
|
7 |
+
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "png"])
|
8 |
+
|
9 |
+
if uploaded_image:
|
10 |
+
image_array = np.array(uploaded_image)
|
11 |
+
denoised_image = apply_diffusion(image_array)
|
12 |
+
st.image(denoised_image, caption="Denoised Image", use_column_width=True)
|
13 |
+
|
14 |
+
if __name__ == "__main__":
|
15 |
+
main()
|
16 |
+
|
17 |
+
def apply_diffusion(image_array):
|
18 |
+
# Convert to grayscale if needed
|
19 |
+
if len(image_array.shape) == 3:
|
20 |
+
image_array = np.mean(image_array, axis=2)
|
21 |
+
|
22 |
+
# Apply Gaussian diffusion
|
23 |
+
denoised_image = gaussian_filter(image_array, sigma=1.0)
|
24 |
+
|
25 |
+
return denoised_image
|
26 |
+
|
27 |
+
|