Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,17 @@ model_path = hf_hub_download(repo_id="Bmo411/DenoisingAutoencoder", filename="au
|
|
| 9 |
|
| 10 |
# Cargar el modelo una sola vez para evitar recargas en cada ejecución
|
| 11 |
model = tf.keras.models.load_model(model_path, compile=True)
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
def degrade_image(image, downscale_factor=4):
|
| 14 |
"""Reduce la calidad de la imagen reduciendo su tamaño y volviéndola a escalar."""
|
| 15 |
h, w = image.shape[:2]
|
|
|
|
| 9 |
|
| 10 |
# Cargar el modelo una sola vez para evitar recargas en cada ejecución
|
| 11 |
model = tf.keras.models.load_model(model_path, compile=True)
|
| 12 |
+
def fourier_transform(x):
|
| 13 |
+
fourier = tf.signal.fft2d(tf.cast(x, tf.complex64))
|
| 14 |
+
fourier = tf.complex(tf.math.real(fourier), tf.math.imag(fourier))
|
| 15 |
+
fourier = tf.abs(fourier)
|
| 16 |
+
return tf.concat([tf.math.real(fourier), tf.math.imag(fourier)], axis=-1) # Separar parte real e imaginaria
|
| 17 |
+
|
| 18 |
+
def inverse_fourier_transform(x):
|
| 19 |
+
real_part, imag_part = tf.split(x, num_or_size_splits=2, axis=-1)
|
| 20 |
+
complex_fourier = tf.complex(real_part, imag_part)
|
| 21 |
+
return tf.abs(tf.signal.ifft2d(complex_fourier))
|
| 22 |
+
|
| 23 |
def degrade_image(image, downscale_factor=4):
|
| 24 |
"""Reduce la calidad de la imagen reduciendo su tamaño y volviéndola a escalar."""
|
| 25 |
h, w = image.shape[:2]
|