Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,9 +5,9 @@ from PIL import Image
|
|
| 5 |
import os
|
| 6 |
import uuid
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
| 10 |
-
os.makedirs(
|
| 11 |
|
| 12 |
def apply_filters(image, mode):
|
| 13 |
img = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
|
|
@@ -72,12 +72,12 @@ def apply_filters(image, mode):
|
|
| 72 |
else:
|
| 73 |
processed = img
|
| 74 |
|
| 75 |
-
# Save processed image to
|
| 76 |
output_filename = f"{uuid.uuid4().hex}_{mode.replace(' ', '_')}.png"
|
| 77 |
-
output_path = os.path.join(
|
| 78 |
Image.fromarray(processed).save(output_path)
|
| 79 |
|
| 80 |
-
return processed, output_path
|
| 81 |
|
| 82 |
title = "🎨 Image Filter Lab"
|
| 83 |
description = "Apply filters like Pencil Sketch, Cartoon, Sepia, Edge Detection and more using OpenCV. Upload an image and select a filter."
|
|
|
|
| 5 |
import os
|
| 6 |
import uuid
|
| 7 |
|
| 8 |
+
# Save processed images inside the app folder
|
| 9 |
+
OUTPUT_DIR = "outputs"
|
| 10 |
+
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
| 11 |
|
| 12 |
def apply_filters(image, mode):
|
| 13 |
img = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
|
|
|
|
| 72 |
else:
|
| 73 |
processed = img
|
| 74 |
|
| 75 |
+
# Save processed image to outputs/
|
| 76 |
output_filename = f"{uuid.uuid4().hex}_{mode.replace(' ', '_')}.png"
|
| 77 |
+
output_path = os.path.join(OUTPUT_DIR, output_filename)
|
| 78 |
Image.fromarray(processed).save(output_path)
|
| 79 |
|
| 80 |
+
return processed, output_path # safe path for Gradio
|
| 81 |
|
| 82 |
title = "🎨 Image Filter Lab"
|
| 83 |
description = "Apply filters like Pencil Sketch, Cartoon, Sepia, Edge Detection and more using OpenCV. Upload an image and select a filter."
|