|
import gradio |
|
import cv2 |
|
import numpy as np |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
|
|