lulavc commited on
Commit
0c49c49
Β·
verified Β·
1 Parent(s): 112ff7a

Update title, subtitle, and tags

Browse files
Files changed (1) hide show
  1. README.md +94 -179
README.md CHANGED
@@ -1,190 +1,105 @@
1
  ---
2
- title: Z Image Turbo
3
- emoji: πŸš€
4
  colorFrom: purple
5
  colorTo: pink
6
  sdk: gradio
7
- sdk_version: "4.20.0"
8
  app_file: app.py
9
- pinned: false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  ---
11
 
12
- # Z Image Turbo - Production Edition
13
-
14
- A production-ready, optimized image generation and transformation application built with Gradio and Diffusers. This application addresses common production challenges including error handling, resource management, and performance optimization.
15
-
16
- ## πŸš€ Features
17
 
18
- ### Core Functionality
19
- - **Image Generation**: Create high-quality images from text prompts
20
- - **Image Transformation**: Modify existing images with AI guidance
21
- - **Multiple Styles**: Apply artistic styles to generations
22
- - **Aspect Ratios**: Support for various image dimensions
23
-
24
- ### Production Optimizations
25
- - βœ… **PyTorch 2.0+ Compilation** with graceful fallback for older versions
26
- - βœ… **xformers Memory Optimization** with CPU fallback when not available
27
- - βœ… **Dynamic Resource Management** with CPU offloading for memory-constrained environments
28
- - βœ… **Intelligent Caching System** with LRU eviction and TTL
29
- - βœ… **Comprehensive Error Handling** with user-friendly messages
30
- - βœ… **Real-time System Monitoring** with performance metrics
31
- - βœ… **Modular Architecture** with clear separation of concerns
32
-
33
- ## πŸ“‹ System Requirements
34
-
35
- ### Minimum Requirements
36
- - Python 3.9+
37
- - GPU with 6GB+ VRAM (recommended)
38
- - 8GB+ RAM
39
- - 10GB+ disk space
40
-
41
- ### Recommended
42
- - GPU with 12GB+ VRAM
43
- - PyTorch 2.0+ for optimal performance
44
- - xformers installed for memory efficiency
45
-
46
- ## πŸ”§ Configuration
47
-
48
- ### Environment Variables
49
- ```bash
50
- # Optional: Override default settings
51
- HF_TOKEN=your_huggingface_token
52
- CUDA_VISIBLE_DEVICES=0
53
- PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:128
54
- ```
55
-
56
- ### Performance Tuning
57
- The application automatically optimizes based on available hardware:
58
- - Detects optimal data type (bfloat16/float16/float32)
59
- - Enables CPU offloading for limited GPU memory
60
- - Adjusts batch sizes and concurrency limits
61
-
62
- ## πŸ“Š Monitoring
63
-
64
- ### System Metrics
65
- - Memory usage (CPU and GPU)
66
- - CPU utilization
67
- - Generation count and success rate
68
- - Cache hit rate
69
- - Uptime and error tracking
70
-
71
- ### Health Checks
72
- The application provides comprehensive health monitoring with real-time metrics tracking.
73
-
74
- ## πŸ› Troubleshooting
75
-
76
- ### Common Issues
77
-
78
- #### 1. "Out of Memory" Error
79
- **Solution**: The app automatically handles OOM scenarios and suggests:
80
- - Using smaller image sizes
81
- - Enabling CPU offloading
82
- - Restarting the space
83
-
84
- #### 2. "Could not compile UNet" Warning
85
- **Expected Behavior**: This is normal for PyTorch < 2.0. The app continues without compilation.
86
-
87
- #### 3. "Could not enable xformers" Warning
88
- **Expected Behavior**: Falls back to standard attention mechanism.
89
-
90
- #### 4. Slow Generation
91
- **Check**:
92
- - GPU memory availability
93
- - Model loading status
94
- - System resource usage
95
-
96
- ### Logs
97
- The application logs to:
98
- - Console output for real-time monitoring
99
- - `z_image_turbo.log` file for persistent logs
100
-
101
- ## 🎯 Best Practices
102
-
103
- ### For Users
104
- 1. **Start with simple prompts** to test performance
105
- 2. **Use appropriate image sizes** for your hardware
106
- 3. **Leverage caching** by reusing similar prompts
107
- 4. **Monitor system resources** in the System Monitor tab
108
-
109
- ### For Developers
110
- 1. **Check error codes** for debugging
111
- 2. **Monitor performance metrics** regularly
112
- 3. **Use the health check endpoint** for monitoring
113
- 4. **Review logs** for troubleshooting
114
-
115
- ## πŸ” Error Codes
116
-
117
- | Code | Meaning | Resolution |
118
- |------|---------|------------|
119
- | 1001 | Model Load Error | Check model access and permissions |
120
- | 1002 | Generation Error | Check prompt and resources |
121
- | 1003 | Transform Error | Verify input image and prompt |
122
- | 2001 | Invalid Input | Check input parameters |
123
- | 3001 | Resource Error | Free up memory or use smaller images |
124
- | 4001 | Network Error | Check internet connection |
125
- | 5001 | Cache Error | Clear cache or restart |
126
- | 9999 | Unknown Error | Check logs for details |
127
-
128
- ## πŸ“ˆ Performance Optimization
129
-
130
- ### Automatic Optimizations
131
- 1. **Model Compilation**: PyTorch 2.0+ compilation when available
132
- 2. **Memory Efficiency**: xformers attention and VAE slicing
133
- 3. **Resource Management**: CPU offloading for memory constraints
134
- 4. **Smart Caching**: LRU cache with intelligent eviction
135
-
136
- ### Manual Tuning
137
- - Adjust `max_size` in CacheManager for memory/concurrency balance
138
- - Modify inference steps for quality/speed trade-off
139
- - Use aspect ratios that match your hardware capabilities
140
-
141
- ## πŸ” Security
142
-
143
- ### Best Practices
144
- - No user data is persisted beyond cache TTL
145
- - Images are not stored permanently
146
- - API keys are environment variables only
147
- - Safe tensor format for model weights
148
-
149
- ## πŸ“ Changelog
150
-
151
- ### v2.0.0 Production
152
- - **Added**: Comprehensive error handling with error codes
153
- - **Added**: PyTorch 2.0+ compilation with fallback
154
- - **Added**: xformers optimization with CPU fallback
155
- - **Added**: Intelligent caching system with LRU and TTL
156
- - **Added**: Real-time system monitoring
157
- - **Added**: Production-ready logging
158
- - **Added**: Health check endpoints
159
- - **Improved**: Resource management and cleanup
160
- - **Improved**: User experience with better error messages
161
- - **Improved**: Performance with automatic optimizations
162
-
163
- ### v1.0.0 Initial
164
- - Basic image generation
165
- - Simple UI
166
- - Model integration
167
-
168
- ## 🀝 Contributing
169
-
170
- When contributing:
171
- 1. Follow PEP 8 style guidelines
172
- 2. Add comprehensive error handling
173
- 3. Include logging for debugging
174
- 4. Update documentation
175
- 5. Test with various hardware configurations
176
-
177
- ## πŸ“„ License
178
-
179
- This project is licensed under the MIT License.
180
-
181
- ## πŸ™ Acknowledgments
182
-
183
- - [Tongyi-MAI/Z-Image-Turbo](https://huggingface.co/Tongyi-MAI/Z-Image-Turbo) for the base model
184
- - [Diffusers](https://github.com/huggingface/diffusers) library
185
- - [Gradio](https://github.com/gradio-app/gradio) for the UI framework
186
- - Hugging Face Spaces for hosting
187
 
188
  ---
189
 
190
- **Created with ❀️ by AI Agent Framework Specialist**
 
1
  ---
2
+ title: Z-Image Turbo + GLM-4.6V / DeepSeek-3.2 Thinking
3
+ emoji: 🎨
4
  colorFrom: purple
5
  colorTo: pink
6
  sdk: gradio
7
+ sdk_version: 5.31.0
8
  app_file: app.py
9
+ pinned: true
10
+ license: apache-2.0
11
+ tags:
12
+ - text-to-image
13
+ - image-to-image
14
+ - diffusion
15
+ - transformer
16
+ - z-image
17
+ - z-image-turbo
18
+ - ai-art
19
+ - image-generation
20
+ - image-editing
21
+ - glm-4
22
+ - glm-4.6v
23
+ - glm-4v
24
+ - vision-language
25
+ - multimodal
26
+ - prompt-generation
27
+ - ai-assistant
28
+ - zhipu
29
+ - zai
30
+ - deepseek
31
+ - deepseek-reasoner
32
+ - deepseek-3.2
33
+ - thinking
34
+ - reasoning
35
+ - multilingual
36
+ - rtl
37
+ - arabic
38
+ - hindi
39
+ - spanish
40
+ - portuguese
41
+ short_description: Image Gen & Edit with GLM-4.6V + DeepSeek-3.2
42
  ---
43
 
44
+ # ⚑ Z-Image Generation & Transformation Demo
 
 
 
 
45
 
46
+ Generate stunning AI images and transform existing photos using **Alibaba's Z-Image-Turbo** - a next-generation diffusion transformer model.
47
+
48
+ ## ✨ Features
49
+
50
+ 🎨 **Text-to-Image Generation**
51
+ - 10 style presets (Photorealistic, Cinematic, Anime, Digital Art, and more)
52
+ - 18 aspect ratios from 1024px to 2048px
53
+ - AI-powered prompt polishing with Qwen2.5-72B
54
+
55
+ πŸ–ΌοΈ **Image-to-Image Transformation**
56
+ - Transform photos into different art styles
57
+ - Adjustable strength control (subtle to complete change)
58
+ - Style-focused AI prompt enhancement
59
+
60
+ ⚑ **Optimized Performance**
61
+ - Runs on ZeroGPU (NVIDIA H200)
62
+ - FlashAttention-2 via SDPA
63
+ - ~20-25 seconds per generation
64
+
65
+ ## πŸš€ How to Use
66
+
67
+ ### Generate Tab
68
+ 1. Enter a description of your image
69
+ 2. (Optional) Enable "Polish Prompt" for AI-enhanced prompts
70
+ 3. Select a style and aspect ratio
71
+ 4. Click "Generate"
72
+
73
+ ### Transform Tab
74
+ 1. Upload an image
75
+ 2. Describe the transformation you want
76
+ 3. Adjust strength (lower = subtle, higher = dramatic)
77
+ 4. Click "Transform"
78
+
79
+ ## 🎯 Example Prompts
80
+
81
+ - *"Ancient dragon perched on a Gothic cathedral at dusk, stormy purple sky"*
82
+ - *"Cyberpunk samurai in a neon-lit rainy alley, glowing armor"*
83
+ - *"Cozy witch cottage interior, cauldrons bubbling, magical atmosphere"*
84
+
85
+ ## πŸ“Š Technical Details
86
+
87
+ | Spec | Value |
88
+ |------|-------|
89
+ | Model | Tongyi-MAI/Z-Image-Turbo |
90
+ | Steps | 9 (optimized) |
91
+ | Precision | BFloat16 |
92
+ | Max Resolution | 2048x2048 |
93
+
94
+ ## πŸ”— Links
95
+
96
+ - [Z-Image-Turbo Model](https://huggingface.co/Tongyi-MAI/Z-Image-Turbo)
97
+ - [Z-Image GitHub](https://github.com/Tongyi-MAI/Z-Image)
98
+
99
+ ## πŸ“œ License
100
+
101
+ Model: Apache 2.0 License
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  ---
104
 
105
+ **Created by [@lulavc](https://huggingface.co/lulavc)**