Spaces:
Running
on
Zero
A newer version of the Gradio SDK is available:
5.38.2
title: text cut object
emoji: ✂️
colorFrom: indigo
colorTo: indigo
sdk: gradio
sdk_version: 5.35.0
app_file: app.py
pinned: false
license: mit
I'll create comprehensive documentation for this object segmentation and background removal application in both English and Korean.
English Documentation
Advanced Object Cutout Tool - AI-Powered Background Removal
This application is a sophisticated object segmentation tool that combines Grounding DINO for object detection and a specialized Box Segmenter for precise background removal, offering two intuitive methods for isolating objects from images.
Key Features
Dual Input Methods
- Text Prompt Mode: Simply describe the object you want to extract (e.g., "chair", "potted plant")
- Bounding Box Mode: Manually draw a box around the object for precise selection
- Both methods provide high-quality cutouts with transparent backgrounds
Advanced AI Models
- Grounding DINO: State-of-the-art object detection model that understands natural language descriptions
- Box Segmenter: Refined segmentation model for pixel-perfect object extraction
- PyMatting Integration: Advanced alpha matting for clean edges without halos
Professional Edge Processing
- Color Decontamination: Removes color bleeding from edges using ML-based foreground estimation
- Alpha Matting: Preserves fine details like hair, fur, and transparent objects
- Automatic Cropping: Intelligently crops the result to the object boundaries
User-Friendly Interface
- Image Slider: Before/after comparison view for immediate visual feedback
- Download Options: Easy one-click download of processed images
- Example Gallery: Pre-loaded examples demonstrating various use cases
- Responsive Design: Works seamlessly on desktop and mobile devices
Technical Implementation
The application leverages several cutting-edge technologies:
- Grounding DINO: For natural language-based object detection
- Refiners Library: Custom segmentation model with SOTA performance
- PyMatting: Advanced matting algorithms for edge refinement
- Gradio: Modern web interface with GPU acceleration via ZeroGPU
- Pillow HEIF: Support for modern image formats including HEIC and AVIF
Processing Pipeline:
Object Detection (Text mode only):
- Processes natural language prompt with Grounding DINO
- Identifies object location with bounding box coordinates
- Handles multiple detections by computing union of boxes
Segmentation:
- Applies Box Segmenter model to extract precise object mask
- Runs on GPU for real-time performance
- Generates high-resolution binary mask
Edge Refinement:
- Applies color decontamination to remove edge artifacts
- Uses ML-based foreground estimation for natural edges
- Preserves transparency and semi-transparent regions
Post-Processing:
- Composites object onto transparent background
- Auto-crops to remove excess transparent areas
- Saves as PNG with full alpha channel support
Performance Optimizations
- GPU Acceleration: Automatic CUDA optimization with @spaces.GPU decorator
- Image Size Management: Automatic resizing for images over 2048px
- Efficient Memory Usage: Model offloading and careful tensor management
- Batch Processing: Optimized for single-image processing with minimal latency
- Format Support: Native support for HEIC, AVIF, JPEG, PNG, and more
Use Cases
Perfect for:
- E-commerce: Product photography with clean backgrounds
- Graphic Design: Extracting elements for compositions
- Social Media: Creating stickers and transparent overlays
- Photography: Isolating subjects for editing
- Education: Teaching object detection and segmentation concepts
- Marketing: Creating promotional materials with isolated products
한글 설명서
고급 객체 추출 도구 - AI 기반 배경 제거
이 애플리케이션은 객체 감지를 위한 Grounding DINO와 정밀한 배경 제거를 위한 전문 Box Segmenter를 결합한 정교한 객체 분할 도구로, 이미지에서 객체를 분리하는 두 가지 직관적인 방법을 제공합니다.
주요 기능
이중 입력 방식
- 텍스트 프롬프트 모드: 추출하려는 객체를 간단히 설명 (예: "의자", "화분")
- 경계 상자 모드: 정밀한 선택을 위해 객체 주위에 수동으로 상자 그리기
- 두 방법 모두 투명 배경의 고품질 추출 결과 제공
고급 AI 모델
- Grounding DINO: 자연어 설명을 이해하는 최첨단 객체 감지 모델
- Box Segmenter: 픽셀 단위의 완벽한 객체 추출을 위한 정제된 분할 모델
- PyMatting 통합: 헤일로 없는 깨끗한 가장자리를 위한 고급 알파 매팅
전문적인 가장자리 처리
- 색상 오염 제거: ML 기반 전경 추정을 사용하여 가장자리의 색상 번짐 제거
- 알파 매팅: 머리카락, 털, 투명 객체와 같은 세밀한 디테일 보존
- 자동 크롭: 객체 경계에 맞춰 지능적으로 결과물 크롭
사용자 친화적 인터페이스
- 이미지 슬라이더: 즉각적인 시각적 피드백을 위한 전후 비교 뷰
- 다운로드 옵션: 처리된 이미지의 간편한 원클릭 다운로드
- 예제 갤러리: 다양한 사용 사례를 보여주는 사전 로드된 예제
- 반응형 디자인: 데스크톱과 모바일 기기에서 원활하게 작동
기술적 구현
애플리케이션은 여러 최첨단 기술을 활용합니다:
- Grounding DINO: 자연어 기반 객체 감지
- Refiners 라이브러리: SOTA 성능의 커스텀 분할 모델
- PyMatting: 가장자리 정제를 위한 고급 매팅 알고리즘
- Gradio: ZeroGPU를 통한 GPU 가속이 포함된 현대적 웹 인터페이스
- Pillow HEIF: HEIC 및 AVIF를 포함한 최신 이미지 형식 지원
처리 파이프라인:
객체 감지 (텍스트 모드 전용):
- Grounding DINO로 자연어 프롬프트 처리
- 경계 상자 좌표로 객체 위치 식별
- 상자들의 합집합을 계산하여 다중 감지 처리
분할:
- Box Segmenter 모델을 적용하여 정밀한 객체 마스크 추출
- 실시간 성능을 위해 GPU에서 실행
- 고해상도 이진 마스크 생성
가장자리 정제:
- 가장자리 아티팩트 제거를 위한 색상 오염 제거 적용
- 자연스러운 가장자리를 위한 ML 기반 전경 추정 사용
- 투명도 및 반투명 영역 보존
후처리:
- 투명 배경에 객체 합성
- 과도한 투명 영역 제거를 위한 자동 크롭
- 전체 알파 채널 지원으로 PNG 저장
성능 최적화
- GPU 가속: @spaces.GPU 데코레이터로 자동 CUDA 최적화
- 이미지 크기 관리: 2048px 이상 이미지에 대한 자동 크기 조정
- 효율적인 메모리 사용: 모델 오프로딩 및 신중한 텐서 관리
- 배치 처리: 최소 지연 시간으로 단일 이미지 처리에 최적화
- 형식 지원: HEIC, AVIF, JPEG, PNG 등 네이티브 지원
사용 사례
다음과 같은 용도에 적합합니다:
- 전자상거래: 깨끗한 배경의 제품 사진
- 그래픽 디자인: 구성을 위한 요소 추출
- 소셜 미디어: 스티커 및 투명 오버레이 생성
- 사진: 편집을 위한 피사체 분리
- 교육: 객체 감지 및 분할 개념 교육
- 마케팅: 분리된 제품으로 홍보 자료 제작