jflo commited on
Commit
99800f7
1 Parent(s): a724cd9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import cv2
4
+
5
+ def filter_img(input_img,filter_type):
6
+ img = input_img
7
+ if filter_type == 'vintage':
8
+ sepia_filter = np.array(
9
+ [[0.393, 0.769, 0.189], [0.349, 0.686, 0.168], [0.272, 0.534, 0.131]]
10
+ )
11
+ filtered_img = img.dot(sepia_filter.T)
12
+ filtered_img /= filtered_img.max()
13
+ return filtered_img
14
+
15
+
16
+ elif filter_type == 'gray-sharp':
17
+ img = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
18
+ filtered_img = cv2.addWeighted(img,4, cv2.blur(img,(128,128)),-4,128)
19
+
20
+ return filtered_img
21
+
22
+ demo = gr.Interface(filter_img,
23
+ inputs = [ gr.Image(),gr.inputs.Dropdown(["sharp","gray-sharp","vintage"])],
24
+ outputs = "image",
25
+ description="Cool image filters!"
26
+ )
27
+
28
+ demo.launch(inline=False)