Spaces:
Paused
Paused
VINU NAYAK commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from rembg import remove
|
| 3 |
from PIL import Image
|
| 4 |
-
import io
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
output_image = remove(input_image)
|
| 10 |
return output_image
|
| 11 |
|
| 12 |
demo = gr.Interface(
|
| 13 |
fn=remove_background,
|
| 14 |
-
inputs=
|
|
|
|
|
|
|
|
|
|
| 15 |
outputs=gr.Image(type="pil"),
|
| 16 |
-
title="Background Remover",
|
| 17 |
-
description="
|
| 18 |
-
examples=[],
|
| 19 |
theme=gr.themes.Soft()
|
| 20 |
)
|
| 21 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from rembg import remove
|
| 3 |
from PIL import Image
|
|
|
|
| 4 |
|
| 5 |
+
# Set your secret API key here
|
| 6 |
+
API_KEY = "mysecret123"
|
| 7 |
+
|
| 8 |
+
def remove_background(input_image, key):
|
| 9 |
+
if key != API_KEY:
|
| 10 |
+
raise gr.Error("Invalid API Key!")
|
| 11 |
+
|
| 12 |
output_image = remove(input_image)
|
| 13 |
return output_image
|
| 14 |
|
| 15 |
demo = gr.Interface(
|
| 16 |
fn=remove_background,
|
| 17 |
+
inputs=[
|
| 18 |
+
gr.Image(type="pil", label="Upload Image"),
|
| 19 |
+
gr.Text(label="API Key")
|
| 20 |
+
],
|
| 21 |
outputs=gr.Image(type="pil"),
|
| 22 |
+
title="Protected Background Remover",
|
| 23 |
+
description="Enter your API key to use this app",
|
|
|
|
| 24 |
theme=gr.themes.Soft()
|
| 25 |
)
|
| 26 |
|