| import gradio | |
| import cv2 | |
| def greet(image, in_contrast, in_brightness): | |
| in_contrast = float(in_contrast) | |
| in_brightness = float(in_brightness) | |
| # contrast [1.0-3.0] | |
| # brightness [0-100] | |
| # https://docs.opencv.org/4.x/d3/dc1/tutorial_basic_linear_transform.html | |
| new_image = cv2.convertScaleAbs(image, alpha=in_contrast, beta=in_brightness) | |
| return new_image | |
| demo = gradio.Interface( | |
| fn=greet, | |
| inputs=['image', gradio.Slider(1,3), gradio.Slider(0, 100)], | |
| outputs=['image'], | |
| ) | |
| demo.launch() | |