ogkalu2 / Merge-Stable-Diffusion-models-without-distortion

Adaptation of the merging method described in the paper - Git Re-Basin: Merging Models modulo Permutation Symmetries (https://arxiv.org/abs/2209.04836) for Stable Diffusion
MIT License
139 stars 21 forks source link

After running for a while, get error #1

Open Dawgmastah opened 1 year ago

Dawgmastah commented 1 year ago

Error is:

0/P_model.diffusion_model.output_blocks.6.0_inner3: 0.0 0/P_model.diffusion_model.output_blocks.4.0_inner2: 0.0 0/P_bg371: 0.0 0/P_bg206: 0.0 0/P_model.diffusion_model.output_blocks.6.0_inner2: 0.0

Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 27, in updated_params = unflatten_params(apply_permutation(permutation_spec, final_permutation, flatten_params(state_b))) File "X:\AIMODELS\weight_matching.py", line 786, in apply_permutation return {k: get_permuted_param(ps, perm, k, params) for k in params.keys()} File "X:\AIMODELS\weight_matching.py", line 786, in return {k: get_permuted_param(ps, perm, k, params) for k in params.keys()} File "X:\AIMODELS\weight_matching.py", line 773, in get_permuted_param for axis, p in enumerate(ps.axes_to_perm[k]): KeyError: 'first_stage_model.decoder.conv_in.weight'

Dawgmastah commented 1 year ago

Pasting whole log here:

(merging) X:\AIMODELS>python SD_rebasin_merge.py --model_a berry_mix.ckpt --model_b f22XXXXSelenagomez8_5000.ckpt 0/P_bg401: 0.0 0/P_model.diffusion_model.output_blocks.2.0_inner2: 0.0 0/P_bg249: 0.0 0/P_bg373: 0.0 0/P_bg257: 0.0 0/P_bg142: 0.0 0/P_bg45: 0.0 0/P_model.diffusion_model.output_blocks.10.0_inner: 0.0 0/P_bg6: 0.0 0/P_model.diffusion_model.output_blocks.0.0_inner2: 0.0 0/P_bg222: 0.0 0/P_model.diffusion_model.input_blocks.1.0_inner: 0.0 0/P_bg253: 0.0 0/P_first_stage_model.encoder.down.2.block.1_inner: 0.0 0/P_bg229: 0.0 0/P_bg95: 0.0 0/P_bg105: 0.0 0/P_bg51: 0.0 0/P_bg160: 0.0 0/P_bg90: 0.0 0/P_bg312: 0.0 0/P_bg146: 0.0 0/P_first_stage_model.encoder.down.3.block.0_inner: 0.0 0/P_bg165: 0.0 0/P_bg198: 0.0 0/P_bg58: 0.0 0/P_first_stage_model.decoder.up.2.block.0_inner: 0.0 0/P_bg337: 0.0 0/P_bg403: 0.0 0/P_bg73: 0.0 0/P_model.diffusion_model.output_blocks.6.0_inner4: 0.0 0/P_model.diffusion_model.output_blocks.7.0_inner3: 0.0 0/P_bg189: 0.0 0/P_bg53: 0.0 0/P_model.diffusion_model.input_blocks.11.0_inner: 0.0 0/P_model.diffusion_model.output_blocks.5.0_inner3: 0.0 0/P_model.diffusion_model.output_blocks.2.0_inner4: 0.0 0/P_bg227: 0.0 0/P_bg256: 0.0 0/P_bg283: 0.0 0/P_bg157: 0.0 0/P_bg0: 0.0 0/P_bg376: 0.0 0/P_bg92: 0.0 0/P_bg134: 0.0 0/P_first_stage_model.encoder.down.3.block.1_inner: 0.0 0/P_bg89: 0.0 0/P_bg36: 0.0 0/P_bg389: 0.0 0/P_bg50: 0.0 0/P_model.diffusion_model.input_blocks.11.0_inner4: 0.0 0/P_bg278: 0.0 0/P_first_stage_model.encoder.down.0.block.0_inner: 0.0 0/P_bg288: 0.0 0/P_model.diffusion_model.output_blocks.9.0_inner2: 0.0 0/P_bg269: 0.0 0/P_model.diffusion_model.middle_block.0_inner3: 0.0 0/P_bg323: 0.0 0/P_first_stage_model.encoder.down.0.block.1_inner: 0.0 0/P_bg167: 0.0 0/P_bg188: 0.0 0/P_bg106: 0.0 0/P_model.diffusion_model.output_blocks.6.0_inner: 0.0 0/P_model.diffusion_model.middle_block.0_inner: 0.0 0/P_bg5: 0.0 0/P_model.diffusion_model.input_blocks.5.0_inner: 0.0 0/P_model.diffusion_model.input_blocks.1.0_inner2: 0.0 0/P_bg336: 0.0 0/P_bg71: 0.0 0/P_bg334: 0.0 0/P_first_stage_model.decoder.up.3.block.0_inner: 0.0 0/P_bg390: 0.0 0/P_bg212: 0.0 0/P_bg311: 0.0 0/P_bg117: 0.0 0/P_bg102: 0.0 0/P_bg217: 0.0 0/P_bg155: 0.0 0/P_bg351: 0.0 0/P_model.diffusion_model.output_blocks.0.0_inner3: 0.0 0/P_bg67: 0.0 0/P_bg388: 0.0 0/P_bg387: 0.0 0/P_bg44: 0.0 0/P_bg366: 0.0 0/P_first_stage_model.decoder.up.2.block.1_inner: 0.0 0/P_bg262: 0.0 0/P_model.diffusion_model.input_blocks.11.0_inner3: 0.0 0/P_bg302: 0.0 0/P_bg201: 0.0 0/P_bg255: 0.0 0/P_bg407: 0.0 0/P_bg18: 0.0 0/P_bg340: 0.0 0/P_bg150: 0.0 0/P_bg12: 0.0 0/P_bg358: 0.0 0/P_model.diffusion_model.input_blocks.7.0_inner3: 0.0 0/P_bg180: 0.0 0/P_first_stage_model.decoder.up.0.block.0_inner: 0.0 0/P_bg220: 0.0 0/P_model.diffusion_model.middle_block.2_inner3: 0.0 0/P_model.diffusion_model.input_blocks.8.0_inner: 0.0 0/P_bg115: 0.0 0/P_bg131: 0.0 0/P_bg377: 0.0 0/P_bg207: 0.0 0/P_bg261: 0.0 0/P_model.diffusion_model.middle_block.2_inner: 0.0 0/P_bg310: 0.0 0/P_bg163: 0.0 0/P_bg172: 0.0 0/P_bg116: 0.0 0/P_model.diffusion_model.input_blocks.4.0_inner: 0.0 0/P_bg175: 0.0 0/P_bg173: 0.0 0/P_bg309: 0.0 0/P_bg126: 0.0 0/P_bg320: 0.0 0/P_bg300: 0.0 0/P_bg321: 0.0 0/P_model.diffusion_model.middle_block.2_inner2: 0.0 0/P_bg395: 0.0 0/P_bg61: 0.0 0/P_bg192: 0.0 0/P_bg308: 0.0 0/P_bg290: 0.0 0/P_bg46: 0.0 0/P_bg177: 0.0 0/P_bg34: 0.0 0/P_bg136: 0.0 0/P_model.diffusion_model.output_blocks.3.0_inner4: 0.0 0/P_bg385: 0.0 0/P_bg314: 0.0 0/P_model.diffusion_model.input_blocks.5.0_inner3: 0.0 0/P_bg364: 0.0 0/P_bg369: 0.0 0/P_bg406: 0.0 0/P_bg86: 0.0 0/P_bg65: 0.0 0/P_model.diffusion_model.output_blocks.4.0_inner: 0.0 0/P_bg170: 0.0 0/P_bg325: 0.0 0/P_bg7: 0.0 0/P_bg271: 0.0 0/P_bg224: 0.0 0/P_bg237: 0.0 0/P_bg235: 0.0 0/P_bg378: 0.0 0/P_bg359: 0.0 0/P_bg130: 0.0 0/P_bg360: 0.0 0/P_model.diffusion_model.output_blocks.7.0_inner2: 0.0 0/P_bg296: 0.0 0/P_bg74: 0.0 0/P_bg24: 0.0 0/P_model.diffusion_model.output_blocks.9.0_inner3: 0.0 0/P_bg260: 0.0 0/P_bg153: 0.0 0/P_bg221: 0.0 0/P_bg195: 0.0 0/P_bg37: 0.0 0/P_model.diffusion_model.output_blocks.1.0_inner3: 0.0 0/P_bg365: 0.0 0/P_bg335: 0.0 0/P_bg231: 0.0 0/P_bg233: 0.0 0/P_bg152: 0.0 0/P_bg11: 0.0 0/P_model.diffusion_model.output_blocks.11.0_inner4: 0.0 0/P_bg331: 0.0 0/P_bg94: 0.0 0/P_bg26: 0.0 0/P_bg372: 0.0 0/P_bg64: 0.0 0/P_bg259: 0.0 0/P_bg193: 0.0 0/P_bg370: 0.0 0/P_first_stage_model.decoder.up.1.block.0_inner: 0.0 0/P_bg341: 0.0 0/P_bg32: 0.0 0/P_bg273: 0.0 0/P_bg205: 0.0 0/P_bg120: 0.0 0/P_bg281: 0.0 0/P_bg247: 0.0 0/P_bg342: 0.0 0/P_bg184: 0.0 0/P_model.diffusion_model.input_blocks.10.0_inner4: 0.0 0/P_bg43: 0.0 0/P_model.diffusion_model.input_blocks.8.0_inner2: 0.0 0/P_bg238: 0.0 0/P_bg333: 0.0 0/P_bg297: 0.0 0/P_bg345: 0.0 0/P_bg398: 0.0 0/P_first_stage_model.decoder.up.1.block.1_inner: 0.0 0/P_bg279: 0.0 0/P_bg246: 0.0 0/P_first_stage_model.encoder.mid.block_1_inner: 0.0 0/P_bg344: 0.0 0/P_bg9: 0.0 0/P_bg59: 0.0 0/P_bg127: 0.0 0/P_bg3: 0.0 0/P_bg252: 0.0 0/P_bg35: 0.0 0/P_bg42: 0.0 0/P_bg368: 0.0 0/P_bg47: 0.0 0/P_bg68: 0.0 0/P_model.diffusion_model.input_blocks.8.0_inner4: 0.0 0/P_bg151: 0.0 0/P_bg25: 0.0 0/P_bg371: 0.0 0/P_bg250: 0.0 0/P_bg162: 0.0 0/P_bg182: 0.0 0/P_bg287: 0.0 0/P_bg214: 0.0 0/P_model.diffusion_model.output_blocks.3.0_inner3: 0.0 0/P_bg69: 0.0 0/P_bg196: 0.0 0/P_bg49: 0.0 0/P_first_stage_model.decoder.up.0.block.1_inner: 0.0 0/P_bg107: 0.0 0/P_bg40: 0.0 0/P_bg16: 0.0 0/P_first_stage_model.encoder.mid.block_2_inner: 0.0 0/P_bg133: 0.0 0/P_bg356: 0.0 0/P_model.diffusion_model.input_blocks.8.0_inner3: 0.0 0/P_model.diffusion_model.input_blocks.2.0_inner4: 0.0 0/P_model.diffusion_model.output_blocks.1.0_inner4: 0.0 0/P_model.diffusion_model.output_blocks.9.0_inner: 0.0 0/P_bg402: 0.0 0/P_bg13: 0.0 0/P_bg19: 0.0 0/P_bg156: 0.0 0/P_bg125: 0.0 0/P_bg317: 0.0 0/P_bg383: 0.0 0/P_bg176: 0.0 0/P_bg380: 0.0 0/P_model.diffusion_model.input_blocks.4.0_inner4: 0.0 0/P_bg375: 0.0 0/P_bg166: 0.0 0/P_bg145: 0.0 0/P_bg280: 0.0 0/P_bg346: 0.0 0/P_bg397: 0.0 0/P_model.diffusion_model.output_blocks.7.0_inner: 0.0 0/P_bg254: 0.0 0/P_model.diffusion_model.output_blocks.9.0_inner4: 0.0 0/P_model.diffusion_model.input_blocks.2.0_inner2: 0.0 0/P_bg286: 0.0 0/P_first_stage_model.encoder.down.1.block.0_inner: 0.0 0/P_bg85: 0.0 0/P_bg243: 0.0 0/P_bg263: 0.0 0/P_bg241: 0.0 0/P_bg232: 0.0 0/P_bg197: 0.0 0/P_bg164: 0.0 0/P_bg98: 0.0 0/P_bg394: 0.0 0/P_bg392: 0.0 0/P_bg60: 0.0 0/P_bg161: 0.0 0/P_bg112: 0.0 0/P_first_stage_model.decoder.mid.block_1_inner: 0.0 0/P_bg27: 0.0 0/P_model.diffusion_model.input_blocks.2.0_inner: 0.0 0/P_bg22: 0.0 0/P_bg400: 0.0 0/P_bg200: 0.0 0/P_bg285: 0.0 0/P_model.diffusion_model.input_blocks.7.0_inner: 0.0 0/P_bg219: 0.0 0/P_bg100: 0.0 0/P_bg393: 0.0 0/P_model.diffusion_model.output_blocks.0.0_inner4: 0.0 0/P_bg70: 0.0 0/P_first_stage_model.encoder.down.2.block.0_inner: 0.0 0/P_bg324: -6.103515625e-05 0/P_bg104: 0.0 0/P_bg181: 0.0 0/P_bg234: 0.0 0/P_bg213: 0.0 0/P_bg149: 0.0 0/P_bg17: 0.0 0/P_bg313: 0.0 0/P_bg154: 0.0 0/P_bg128: 0.0 0/P_bg99: 0.0 0/P_model.diffusion_model.output_blocks.4.0_inner2: 0.0 0/P_bg111: 0.0 0/P_bg305: 0.0 0/P_bg110: 0.0 0/P_bg72: 0.0 0/P_bg97: 0.0 0/P_bg93: 0.0 0/P_bg242: 0.0 0/P_bg381: 0.0 0/P_bg303: 0.0 0/P_bg244: 0.0 0/P_bg54: 0.0 0/P_bg2: 0.0 0/P_bg272: 0.0 0/P_bg77: 0.0 0/P_bg14: 0.0 0/P_bg245: 0.0 0/P_bg75: 0.0 0/P_bg318: 0.0 0/P_bg124: 0.0 0/P_model.diffusion_model.input_blocks.10.0_inner: 0.0 0/P_model.diffusion_model.output_blocks.6.0_inner3: 0.0 0/P_bg332: 0.0 0/P_bg108: 0.0 0/P_bg338: 0.0 0/P_bg216: 0.0 0/P_bg328: 0.0 0/P_bg210: 0.0 0/P_bg354: 0.0 0/P_model.diffusion_model.output_blocks.8.0_inner3: 0.0 0/P_first_stage_model.decoder.mid.block_2_inner: 0.0 0/P_bg80: 0.0 0/P_bg87: 0.0 0/P_bg84: 0.0 0/P_bg223: 0.0 0/P_bg353: 0.0 0/P_model.diffusion_model.input_blocks.10.0_inner3: 0.0 0/P_bg20: 0.0 0/P_bg33: 0.0 0/P_bg28: 0.0 0/P_bg396: 0.0 0/P_model.diffusion_model.output_blocks.5.0_inner4: 0.0 0/P_bg315: 0.0 0/P_model.diffusion_model.input_blocks.5.0_inner2: 0.0 0/P_bg129: 0.0 0/P_model.diffusion_model.input_blocks.5.0_inner4: 0.0 0/P_bg39: 0.0 0/P_bg316: 0.0 0/P_bg204: 0.0 0/P_bg113: 0.0 0/P_bg1: 0.0 0/P_model.diffusion_model.output_blocks.11.0_inner3: 0.0 0/P_model.diffusion_model.output_blocks.4.0_inner4: 0.0 0/P_bg178: 0.0 0/P_bg141: 0.0 0/P_bg158: 0.0 0/P_bg91: 0.0 0/P_bg349: 0.0 0/P_model.diffusion_model.middle_block.0_inner2: 0.0 0/P_model.diffusion_model.output_blocks.1.0_inner: 0.0 0/P_bg194: 0.0 0/P_bg405: 0.0 0/P_bg121: 0.0 0/P_bg399: 0.0 0/P_bg15: 0.0 0/P_bg319: 0.0 0/P_first_stage_model.encoder.down.1.block.1_inner: 0.0 0/P_bg135: 0.0 0/P_bg404: 0.0 0/P_bg169: 0.0 0/P_bg79: 0.0 0/P_bg41: 0.0 0/P_bg82: 0.0 0/P_model.diffusion_model.output_blocks.7.0_inner4: 0.0 0/P_bg270: 0.0 0/P_bg374: 0.0 0/P_model.diffusion_model.output_blocks.11.0_inner2: 0.0 0/P_bg352: 0.0 0/P_bg343: 0.0 0/P_bg357: 0.0 0/P_bg251: 0.0 0/P_model.diffusion_model.input_blocks.1.0_inner4: 0.0 0/P_bg386: 0.0 0/P_bg140: 0.0 0/P_bg289: 0.0 0/P_bg228: 0.0 0/P_first_stage_model.decoder.up.2.block.2_inner: 0.0 0/P_bg31: 0.0 0/P_bg293: 0.0 0/P_bg265: 0.0 0/P_bg339: 0.0 0/P_bg362: 0.0 0/P_bg56: 0.0 0/P_bg83: 0.0 0/P_model.diffusion_model.middle_block.0_inner4: 0.0 0/P_model.diffusion_model.output_blocks.5.0_inner2: 0.0 0/P_bg304: 0.0 0/P_bg391: 0.0 0/P_bg147: 0.0 0/P_bg137: 0.0 0/P_b294: 0.0 0/P_bg174: 0.0 0/P_bg168: 0.0 0/P_model.diffusion_model.output_blocks.8.0_inner2: 0.0 0/P_bg268: 0.0 0/P_bg199: 0.0 0/P_bg57: 0.0 0/P_bg355: 0.0 0/P_bg274: 0.0 0/P_bg226: 0.0 0/P_bg139: 0.0 0/P_model.diffusion_model.output_blocks.10.0_inner4: 0.0 0/P_bg248: 0.0 0/P_model.diffusion_model.middle_block.2_inner4: 0.0 0/P_bg103: 0.0 0/P_bg48: 0.0 0/P_first_stage_model.decoder.up.3.block.2_inner: 0.0 0/P_model.diffusion_model.input_blocks.2.0_inner3: 0.0 0/P_model.diffusion_model.output_blocks.1.0_inner2: 0.0 0/P_bg239: 0.0 0/P_bg203: 0.0 0/P_bg307: 0.0 0/P_model.diffusion_model.input_blocks.10.0_inner2: 0.0 0/P_model.diffusion_model.input_blocks.1.0_inner3: 0.0 0/P_bg276: 0.0 0/P_bg215: 0.0 0/P_bg284: 0.0 0/P_b381: 0.0 0/P_bg209: 0.0 0/P_bg236: 0.0 0/P_bg329: 0.0 0/P_model.diffusion_model.input_blocks.7.0_inner4: 0.0 0/P_bg23: 0.0 0/P_bg96: 0.0 0/P_bg298: 0.0 0/P_bg382: 0.0 0/P_model.diffusion_model.output_blocks.10.0_inner2: 0.0 0/P_bg218: 0.0 0/P_bg301: 0.0 0/P_bg81: 0.0 0/P_bg88: 0.0 0/P_bg291: 0.0 0/P_bg306: 0.0 0/P_bg159: 0.0 0/P_model.diffusion_model.input_blocks.7.0_inner2: 0.0 0/P_bg295: 0.0 0/P_model.diffusion_model.input_blocks.4.0_inner2: 0.0 0/P_bg8: 0.0 0/P_bg187: 0.0 0/P_bg202: 0.0 0/P_bg299: 0.0 0/P_bg361: 0.0 0/P_bg186: 0.0 0/P_bg114: 0.0 0/P_bg119: 0.0 0/P_bg191: 0.0 0/P_bg363: 0.0 0/P_bg144: 0.0 0/P_bg21: 0.0 0/P_bg264: 0.0 0/P_bg10: 0.0 0/P_model.diffusion_model.input_blocks.4.0_inner3: 0.0 0/P_bg118: 0.0 0/P_model.diffusion_model.output_blocks.4.0_inner3: 0.0 0/P_bg185: 0.0 0/P_bg109: 0.0 0/P_bg384: 0.0 0/P_bg52: 0.0 0/P_bg258: 0.0 0/P_bg138: 0.0 0/P_bg38: 0.0 0/P_bg379: 0.0 0/P_model.diffusion_model.output_blocks.2.0_inner: 0.0 0/P_bg66: 0.0 0/P_bg208: 0.0 0/P_bg348: 0.0 0/P_bg292: 0.0 0/P_bg179: 0.0 0/P_first_stage_model.decoder.up.3.block.1_inner: 0.0 0/P_bg76: 0.0 0/P_bg132: 0.0 0/P_bg206: 0.0 0/P_bg240: 0.0 0/P_model.diffusion_model.output_blocks.3.0_inner: 0.0 0/P_bg225: 0.0 0/P_bg78: 0.0 0/P_bg267: 0.0 0/P_model.diffusion_model.output_blocks.3.0_inner2: 0.0 0/P_model.diffusion_model.output_blocks.8.0_inner: 0.0 0/P_model.diffusion_model.output_blocks.0.0_inner: 0.0 0/P_model.diffusion_model.output_blocks.11.0_inner: 0.0 0/P_model.diffusion_model.output_blocks.2.0_inner3: 0.0 0/P_bg277: 0.0 0/P_bg211: 0.0 0/P_bg327: 0.0 0/P_bg322: 0.0 0/P_bg4: 0.0 0/P_model.diffusion_model.input_blocks.11.0_inner2: 0.0 0/P_bg171: 0.0 0/P_first_stage_model.decoder.up.1.block.2_inner: 0.0 0/P_bg367: 0.0 0/P_bg30: 0.0 0/P_bg101: 0.0 0/P_bg63: 0.0 0/P_model.diffusion_model.output_blocks.8.0_inner4: 0.0 0/P_model.diffusion_model.output_blocks.10.0_inner3: 0.0 0/P_bg330: 0.0 0/P_bg266: 0.0 0/P_bg347: 0.0 0/P_bg123: 0.0 0/P_bg326: 0.0 0/P_bg148: 0.0 0/P_bg190: 0.0 0/P_bg55: 0.0 0/P_bg29: 0.0 0/P_model.diffusion_model.output_blocks.6.0_inner2: 0.0 0/P_bg122: 0.0 0/P_model.diffusion_model.output_blocks.5.0_inner: 0.0 0/P_bg275: 0.0 0/P_bg282: 0.0 0/P_first_stage_model.decoder.up.0.block.2_inner: 0.0 0/P_bg183: 0.0 0/P_bg62: 0.0 0/P_bg143: 0.0 0/P_bg350: 0.0 0/P_bg230: 0.0 Saving... Done!

By the way, merging with 1.4 OR 1.5emaonly fails with this error:

Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 16, in model_a = torch.load(args.model_a, map_location=device) File "C:\Users\DogMa.conda\envs\merging\lib\site-packages\torch\serialization.py", line 712, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "C:\Users\DogMa.conda\envs\merging\lib\site-packages\torch\serialization.py", line 1046, in _load result = unpickler.load() File "C:\Users\DogMa.conda\envs\merging\lib\site-packages\torch\serialization.py", line 1039, in find_class return super().find_class(mod_name, name) ModuleNotFoundError: No module named 'pytorch_lightning'

Merging with Berrymix + Dreambooth worked, and are the images shown above.

ogkalu2 commented 1 year ago

Thank you. I don't think the values should be all or mostly 0.0 but if that's the case, i can't figure out why

Dawgmastah commented 1 year ago

Merging between 1.4 and 1.5 fails as well, so I think this is only DB compatible for now

Dawgmastah commented 1 year ago

Testing swapping the models, I can confirm only model B retains training (and influence it seems)

ogkalu2 commented 1 year ago

Testing swapping the models, I can confirm only model B retains training (and influence it seems)

Train what you first trained and in the same placement but,

Open the SD_rebasin_merge file, in the updated_params line, replace state_b with state_a and run it.

The idea is this, if model_a is now what has the bias then something is wrong with the apply permutation function. If state_b still has the bias then something is wrong with the weight_matching function.

ogkalu2 commented 1 year ago

@Dawgmastah Hopefully it's the former

Dawgmastah commented 1 year ago

On it

Dawgmastah commented 1 year ago

Back from testing, after changing that line, the model with training and dreambooth conserved indeed swapped. (now its model A)

Also, streaming youtube greatly slowed the process ha @ogkalu2

ogkalu2 commented 1 year ago

@Dawgmastah Try running with the new SD_rebasin_merge i uploaded

Dawgmastah commented 1 year ago

On it

Dawgmastah commented 1 year ago

That was not it @ogkalu2 but maybe its in the right direction.

Newly created CKPT is only 87KB(compressed), and inside the data folder (which now exists) there is only a single data file called 0.

image

ogkalu2 commented 1 year ago

@Dawgmastah try the new file again

Dawgmastah commented 1 year ago

Testing

Dawgmastah commented 1 year ago

@ogkalu2 Exit with error:

0/P_bg46: 0.0 Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 31, in w = torch.index_select(w, axis, final_permutation[p].int()) TypeError: index_select() received an invalid combination of arguments - got (str, int, Tensor), but expected one of:

Dawgmastah commented 1 year ago

Ill be gone for a bit, possibly until tomorrow morning, happy to continue debugging when im back tho

ogkalu2 commented 1 year ago

@Dawgmastah No worries. Test the update when you're able to

Dawgmastah commented 1 year ago

@ogkalu2 was able to take a look:

Now exits with:

0/P_bg250: 0.0 Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 25, in for k in get_permuted_param(permutation_spec, final_permutation, k, state_b): NameError: name 'k' is not defined

ogkalu2 commented 1 year ago

@Dawgmastah Okay. Guess we'll continue tomorrow then.

Dawgmastah commented 1 year ago

Just in case, tested with latest build, error is still:

0/P_bg152: 0.0 Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 25, in for k in get_permuted_param(permutation_spec, final_permutation, k, state_b): NameError: name 'k' is not defined

(@ogkalu2 are the _bg_xxx numbers random?)

ogkalu2 commented 1 year ago

@Dawgmastah Oh I hadn't changed anything yet. Hold on

ogkalu2 commented 1 year ago

@Dawgmastah Try running the update now

Dawgmastah commented 1 year ago

On it

Dawgmastah commented 1 year ago

@ogkalu2 After testing, only dreambooth traiing from model B is being preserved right now (but the file is created and mounts correctly)

The hash also matches B

lopho commented 1 year ago

if you are using the hash function from autos webui, it's broken and will return the same hash for many models.

lopho commented 1 year ago

feel free to use this snippet to hash a model:

import sys
import hashlib
with open(sys.argv[1], 'rb') as f:
    hashfun = hashlib.sha256()
    hashfun.update(f.read())
    print(hashfun.hexdigest())

just copypaste the code into a file, save as hash.py and run it like this:

python3 hash.py model_file.ckpt

or if you are on linux, this is easier than using python and will result in the same hash as the script above:

sha256sum model_file.ckpt
Dawgmastah commented 1 year ago

@lopho Oh, id not know that, yes, its the same hash in the preview.

I used the SHA256 from 7zip and they are different

ogkalu2 commented 1 year ago

@Dawgmastah In the SD rebasin file, on the result = line, change state_b to state_a and run it again.

Dawgmastah commented 1 year ago

Testing

Dawgmastah commented 1 year ago

@ogkalu2 Now only model A is preserved

ogkalu2 commented 1 year ago

@Dawgmastah run with the new weight_matching

Dawgmastah commented 1 year ago

Do I revert the previous change in SD rebasin?

ogkalu2 commented 1 year ago

@Dawgmastah No. Use the newest SD rebasin

Dawgmastah commented 1 year ago

@ogkalu2 Fails immediately with error

0/P_bg318: 0.0 Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 23, in final_permutation = weight_matching(permutation_spec, state_a, state_b) File "X:\AIMODELS\weight_matching.py", line 795, in weight_matching w_b = get_permuted_param(ps, perm, wk, params_b, except_axis=axis) File "X:\AIMODELS\weight_matching.py", line 774, in get_permuted_param return c UnboundLocalError: local variable 'c' referenced before assignment

Im unfamiliar with python (only with C, so I cant help with fixing it, sounds simple though) *I was wrong, couldnt fix it playing around with it, not simple at all lol

ogkalu2 commented 1 year ago

@Dawgmastah changed something. see if you still get the error

Dawgmastah commented 1 year ago

@ogkalu2 Error persists

Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 23, in final_permutation = weight_matching(permutation_spec, state_a, state_b) File "X:\AIMODELS\weight_matching.py", line 795, in weight_matching w_b = get_permuted_param(ps, perm, wk, params_b, except_axis=axis) File "X:\AIMODELS\weight_matching.py", line 774, in get_permuted_param return c UnboundLocalError: local variable 'c' referenced before assignment

ogkalu2 commented 1 year ago

@Dawgmastah Try again

Dawgmastah commented 1 year ago

Fails immediately but with a different error (I had gotten this already when putitng return c in both statements of the if)

Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 23, in final_permutation = weight_matching(permutation_spec, state_a, state_b) File "X:\AIMODELS\weight_matching.py", line 796, in weight_matching w_b = torch.moveaxis(w_b, axis, 0).reshape((n, -1)) TypeError: moveaxis() received an invalid combination of arguments - got (NoneType, int, int), but expected one of:

ogkalu2 commented 1 year ago

@Dawgmastah Try again

ogkalu2 commented 1 year ago

@Dawgmastah

Sorry made an indent mistake. try it now

Dawgmastah commented 1 year ago

@ogkalu2 Fails immediately with following error:

Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 23, in final_permutation = weight_matching(permutation_spec, state_a, state_b) File "X:\AIMODELS\weight_matching.py", line 796, in weight_matching w_b = get_permuted_param(ps, perm, wk, params_b, except_axis=axis) File "X:\AIMODELS\weight_matching.py", line 763, in get_permuted_param c = torch.index_select(w, axis, perm[p].int()) UnboundLocalError: local variable 'axis' referenced before assignment

Dawgmastah commented 1 year ago

If I add in the funct axis=0 and p=0 get following error

Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 23, in final_permutation = weight_matching(permutation_spec, state_a, state_b) File "X:\AIMODELS\weight_matching.py", line 798, in weight_matching w_b = get_permuted_param(ps, perm, wk, params_b, except_axis=axis) File "X:\AIMODELS\weight_matching.py", line 765, in get_permuted_param c = torch.index_select(w, axis, perm[p].int()) KeyError: 0

(Apologize if thats stupid, was my initial reaction as c programmer =P)

ogkalu2 commented 1 year ago

@Dawgmastah

Try again

Dawgmastah commented 1 year ago

@ogkalu2 Executes for a bit and returns:

Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 23, in final_permutation = weight_matching(permutation_spec, state_a, state_b) File "X:\AIMODELS\weight_matching.py", line 793, in weight_matching w_b = get_permuted_param(ps, perm, wk, params_b, except_axis=axis) File "X:\AIMODELS\weight_matching.py", line 770, in get_permuted_param w = torch.index_select(w, axis, perm[p]) RuntimeError: index_select(): Expected dtype int32 or int64 for index

ogkalu2 commented 1 year ago

@Dawgmastah Okay. Well at this rate, the issue is the get_permuted_params function or the weight_matching function. It seems like the get_permuted_function might be ignoring everything else in favor of returning w as w = params[k] but i can't tell for sure.

Dawgmastah commented 1 year ago

@ogkalu2 Should we maybe ask in the original repo or ask in reddit if someone can take a look? I really am incompetent in python, else id try to help

ogkalu2 commented 1 year ago

@Dawgmastah I've sent a message on the original repo. Anyway try running again with the new rebasin merge and weight merging files

Dawgmastah commented 1 year ago

@ogkalu2 Different error this time:

Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 23, in final_permutation = weight_matching(permutation_spec, state_a, state_b) File "X:\AIMODELS\weight_matching.py", line 807, in weight_matching w_b = torch.moveaxis(w_b, axis, 0).reshape((n, -1)) RuntimeError: shape '[1280, -1]' is invalid for input of size 768

ogkalu2 commented 1 year ago

@Dawgmastah Try again

Dawgmastah commented 1 year ago

Exiting very quickly with:

Traceback (most recent call last): File "X:\AIMODELS\SD_rebasin_merge.py", line 23, in final_permutation = weight_matching(permutation_spec, state_a, state_b) File "X:\AIMODELS\weight_matching.py", line 804, in weight_matching w_b = torch.moveaxis(w_b, axis, 0).reshape((n, -1)) RuntimeError: shape '[3072, -1]' is invalid for input of size 768

ogkalu2 commented 1 year ago

@Dawgmastah Try with the new weight_matching