Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -19,15 +19,15 @@ pipe.to(device)
|
|
| 19 |
print(f"Model loaded on {device}")
|
| 20 |
|
| 21 |
@spaces.GPU
|
| 22 |
-
def process_image(image,
|
| 23 |
"""
|
| 24 |
Process an image with RMBG-3.0
|
| 25 |
"""
|
| 26 |
if image is None:
|
| 27 |
return None, "Please upload an image"
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
try:
|
| 33 |
# Run the pipeline to get the grayscale alpha matte
|
|
@@ -67,9 +67,8 @@ with gr.Blocks(title="RMBG-3.0 - Background Removal & Image Editing") as demo:
|
|
| 67 |
|
| 68 |
### How to use:
|
| 69 |
1. Upload your image
|
| 70 |
-
2.
|
| 71 |
-
3.
|
| 72 |
-
4. Click Process!
|
| 73 |
""")
|
| 74 |
|
| 75 |
with gr.Row():
|
|
@@ -80,12 +79,6 @@ with gr.Blocks(title="RMBG-3.0 - Background Removal & Image Editing") as demo:
|
|
| 80 |
height=400
|
| 81 |
)
|
| 82 |
|
| 83 |
-
instruction = gr.Textbox(
|
| 84 |
-
label="Editing Instruction",
|
| 85 |
-
value="\"{'edit_instruction':'Generate a detailed grayscale alpha matte. Map the opaque foreground to white and the background to black. Produce soft, anti-aliased grayscale gradients at the edges of the subject to represent fine details and transparency.'}\"",
|
| 86 |
-
lines=5
|
| 87 |
-
)
|
| 88 |
-
|
| 89 |
with gr.Accordion("Advanced Settings", open=False):
|
| 90 |
num_steps = gr.Slider(
|
| 91 |
minimum=1,
|
|
@@ -122,7 +115,7 @@ with gr.Blocks(title="RMBG-3.0 - Background Removal & Image Editing") as demo:
|
|
| 122 |
# Connect the button
|
| 123 |
process_btn.click(
|
| 124 |
fn=process_image,
|
| 125 |
-
inputs=[input_image,
|
| 126 |
outputs=[output_image, status_text]
|
| 127 |
)
|
| 128 |
|
|
|
|
| 19 |
print(f"Model loaded on {device}")
|
| 20 |
|
| 21 |
@spaces.GPU
|
| 22 |
+
def process_image(image, num_steps=50, guidance_scale=5.0):
|
| 23 |
"""
|
| 24 |
Process an image with RMBG-3.0
|
| 25 |
"""
|
| 26 |
if image is None:
|
| 27 |
return None, "Please upload an image"
|
| 28 |
|
| 29 |
+
# Fixed instruction for background removal
|
| 30 |
+
instruction = "{'edit_instruction':'Generate a detailed grayscale alpha matte. Map the opaque foreground to white and the background to black. Produce soft, anti-aliased grayscale gradients at the edges of the subject to represent fine details and transparency.'}"
|
| 31 |
|
| 32 |
try:
|
| 33 |
# Run the pipeline to get the grayscale alpha matte
|
|
|
|
| 67 |
|
| 68 |
### How to use:
|
| 69 |
1. Upload your image
|
| 70 |
+
2. Adjust settings if needed (optional)
|
| 71 |
+
3. Click Process!
|
|
|
|
| 72 |
""")
|
| 73 |
|
| 74 |
with gr.Row():
|
|
|
|
| 79 |
height=400
|
| 80 |
)
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
with gr.Accordion("Advanced Settings", open=False):
|
| 83 |
num_steps = gr.Slider(
|
| 84 |
minimum=1,
|
|
|
|
| 115 |
# Connect the button
|
| 116 |
process_btn.click(
|
| 117 |
fn=process_image,
|
| 118 |
+
inputs=[input_image, num_steps, guidance_scale],
|
| 119 |
outputs=[output_image, status_text]
|
| 120 |
)
|
| 121 |
|