shiue2000 commited on
Commit
41fdb7f
·
verified ·
1 Parent(s): ee2c2ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -5,9 +5,9 @@ from PIL import Image
5
  import os
6
  import uuid
7
 
8
- # Set up absolute desktop path
9
- desktop_dir = os.path.expanduser("~/Desktop/image")
10
- os.makedirs(desktop_dir, exist_ok=True)
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 Desktop/image/
76
  output_filename = f"{uuid.uuid4().hex}_{mode.replace(' ', '_')}.png"
77
- output_path = os.path.join(desktop_dir, output_filename)
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."