|
|
import cv2 as cv |
|
|
import numpy as np |
|
|
import gradio as gr |
|
|
|
|
|
def nostalgic_effect(image): |
|
|
|
|
|
image = np.array(image) |
|
|
|
|
|
image = cv.cvtColor(image, cv.COLOR_RGB2BGR) |
|
|
|
|
|
gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY) |
|
|
return gray_image |
|
|
|
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
gr.Markdown("# Convert Image to Black and White!") |
|
|
gr.Markdown("Upload an image and see it transformed to black and white...") |
|
|
|
|
|
image_input = gr.Image(type='pil') |
|
|
image_output = gr.Image(type="numpy", label="Converted Image") |
|
|
|
|
|
|
|
|
convert_btn = gr.Button("Convert") |
|
|
convert_btn.click(fn=nostalgic_effect, inputs=image_input, outputs=image_output) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch() |