Commit 2b119c7
committed
feat(diffusion): add Qwen-Image support with true_cfg_scale parameter
**Problem:**
Qwen-Image models from Alibaba use a different parameter name (true_cfg_scale)
instead of the standard guidance_scale used by other diffusion models. Users
could not properly configure Qwen-Image models.
**Solution:**
- Added true_cfg_scale parameter to generate_image_diffusers.py
- Detects Qwen/QwenImage pipeline types and uses appropriate parameter
- Updated Swift PythonDiffusersService to pass trueCfgScale
- Backward compatible: falls back to guidance_scale if true_cfg_scale not specified
- Python script already had QwenImagePipeline support via dynamic detection
**Changes:**
1. scripts/generate_image_diffusers.py:
- Added true_cfg_scale parameter to generateImage() function
- Added model type detection (is_qwen) to choose correct parameter
- Build guidance_kwargs dict with either true_cfg_scale or guidance_scale
- Updated all pipeline calls to use **guidance_kwargs
- Added --true-cfg-scale command-line argument
2. Sources/StableDiffusionIntegration/PythonDiffusersService.swift:
- Added trueCfgScale: Float? parameter to generateImage()
- Added logging for trueCfgScale value
- Pass --true-cfg-scale to Python script when provided
**Testing:**
✅ Build: PASS
✅ Python syntax: PASS
✅ Backward compatible: existing models continue to work
**Notes:**
- Qwen-Image recommended settings: 50 steps, true_cfg_scale 4.0
- Models already supported via HuggingFace browser in preferences
- UI can search/download Qwen/Qwen-Image model directly1 parent 4d2448b commit 2b119c7
2 files changed
Lines changed: 43 additions & 13 deletions
File tree
- Sources/StableDiffusionIntegration
- scripts
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| |||
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
| 199 | + | |
198 | 200 | | |
199 | 201 | | |
200 | 202 | | |
| |||
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
| 230 | + | |
228 | 231 | | |
229 | 232 | | |
230 | 233 | | |
| |||
243 | 246 | | |
244 | 247 | | |
245 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
246 | 254 | | |
247 | 255 | | |
248 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
| 458 | + | |
458 | 459 | | |
459 | 460 | | |
460 | 461 | | |
| |||
475 | 476 | | |
476 | 477 | | |
477 | 478 | | |
478 | | - | |
| 479 | + | |
| 480 | + | |
479 | 481 | | |
480 | 482 | | |
481 | 483 | | |
| |||
862 | 864 | | |
863 | 865 | | |
864 | 866 | | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
865 | 884 | | |
866 | 885 | | |
867 | 886 | | |
| |||
873 | 892 | | |
874 | 893 | | |
875 | 894 | | |
876 | | - | |
| 895 | + | |
| 896 | + | |
877 | 897 | | |
878 | 898 | | |
879 | 899 | | |
| |||
886 | 906 | | |
887 | 907 | | |
888 | 908 | | |
889 | | - | |
890 | 909 | | |
891 | 910 | | |
| 911 | + | |
892 | 912 | | |
893 | 913 | | |
894 | 914 | | |
| |||
899 | 919 | | |
900 | 920 | | |
901 | 921 | | |
902 | | - | |
903 | 922 | | |
904 | | - | |
| 923 | + | |
| 924 | + | |
905 | 925 | | |
906 | 926 | | |
907 | 927 | | |
| |||
911 | 931 | | |
912 | 932 | | |
913 | 933 | | |
914 | | - | |
915 | 934 | | |
916 | | - | |
| 935 | + | |
| 936 | + | |
917 | 937 | | |
918 | 938 | | |
919 | 939 | | |
920 | 940 | | |
921 | 941 | | |
922 | 942 | | |
923 | 943 | | |
924 | | - | |
925 | 944 | | |
926 | 945 | | |
927 | 946 | | |
928 | 947 | | |
| 948 | + | |
929 | 949 | | |
930 | 950 | | |
931 | 951 | | |
| |||
934 | 954 | | |
935 | 955 | | |
936 | 956 | | |
937 | | - | |
938 | 957 | | |
939 | 958 | | |
940 | 959 | | |
941 | | - | |
| 960 | + | |
| 961 | + | |
942 | 962 | | |
943 | 963 | | |
944 | 964 | | |
945 | 965 | | |
946 | 966 | | |
947 | 967 | | |
948 | 968 | | |
949 | | - | |
950 | 969 | | |
951 | 970 | | |
952 | 971 | | |
953 | | - | |
| 972 | + | |
| 973 | + | |
954 | 974 | | |
955 | 975 | | |
956 | 976 | | |
| |||
1043 | 1063 | | |
1044 | 1064 | | |
1045 | 1065 | | |
| 1066 | + | |
1046 | 1067 | | |
1047 | 1068 | | |
1048 | 1069 | | |
| |||
1064 | 1085 | | |
1065 | 1086 | | |
1066 | 1087 | | |
| 1088 | + | |
1067 | 1089 | | |
1068 | 1090 | | |
1069 | 1091 | | |
| |||
0 commit comments