{"id":23739844,"url":"https://github.com/p1atdev/sd_ti_merge","last_synced_at":"2025-10-10T10:08:05.984Z","repository":{"id":165955126,"uuid":"641365335","full_name":"p1atdev/sd_ti_merge","owner":"p1atdev","description":null,"archived":false,"fork":false,"pushed_at":"2023-05-17T00:20:49.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-31T20:56:38.467Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p1atdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-16T10:16:35.000Z","updated_at":"2023-05-16T10:18:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"314a80da-a15a-46a3-b3c2-f7a7b202c8fc","html_url":"https://github.com/p1atdev/sd_ti_merge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/p1atdev/sd_ti_merge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p1atdev%2Fsd_ti_merge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p1atdev%2Fsd_ti_merge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p1atdev%2Fsd_ti_merge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p1atdev%2Fsd_ti_merge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p1atdev","download_url":"https://codeload.github.com/p1atdev/sd_ti_merge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p1atdev%2Fsd_ti_merge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273158332,"owners_count":25055859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-31T09:39:29.489Z","updated_at":"2025-10-10T10:08:00.946Z","avatar_url":"https://github.com/p1atdev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sd_ti_merge\n\nStable Diffusion の Textual Inversion 埋め込みをマージできます。\n\n## マージスクリプト\n\nマージする全ての埋め込みのトークンサイズと次元数が一致している必要があります。(後述する情報表示スクリプトでも確認できます)\n\n```bash\npython ./merge.py emb1.pt emb2.pt ... emb.pt -o output.pt --ratios 1 1 ... 1\n```\n\nのようにマージするモデル、出力先、混ぜる割合を指定できます。 \n\n- `--ratios` は指定しなかった場合、すべて等しい割合でマージされます。指定する場合は特に合計値を意識する必要はなく、単純に割合だけ考えて大丈夫です。\n\n`ti_A` と `ti_B` を 2:3 でマージする場合はこんな感じです。\n\n```bash\npython ./merge.py path/to/ti_A.pt path/to/ti_B.pt -o path/to/output.pt --ratios 0.4 0.6\n```\n\n## 情報表示スクリプト\n\nTI に入っている情報を見ることが出来ます。\n\n```bash\npython ./info.py path/to/ti.pt\n```\n\nのようにすると、\n\n```\nModel: {'emb_params': tensor([[-0.0165,  0.0029,  0.0104,  ...,  0.0131, -0.0015, -0.0038],\n        [-0.0164,  0.0102,  0.0066,  ...,  0.0060,  0.0098,  0.0109],\n        [-0.0164,  0.0101,  0.0076,  ...,  0.0061,  0.0055,  0.0089],\n        ...,\n        [-0.0138, -0.0084, -0.0020,  ...,  0.0048,  0.0108,  0.0097],\n        [-0.0136, -0.0096,  0.0006,  ...,  0.0080,  0.0124,  0.0089],\n        [-0.0094, -0.0046,  0.0009,  ...,  0.0137,  0.0160,  0.0206]])}\nToken size: 16 tokens\nDimension: 1024 (SDv2.x)\n```\n\nのように出てきます。`Token size` で示されているのがそのモデルのトークンサイズ、`Dimension` で示されているのが次元数であり、これが一致しないモデル同士はマージできません。`Dimension` は SDv1 系なら768、SDv2 系なら 1024 であり、v1 系と v2 系の TI をマージすることはできません。\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp1atdev%2Fsd_ti_merge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp1atdev%2Fsd_ti_merge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp1atdev%2Fsd_ti_merge/lists"}