Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cv2
|
2 |
+
import gradio as gr
|
3 |
+
def dodgeV2(image, mask):
|
4 |
+
return cv2.divide(image, 255-mask, scale=256)
|
5 |
+
def burnV2(image, mask):
|
6 |
+
return 255 - cv2.divide(255-image, 255-mask, scale=256)
|
7 |
+
def image_to_sketch(img):
|
8 |
+
img = cv2.resize(img,(178,218))
|
9 |
+
img_rgb = img
|
10 |
+
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
|
11 |
+
img_gray_inv = 255 - img_gray
|
12 |
+
img_blur = cv2.GaussianBlur(img_gray_inv, ksize=(21, 21),sigmaX=0, sigmaY=0)
|
13 |
+
img_blend = dodgeV2(img_gray, img_blur)
|
14 |
+
temp = cv2.cvtColor(img_blend,cv2.COLOR_GRAY2BGR)
|
15 |
+
return temp
|
16 |
+
#matplotlib.image.imsave('mypic_s.jpg', img_blend,cmap='gray')
|
17 |
+
gr.Interface(fn=image_to_sketch,inputs="image",outputs="image",title="Image To Sketch Converter",description="Upload of any size image to get desired sketch of it",css=".output {height: 10px;width:10px }").launch()
|