Instructions to use mlworks90/fashion-inpainting-system with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use mlworks90/fashion-inpainting-system with Diffusers:
pip install -U diffusers transformers accelerate
from diffusers import ControlNetModel, StableDiffusionControlNetPipeline controlnet = ControlNetModel.from_pretrained("mlworks90/fashion-inpainting-system") pipe = StableDiffusionControlNetPipeline.from_pretrained( "runwayml/stable-diffusion-v1-5", controlnet=controlnet ) - Notebooks
- Google Colab
- Kaggle
| """ | |
| Fashion Inpainting System - Example Implementation | |
| Correct usage of the fashion_safety_checker API | |
| """ | |
| from fashion_safety_checker import create_fashion_safety_pipeline | |
| def main(): | |
| """ | |
| Example usage of the Fashion Inpainting System | |
| """ | |
| # Initialize the fashion safety pipeline | |
| pipeline = create_fashion_safety_pipeline() | |
| # Example 1: Basic transformation | |
| print("π¨ Basic Fashion Transformation") | |
| result = pipeline.safe_fashion_transformation( | |
| source_image_path="examples/person_in_casual_wear.jpg", | |
| checkpoint_path="checkpoints/realistic_vision_v2.safetensors", | |
| outfit_prompt="elegant red evening dress", | |
| output_path="outputs/red_evening_dress_result.jpg", | |
| face_scale=0.90 # Manual face to body ratio adjustment | |
| ) | |
| if result['success']: | |
| print("β Fashion transformation completed successfully") | |
| print(f"Output saved to: {result.get('output_path', 'outputs/red_evening_dress_result.jpg')}") | |
| else: | |
| print("β Transformation blocked by safety system") | |
| print(f"Blocking reason: {result['blocking_reason']}") | |
| print(f"User message: {result['user_message']}") | |
| print("-" * 50) | |
| # Example 2: Different outfit style | |
| print("π¨ Business Outfit Transformation") | |
| result = pipeline.safe_fashion_transformation( | |
| source_image_path="examples/person_in_casual_wear.jpg", | |
| checkpoint_path="checkpoints/fashion_professional_v1.safetensors", | |
| outfit_prompt="professional business suit, navy blue, elegant", | |
| output_path="outputs/business_suit_result.jpg", | |
| face_scale=0.85 | |
| ) | |
| if result['success']: | |
| print("β Business transformation completed") | |
| else: | |
| print("β Business transformation blocked") | |
| print(f"Reason: {result['blocking_reason']}") | |
| print(f"Message: {result['user_message']}") | |
| print("-" * 50) | |
| # Example 3: Swimwear (requires appropriate safety level) | |
| print("π¨ Swimwear Transformation (Professional Use)") | |
| result = pipeline.safe_fashion_transformation( | |
| source_image_path="examples/person_in_casual_wear.jpg", | |
| checkpoint_path="checkpoints/fashion_permissive_v1.safetensors", | |
| outfit_prompt="elegant one-piece swimsuit, professional fashion photography", | |
| output_path="outputs/swimwear_result.jpg", | |
| face_scale=0.92 | |
| ) | |
| if result['success']: | |
| print("β Swimwear transformation completed") | |
| else: | |
| print("β Swimwear transformation blocked") | |
| print(f"Reason: {result['blocking_reason']}") | |
| print(f"Message: {result['user_message']}") | |
| print("-" * 50) | |
| # Example 4: Error handling for missing files | |
| print("π¨ Error Handling Example") | |
| result = pipeline.safe_fashion_transformation( | |
| source_image_path="examples/nonexistent_image.jpg", # This will fail | |
| checkpoint_path="checkpoints/some_checkpoint.safetensors", | |
| outfit_prompt="casual summer dress", | |
| output_path="outputs/error_test.jpg", | |
| face_scale=0.90 | |
| ) | |
| if result['success']: | |
| print("β This shouldn't happen") | |
| else: | |
| print("β Expected error occurred") | |
| print(f"Reason: {result['blocking_reason']}") | |
| print(f"Message: {result['user_message']}") | |
| def advanced_usage_examples(): | |
| """ | |
| Advanced usage examples with different parameters | |
| """ | |
| pipeline = create_fashion_safety_pipeline() | |
| # Example with different face scales | |
| face_scales = [0.80, 0.85, 0.90, 0.95] | |
| for i, scale in enumerate(face_scales): | |
| print(f"π¨ Testing face_scale={scale}") | |
| result = pipeline.safe_fashion_transformation( | |
| source_image_path="examples/test_subject.jpg", | |
| checkpoint_path="checkpoints/fashion_moderate.safetensors", | |
| outfit_prompt="classic white shirt and dark jeans", | |
| output_path=f"outputs/face_scale_test_{scale}.jpg", | |
| face_scale=scale | |
| ) | |
| if result['success']: | |
| print(f"β face_scale={scale} completed successfully") | |
| else: | |
| print(f"β face_scale={scale} failed: {result['blocking_reason']}") | |
| def batch_processing_example(): | |
| """ | |
| Example of processing multiple transformations | |
| """ | |
| pipeline = create_fashion_safety_pipeline() | |
| # Batch transformation scenarios | |
| transformations = [ | |
| { | |
| "source": "examples/person1.jpg", | |
| "checkpoint": "checkpoints/casual_wear.safetensors", | |
| "prompt": "comfortable jeans and cozy sweater", | |
| "output": "outputs/person1_casual.jpg", | |
| "face_scale": 0.90 | |
| }, | |
| { | |
| "source": "examples/person2.jpg", | |
| "checkpoint": "checkpoints/formal_wear.safetensors", | |
| "prompt": "elegant black evening gown", | |
| "output": "outputs/person2_formal.jpg", | |
| "face_scale": 0.88 | |
| }, | |
| { | |
| "source": "examples/person3.jpg", | |
| "checkpoint": "checkpoints/business_wear.safetensors", | |
| "prompt": "professional gray suit with blue tie", | |
| "output": "outputs/person3_business.jpg", | |
| "face_scale": 0.85 | |
| } | |
| ] | |
| successful_transformations = 0 | |
| failed_transformations = 0 | |
| for i, transform in enumerate(transformations): | |
| print(f"π¨ Processing transformation {i+1}/{len(transformations)}") | |
| result = pipeline.safe_fashion_transformation( | |
| source_image_path=transform["source"], | |
| checkpoint_path=transform["checkpoint"], | |
| outfit_prompt=transform["prompt"], | |
| output_path=transform["output"], | |
| face_scale=transform["face_scale"] | |
| ) | |
| if result['success']: | |
| successful_transformations += 1 | |
| print(f"β Transformation {i+1} completed") | |
| else: | |
| failed_transformations += 1 | |
| print(f"β Transformation {i+1} failed: {result['blocking_reason']}") | |
| print(f"\nπ Batch Processing Results:") | |
| print(f"β Successful: {successful_transformations}") | |
| print(f"β Failed: {failed_transformations}") | |
| print(f"π Success Rate: {successful_transformations/len(transformations)*100:.1f}%") | |
| def safety_level_examples(): | |
| """ | |
| Examples demonstrating different safety behaviors | |
| """ | |
| pipeline = create_fashion_safety_pipeline() | |
| # Test different prompts with safety implications | |
| test_cases = [ | |
| ("conservative business outfit", "Should pass all safety levels"), | |
| ("summer beach dress", "Should pass moderate and permissive"), | |
| ("elegant swimwear", "May require permissive safety level"), | |
| ("inappropriate content", "Should be blocked by safety system") | |
| ] | |
| for prompt, expectation in test_cases: | |
| print(f"\nπ§ͺ Testing prompt: '{prompt}'") | |
| print(f" Expected: {expectation}") | |
| result = pipeline.safe_fashion_transformation( | |
| source_image_path="examples/test_image.jpg", | |
| checkpoint_path="checkpoints/general_fashion.safetensors", | |
| outfit_prompt=prompt, | |
| output_path=f"outputs/safety_test_{prompt.replace(' ', '_')}.jpg", | |
| face_scale=0.90 | |
| ) | |
| if result['success']: | |
| print(f" β Result: Transformation completed") | |
| else: | |
| print(f" β Result: Blocked - {result['blocking_reason']}") | |
| print(f" π¬ Message: {result['user_message']}") | |
| if __name__ == "__main__": | |
| print("π¨ Fashion Inpainting System - Example Usage\n") | |
| # Run basic examples | |
| main() | |
| print("\n" + "="*60) | |
| print("Advanced Examples") | |
| print("="*60) | |
| # Uncomment to run advanced examples | |
| # advanced_usage_examples() | |
| # batch_processing_example() | |
| # safety_level_examples() | |
| print("\n⨠Examples completed!") | |
| print("π For more information, see the documentation at:") | |
| print(" GitHub: https://github.com/your-org/fashion-inpainting-system") | |
| print(" Hugging Face: https://huggingface.co/your-org/fashion-inpainting-system") |