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
File size: 8,464 Bytes
e6c2e33 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | """
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") |