Created
May 4, 2024 14:58
-
-
Save todashuta/c162741946228129814f2183d97f3f0f to your computer and use it in GitHub Desktop.
Gradio
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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