Avi3738 commited on
Commit
2246494
·
verified ·
1 Parent(s): 6c51bc9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import gradio as gr
3
+ from stylization import Stylizer
4
+ import cv2
5
+ import numpy as np
6
+
7
+ stylizer = Stylizer()
8
+
9
+ def stylize_interface(image):
10
+ # Convert from PIL to OpenCV format
11
+ image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR)
12
+ result = stylizer.apply_style_threaded(image)
13
+ # Convert back to PIL format
14
+ result_rgb = cv2.cvtColor(result, cv2.COLOR_BGR2RGB)
15
+ return result_rgb
16
+
17
+ iface = gr.Interface(
18
+ fn=stylize_interface,
19
+ inputs=gr.Image(type="pil"),
20
+ outputs=gr.Image(type="pil"),
21
+ title="Threaded Image Stylizer",
22
+ description="Applies stylization filter using OpenCV with threading."
23
+ )
24
+
25
+ if __name__ == "__main__":
26
+ iface.launch()