File size: 497 Bytes
b417246
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c12e0b8
b417246
 
 
 
 
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
import gradio as gr

def to_gray(img):
  filtpxs = []
  for r,g,b in img.getdata():
    l = (r + g + b) // 3
    filtpxs.append((l, l, l))
  img.putdata(filtpxs)
  return img

my_inputs = [
  gr.Image(type="pil", show_label=False),
]

my_outputs = [
  gr.Image(type="pil", show_label=False)
]

with gr.Blocks() as demo:
  gr.Interface(
    fn=to_gray,
    inputs=my_inputs,
    outputs=my_outputs,
    # allow_flagging="never",
    fill_width=True
  )

if __name__ == "__main__":
   demo.launch()