File size: 1,281 Bytes
eab34ad 15364a8 4124b4d 15364a8 9a23331 3dc6831 4124b4d 3dc6831 9a23331 15364a8 a4409f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import gradio
import cv2
import numpy as np
#def inference(img, in_bright):
# new_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
# in_bright=1
# return new_img
#iface = gradio.Interface(
# fn=inference,
# inputs=['image',gradio.Slider(0,100)],
# outputs='image',
# title='Change Image',
# description='Interface!',
# examples=["llama.jpg"])
#iface.launch()
import gradio as gr
def greet(image, name, is_morning, temperature):
salutation = "Good morning" if is_morning else "Good evening"
greeting = f"{salutation} {name}. It is {temperature} degrees today"
celsius = (temperature - 32) * 5 / 9
new_image = np.zeros(image.shape, image.dtype)
# contrast [1.0-3.0]
# brightness [0-100]
# https://docs.opencv.org/4.x/d3/dc1/tutorial_basic_linear_transform.html
in_contrast = 1.0
in_brightness = 50
for y in range(image.shape[0]):
for x in range(image.shape[1]):
for c in range(image.shape[2]):
new_image[y,x,c] = np.clip(in_contrast*image[y,x,c] + in_brightness, 0, 255)
return new_image, greeting, round(celsius, 2)
demo = gr.Interface(
fn=greet,
inputs=['image',"text", "checkbox", gr.Slider(0, 100)],
outputs=['image',"text", "number"],
)
demo.launch()
|