|
import cv2 |
|
import gradio as gr |
|
def convert_photo_to_Sketch(image): |
|
img = cv2.resize(image, (256, 256)) |
|
|
|
RGB_img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) |
|
|
|
grey_img=cv2.cvtColor(RGB_img, cv2.COLOR_BGR2GRAY) |
|
|
|
invert_img=255-grey_img |
|
|
|
blur_img=cv2.GaussianBlur(invert_img, (21,21),0) |
|
|
|
inverted_blurred_img = 255 - blur_img |
|
|
|
sketch_img=cv2.divide(grey_img,inverted_blurred_img, scale=256.0) |
|
rgb_sketch=cv2.cvtColor(sketch_img, cv2.COLOR_BGR2RGB) |
|
|
|
return rgb_sketch |
|
|
|
|
|
imagein = gr.inputs.Image(label='Orjinal Resim') |
|
imageout = gr.outputs.Image(label='Sketch Resim',type='pil') |
|
gr.Interface(fn=convert_photo_to_Sketch, inputs=imagein, outputs=imageout,title='Convert RGB Image to Sketch').launch() |