palif commited on
Commit
094b1af
·
verified ·
1 Parent(s): d28ea8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -4
app.py CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
2
  import cv2
3
  import numpy as np
4
 
5
- # Filter functions
6
  def apply_filter(image, filter_type):
7
  if filter_type == "Grayscale":
8
  return cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
@@ -37,18 +36,16 @@ def apply_filter(image, filter_type):
37
  color = cv2.bilateralFilter(image, 9, 300, 300)
38
  return cv2.bitwise_and(color, color, mask=edges)
39
 
40
- # Gradio interface
41
  def process_image(image, filter_type):
42
  image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
43
  output = apply_filter(image, filter_type)
44
  return cv2.cvtColor(output, cv2.COLOR_BGR2RGB) if len(output.shape) == 3 else output
45
 
46
- # Gradio app
47
  with gr.Blocks() as app:
48
  gr.Markdown("### Photo Filter Tool")
49
  with gr.Row():
50
  with gr.Column():
51
- image_input = gr.Image(source="upload", type="numpy", label="Upload Image")
52
  filter_type = gr.Radio(
53
  ["Grayscale", "Sepia", "Invert", "Blur", "Sketch", "Sharpen",
54
  "Emboss", "Canny Edge", "Brightness Increase", "Cartoon"],
 
2
  import cv2
3
  import numpy as np
4
 
 
5
  def apply_filter(image, filter_type):
6
  if filter_type == "Grayscale":
7
  return cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
 
36
  color = cv2.bilateralFilter(image, 9, 300, 300)
37
  return cv2.bitwise_and(color, color, mask=edges)
38
 
 
39
  def process_image(image, filter_type):
40
  image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
41
  output = apply_filter(image, filter_type)
42
  return cv2.cvtColor(output, cv2.COLOR_BGR2RGB) if len(output.shape) == 3 else output
43
 
 
44
  with gr.Blocks() as app:
45
  gr.Markdown("### Photo Filter Tool")
46
  with gr.Row():
47
  with gr.Column():
48
+ image_input = gr.Image(type="numpy", label="Upload Image")
49
  filter_type = gr.Radio(
50
  ["Grayscale", "Sepia", "Invert", "Blur", "Sketch", "Sharpen",
51
  "Emboss", "Canny Edge", "Brightness Increase", "Cartoon"],