|
|
--- |
|
|
license: openrail |
|
|
base_model: runwayml/stable-diffusion-v1-5 |
|
|
tags: |
|
|
- stable-diffusion |
|
|
- controlnet |
|
|
- image-inpainting |
|
|
- fashion |
|
|
- pose-conditioning |
|
|
pipeline_tag: image-to-image |
|
|
library_name: diffusers |
|
|
--- |
|
|
# Fashion Inpainting System |
|
|
|
|
|
π¨ **Advanced AI-powered fashion transformation system that preserves body pose and facial identity while generating new clothing styles.** |
|
|
|
|
|
[](LICENSE) |
|
|
[](https://python.org) |
|
|
[](https://huggingface.co) |
|
|
|
|
|
## π Key Features |
|
|
|
|
|
- **Pose Preservation**: Advanced 25.3% pose coverage system maintains body structure and proportions |
|
|
- **Facial Identity Protection**: Preserves original facial features and expressions |
|
|
- **Safety-First Design**: Built-in content filtering and safety checks |
|
|
- **Multiple Checkpoint Support**: Compatible with various Stable Diffusion checkpoints |
|
|
- **Production Ready**: Comprehensive error handling and fallback systems |
|
|
|
|
|
## π― What This System Does |
|
|
|
|
|
**Input**: Person wearing any outfit |
|
|
**Output**: Same person in a completely different outfit while maintaining: |
|
|
- β
Exact facial identity |
|
|
- β
Original body pose and proportions |
|
|
- β
Natural fabric draping and fit |
|
|
- β
Appropriate content generation |
|
|
|
|
|
## π‘οΈ Safety & Ethical Use |
|
|
|
|
|
### β οΈ IMPORTANT USAGE RESTRICTIONS |
|
|
|
|
|
This system is designed for **creative and artistic purposes only**. By using this software, you agree to: |
|
|
|
|
|
**β
ALLOWED USES:** |
|
|
- Fashion design and visualization |
|
|
- Creative artwork and artistic expression |
|
|
- Educational and research purposes |
|
|
- Personal style exploration |
|
|
- Commercial fashion applications (with proper licensing) |
|
|
|
|
|
**β PROHIBITED USES:** |
|
|
- Creating deceptive or misleading content |
|
|
- Non-consensual image manipulation |
|
|
- Identity theft or impersonation |
|
|
- Harassment or bullying |
|
|
- Creation of inappropriate content |
|
|
- Any illegal or harmful activities |
|
|
|
|
|
### π Built-in Safety Features |
|
|
|
|
|
- **Content Filtering**: Automatic detection and prevention of inappropriate outputs |
|
|
- **Identity Preservation**: System designed to change clothing only, not faces |
|
|
- **Pose Validation**: Ensures generated content maintains appropriate poses |
|
|
- **Quality Thresholds**: Filters out low-quality or distorted results |
|
|
|
|
|
## ποΈ System Architecture |
|
|
|
|
|
### Core Components |
|
|
|
|
|
1. **Pose Extraction System** (25.3% coverage) |
|
|
- OpenPose-based pose detection via controlnet_aux |
|
|
- 5-channel pose vectors (Body, Hands, Face, Feet, Skeleton) |
|
|
- Dilated regions for enhanced coverage |
|
|
|
|
|
2. **Hand Exclusion Logic** |
|
|
- Prevents generation of extra hands/limbs |
|
|
- Conservative mask erosion with exclusion zones |
|
|
- Optimized for natural results |
|
|
|
|
|
3. **Safety-Aware Generation** |
|
|
- Content filtering for appropriate results |
|
|
- Coverage analysis for generation scope |
|
|
- Adaptive prompting based on input analysis |
|
|
|
|
|
4. **Checkpoint Compatibility** |
|
|
- Supports custom Stable Diffusion models |
|
|
- Automatic parameter optimization |
|
|
- Fashion-specific model recommendations |
|
|
|
|
|
## π Requirements |
|
|
|
|
|
```bash |
|
|
Python 3.8+ |
|
|
torch>=1.13.0 |
|
|
diffusers>=0.21.0 |
|
|
transformers>=4.21.0 |
|
|
controlnet_aux>=0.4.0 |
|
|
opencv-python>=4.6.0 |
|
|
pillow>=9.0.0 |
|
|
numpy>=1.21.0 |
|
|
``` |
|
|
|
|
|
## π Quick Start |
|
|
|
|
|
### Installation |
|
|
|
|
|
```bash |
|
|
# Clone the repository |
|
|
git clone https://github.com/mlworks90/fashion-inpainting-system.git |
|
|
cd fashion-inpainting-system |
|
|
|
|
|
# Install dependencies |
|
|
pip install -r requirements.txt |
|
|
|
|
|
# Optional: Install with CUDA support |
|
|
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118 |
|
|
``` |
|
|
|
|
|
### Basic Usage |
|
|
|
|
|
```python |
|
|
from fashion_safety_checker import create_fashion_safety_pipeline |
|
|
pipeline = create_fashion_safety_pipeline() |
|
|
|
|
|
# Transform outfit |
|
|
result = pipeline.safe_fashion_transformation( |
|
|
source_image_path="person_in_casual_wear.jpg", |
|
|
checkpoint_path="fashion_checkpoint.safetensors", |
|
|
outfit_prompt="elegant red evening dress", |
|
|
output_path="person_in_evening_dress.jpg", |
|
|
face_scale=0.90 # Manual face to body ratio adjustment |
|
|
) |
|
|
|
|
|
if result['success']: |
|
|
print("β
Fashion transformation completed") |
|
|
else: |
|
|
print(f"Blocking reason: {result['blocking_reason']}") |
|
|
print(f"User message: {result['user_message']}") |
|
|
``` |
|
|
|
|
|
## π Performance & Quality |
|
|
|
|
|
- **Pose Preservation**: 25.3% coverage ensures accurate body structure |
|
|
- **Face Identity**: >95% facial feature preservation |
|
|
- **Generation Speed**: ~30-60 seconds per image (depending on hardware) |
|
|
- **Memory Usage**: 8-12GB VRAM recommended |
|
|
- **Success Rate**: >85% for well-posed input images |
|
|
|
|
|
## π§ Configuration |
|
|
|
|
|
### Safety Settings |
|
|
|
|
|
```python |
|
|
pipeline = create_fashion_safety_pipeline(safety_mode="legacy_strict") |
|
|
# legacy_strict - highest safety restrictions |
|
|
# fashion_strict - conservative outfits only |
|
|
# fashion_moderate - default level. Suitable for most garment types except some swimwear. |
|
|
# fashion_permissive - most permissive mode. Be aware of inappropriate outputs possibility! |
|
|
|
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
## π§ͺ Examples |
|
|
|
|
|
### Fashion Transformations |
|
|
|
|
|
| Input | Target Prompt | Output | |
|
|
|-------|---------------|--------| |
|
|
| Casual wear | "elegant evening dress" |  | |
|
|
| Casual wear | "Business suit" |  | |
|
|
| Casual wear | "Business Costume" |  | |
|
|
|
|
|
## π’ Commercial Use & Support |
|
|
|
|
|
### Open Source License |
|
|
This project is licensed under **Apache License 2.0**, allowing: |
|
|
- β
Commercial use |
|
|
- β
Modification and distribution |
|
|
- β
Private use |
|
|
- β
Patent grant |
|
|
|
|
|
### Professional Services Available |
|
|
|
|
|
For commercial deployments, we offer: |
|
|
- **Custom model training** for specific fashion domains |
|
|
- **API integration** and cloud deployment |
|
|
- **Performance optimization** for production environments |
|
|
- **Priority support** and SLA guarantees |
|
|
- **Custom safety filtering** for brand-specific requirements |
|
|
|
|
|
Contact: [[email protected]](mailto:[email protected]) |
|
|
|
|
|
## π Documentation |
|
|
|
|
|
- [Installation Guide](docs/installation.md) |
|
|
- [API Reference](docs/api_reference.md) |
|
|
- [Safety Guidelines](docs/safety_guidelines.md) |
|
|
- [Troubleshooting](docs/troubleshooting.md) |
|
|
- [Commercial Licensing](docs/commercial_licensing.md) |
|
|
|
|
|
## π€ Contributing |
|
|
|
|
|
We welcome contributions! Please read our [Contributing Guidelines](CONTRIBUTING.md) and [Code of Conduct](CODE_OF_CONDUCT.md). |
|
|
|
|
|
### Development Setup |
|
|
|
|
|
```bash |
|
|
# Clone repository |
|
|
git clone https://github.com/mlworks90/fashion-inpainting-system.git |
|
|
cd fashion-inpainting-system |
|
|
|
|
|
# Install in development mode |
|
|
pip install -e . |
|
|
|
|
|
# Run tests |
|
|
python -m pytest tests/ |
|
|
``` |
|
|
|
|
|
## π Acknowledgments |
|
|
|
|
|
This system builds upon excellent open-source projects: |
|
|
- [Stable Diffusion](https://github.com/CompVis/stable-diffusion) by CompVis |
|
|
- [ControlNet](https://github.com/lllyasviel/ControlNet) by lllyasviel |
|
|
- [Diffusers](https://github.com/huggingface/diffusers) by Hugging Face |
|
|
- [controlnet_aux](https://github.com/patrickvonplaten/controlnet_aux) for OpenPose processing |
|
|
|
|
|
## π License |
|
|
|
|
|
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details. |
|
|
|
|
|
## βοΈ Legal & Safety Disclaimers |
|
|
|
|
|
- Users are responsible for ensuring appropriate use and obtaining necessary consents |
|
|
- This software is provided "as is" without warranty |
|
|
- Not intended for creating deceptive or harmful content |
|
|
- Users must comply with applicable laws and regulations |
|
|
- Commercial users should review terms and consider professional support |
|
|
|
|
|
## π Support & Contact |
|
|
|
|
|
- **Issues**: [GitHub Issues](https://github.com/mlworks90/fashion-inpainting-system/issues) |
|
|
- **Discussions**: [GitHub Discussions](https://github.com/mlworks90/fashion-inpainting-system/discussions) |
|
|
- **Commercial Inquiries**: [[email protected]](mailto:[email protected]) |
|
|
- **Documentation**: [Project Wiki](https://github.com/mlworks90/fashion-inpainting-system/wiki) |
|
|
|
|
|
--- |
|
|
|
|
|
**Made with β€οΈ for the AI and Fashion communities** |