File size: 1,396 Bytes
1c1298c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4258d11
1c1298c
12571c4
 
 
1c1298c
 
 
 
 
12571c4
 
 
 
 
1c1298c
 
 
 
 
 
 
 
 
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
import gradio as gr

import kornia as K
from kornia.core import Tensor


def enhance(file, brightness, contrast, saturation, gamma, hue):      
    # load the image using the rust backend          
    img: Tensor = K.io.load_image(file.name, K.io.ImageLoadType.RGB32)
    img = img[None]  # 1xCxHxW / fp32 / [0, 1]

    # apply tensor image enhancement
    x_out: Tensor = K.enhance.adjust_brightness(img, float(brightness))
    x_out = K.enhance.adjust_contrast(x_out, float(contrast))
    x_out = K.enhance.adjust_saturation(x_out, float(saturation))
    x_out = K.enhance.adjust_gamma(x_out, float(gamma))
    x_out = K.enhance.adjust_hue(x_out, float(hue))

    return K.utils.tensor_to_image(x_out)




title = "Editar Imagen"
description = ""
article = ""

iface = gr.Interface(
    enhance,
    [
        gr.inputs.Image(type="file"),
        gr.inputs.Slider(minimum=0, maximum=1, step=0.1, default=0, label="Brillo"),
        gr.inputs.Slider(minimum=0, maximum=4, step=0.1, default=1, label="Contraste"),
        gr.inputs.Slider(minimum=0, maximum=4, step=0.1, default=1, label="Saturación"),
        gr.inputs.Slider(minimum=0, maximum=1, step=0.1, default=1, label="Gama"),
        gr.inputs.Slider(minimum=0, maximum=4, step=0.1, default=0, label="Tono"),
    ],
    "image",
    # title=title,
    # description=description,
    # article=article,
    live=True
)

iface.launch()