ImageToSketch / app.py
lee45's picture
Create app.py
68b2a37
raw
history blame contribute delete
839 Bytes
import cv2
import gradio as gr
def dodgeV2(image, mask):
return cv2.divide(image, 255-mask, scale=256)
def burnV2(image, mask):
return 255 - cv2.divide(255-image, 255-mask, scale=256)
def image_to_sketch(img):
img = cv2.resize(img,(178,218))
img_rgb = img
img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)
img_gray_inv = 255 - img_gray
img_blur = cv2.GaussianBlur(img_gray_inv, ksize=(21, 21),sigmaX=0, sigmaY=0)
img_blend = dodgeV2(img_gray, img_blur)
temp = cv2.cvtColor(img_blend,cv2.COLOR_GRAY2BGR)
return temp
#matplotlib.image.imsave('mypic_s.jpg', img_blend,cmap='gray')
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()