Skip to content

Instantly share code, notes, and snippets.

@todashuta
Created May 4, 2024 14:58
Show Gist options
  • Save todashuta/c162741946228129814f2183d97f3f0f to your computer and use it in GitHub Desktop.
Save todashuta/c162741946228129814f2183d97f3f0f to your computer and use it in GitHub Desktop.
Gradio
import gradio as gr
import numpy as np
def func(img, n):
R = img[:,:,0]
G = img[:,:,1]
B = img[:,:,2]
R = np.where(R <= n, 0, R)
G = np.where(G <= n, 255, G)
B = np.where(B <= n, 0, B)
#breakpoint()
img[:,:,0] = R
img[:,:,1] = G
img[:,:,2] = B
return img
demo = gr.Interface(
fn=func,
inputs=[gr.Image(), gr.Slider(0, 255)],
outputs=["image"]
)
demo.launch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment