Spaces:
Running on Zero
Running on Zero
Upload folder using huggingface_hub
Browse filesFiles changed (4)
- .gitignoreAdded+12
- README.md+65-6
- app.pyAdded+168
- requirements.txtAdded+7
123456789101112__pycache__/*.py[cod]*$py.class*.so.Pythonenv/venv/.venv/*.egg-info/.DS_Store.ipynb_checkpoints/flagged/123456789101112---title: RMBG 3.0emoji: 🚀colorFrom: redcolorTo: yellowsdk: gradiosdk_version: 6.5.1app_file: app.pypinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071---title: RMBG-3.0 Background Removal & Image Editingemoji: 🎨colorFrom: bluecolorTo: purplesdk: gradiosdk_version: 4.44.0app_file: app.pypinned: falselicense: cc-by-nc-4.0models:- briaai/RMBG-3.0tags:- image-editing- background-removal- image-to-image- diffusionshort_description: Background removal and image editing with RMBG-3.0---# RMBG-3.0 - Background Removal & Image EditingThis Space demonstrates **RMBG-3.0**, an advanced image editing model built on [Fibo-Edit](https://huggingface.co/briaai/Fibo-Edit) by Bria AI.## 🎯 Capabilities- **Background Removal**: Remove backgrounds with high precision- **Object Removal**: Remove specific objects from images- **Style Transfer**: Apply different artistic styles- **Recoloring**: Change colors of objects- **Relighting**: Adjust lighting conditions- **Masked Editing**: Target specific regions with masks## 🚀 How to Use1. **Upload an Image**: Click on the input image area to upload your photo2. **Add a Mask (Optional)**: Upload a mask to edit specific regions only3. **Provide Instructions**: Describe what you want to change (e.g., "remove the background")4. **Adjust Settings**: Optionally tune the number of steps and guidance scale5. **Process**: Click the "Process Image" button## 📖 Example Instructions- `remove the background`- `make it look vintage`- `change the car color to red`- `remove the person`- `add dramatic sunset lighting`- `change to winter scene`## 🏗️ Model Details- **Model**: [briaai/RMBG-3.0](https://huggingface.co/briaai/RMBG-3.0)- **Base**: FIBO-Edit architecture (8B parameters)- **Training**: Exclusively on licensed, copyright-safe data- **License**: [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/) (Non-commercial use only)## 💼 Commercial UseFor commercial licensing, please contact [Bria AI](https://bria.ai/contact-us).## 🔗 Links- [Model Card](https://huggingface.co/briaai/RMBG-3.0)- [Fibo-Edit Base Model](https://huggingface.co/briaai/Fibo-Edit)- [Bria AI](https://bria.ai)- [GitHub](https://github.com/Bria-AI/)---Built with ❤️ by [Bria AI](https://bria.ai)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168import gradio as grimport torchfrom diffusers import BriaFiboEditPipelinefrom PIL import Imageimport os
# Load the modelprint("Loading RMBG-3.0 model...")pipe = BriaFiboEditPipeline.from_pretrained( "briaai/RMBG-3.0", torch_dtype=torch.bfloat16,)
# Check if CUDA is availabledevice = "cuda" if torch.cuda.is_available() else "cpu"pipe.to(device)print(f"Model loaded on {device}")
def process_image(image, mask, instruction, num_steps, guidance_scale): """ Process an image with RMBG-3.0
Args: image: Input image (PIL Image) mask: Optional mask image (PIL Image) instruction: Text instruction for editing num_steps: Number of inference steps guidance_scale: Guidance scale for generation """ if image is None: return None, "Please upload an image"
if not instruction or instruction.strip() == "": return None, "Please provide an editing instruction"
try: # Prepare inputs kwargs = { "image": image, "prompt": instruction, "num_inference_steps": num_steps, "guidance_scale": guidance_scale }
# Add mask if provided if mask is not None: kwargs["mask"] = mask.convert("L")
# Run the pipeline result = pipe(**kwargs).images[0]
return result, "✅ Image processed successfully!"
except Exception as e: return None, f"❌ Error: {str(e)}"
# Create Gradio interfacewith gr.Blocks(title="RMBG-3.0 - Background Removal & Image Editing") as demo: gr.Markdown(""" # RMBG-3.0 - Background Removal & Image Editing
Powered by [Bria AI's RMBG-3.0 model](https://huggingface.co/briaai/RMBG-3.0)
This model performs advanced image editing including: - **Background removal**: "remove the background" - **Object removal**: "remove the person", "remove the car" - **Style changes**: "make it look vintage", "change to winter scene" - **Recoloring**: "change the car color to red" - **Relighting**: "add dramatic lighting"
### How to use: 1. Upload your image 2. (Optional) Upload a mask to edit specific regions 3. Describe what you want to change 4. Adjust settings and click Process! """)
with gr.Row(): with gr.Column(scale=1): input_image = gr.Image( label="Input Image", type="pil", height=400 )
mask_image = gr.Image( label="Mask (Optional - for targeted edits)", type="pil", height=200 )
instruction = gr.Textbox( label="Editing Instruction", placeholder="E.g., 'remove the background', 'change car color to blue', 'make it look vintage'", lines=3 )
with gr.Accordion("Advanced Settings", open=False): num_steps = gr.Slider( minimum=20, maximum=100, value=50, step=1, label="Number of Steps" )
guidance_scale = gr.Slider( minimum=1.0, maximum=15.0, value=5.0, step=0.5, label="Guidance Scale" )
process_btn = gr.Button("🚀 Process Image", variant="primary")
with gr.Column(scale=1): output_image = gr.Image( label="Output Image", type="pil", height=400 )
status_text = gr.Textbox( label="Status", interactive=False, lines=2 )
# Examples gr.Markdown("### Examples") gr.Examples( examples=[ ["Remove the background"], ["Make it look vintage"], ["Change the lighting to dramatic sunset"], ["Remove the person"], ["Change the car color to red"], ], inputs=instruction, label="Example Instructions" )
# Connect the button process_btn.click( fn=process_image, inputs=[input_image, mask_image, instruction, num_steps, guidance_scale], outputs=[output_image, status_text] )
gr.Markdown(""" --- ### About RMBG-3.0
RMBG-3.0 is built on [Fibo-Edit](https://huggingface.co/briaai/Fibo-Edit), an 8B parameter image editing model that uses structured prompts for precise, deterministic editing.
- **Model**: [briaai/RMBG-3.0](https://huggingface.co/briaai/RMBG-3.0) - **Architecture**: Based on FIBO with 8B parameters - **Training**: Exclusively on licensed data - **License**: Non-commercial use ([CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/))
For commercial use, please [contact Bria AI](https://bria.ai/contact-us). """)
# Launch the appif __name__ == "__main__": demo.launch()1234567torch>=2.0.0diffusers>=0.30.0transformers>=4.40.0accelerate>=0.30.0safetensors>=0.4.0pillow>=10.0.0gradio>=4.0.0.gitignoreAdded+12
README.md+65-6
app.pyAdded+168
requirements.txtAdded+7