File size: 451 Bytes
c7644fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
import numpy as np
def gennerateImage(input_array,eps):
eps = eps / 100
mask = np.random.random(input_array.shape)
mask = mask * 2 - 1 # 将mask的值转换为-1到1之间
noise_img = (input_array * (1 + mask * eps)).astype(np.uint8) % 255
return noise_img
demo = gr.Interface(
gennerateImage,
inputs=[
gr.Image(),
gr.Slider(1, 10, 3)
],
outputs="image"
)
demo.launch()
|