{"id":26160031,"url":"https://github.com/swhl/flux-sliders","last_synced_at":"2025-04-14T11:21:32.816Z","repository":{"id":276107551,"uuid":"928225057","full_name":"SWHL/flux-sliders","owner":"SWHL","description":"Modified from https://github.com/rohitgandikota/sliders","archived":false,"fork":false,"pushed_at":"2025-02-18T00:07:18.000Z","size":1137,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T00:41:24.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/SWHL.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}},"created_at":"2025-02-06T09:24:25.000Z","updated_at":"2025-02-25T16:16:31.000Z","dependencies_parsed_at":"2025-02-13T12:31:53.942Z","dependency_job_id":null,"html_url":"https://github.com/SWHL/flux-sliders","commit_stats":null,"previous_names":["swhl/flux-sliders"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2Fflux-sliders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2Fflux-sliders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2Fflux-sliders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SWHL%2Fflux-sliders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SWHL","download_url":"https://codeload.github.com/SWHL/flux-sliders/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868779,"owners_count":21174758,"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","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":"2025-03-11T11:58:06.426Z","updated_at":"2025-04-14T11:21:32.778Z","avatar_url":"https://github.com/SWHL.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## FLUX Sliders\n\n修改自\u003chttps://github.com/rohitgandikota/sliders\u003e\n\n⚠️注意：代码仍在快速迭代中，欢迎加入。\n\n当前代码训练所得模型：\n\n- 可以直接放在**Comfy/models/loras**下被加载使用。但是`slider scale`暂时不知如何插入进去。\n- 可以直接使用diffusers库来推理\n\n### TODO\n\n- [x] 支持diffusers直接推理\n- [x] 支持ComfyUI推理\n- [x] 多个slider lora融合\n- [ ] slider scale与原本lora scale的关系探究？\n\n### 推荐显存\n\n~80G\n\n可以自行将FLUX模型替换为量化后的FLUX模型\n\n### 安装环境\n\n```bash\nconda env create -f environment.yml\n```\n\n### 下载flux-dev模型\n\n```bash\nhuggingface-cli login\nhuggingface-cli download --resume-download black-forest-labs/FLUX.1-dev --local-dir models/FLUX.1-dev\n```\n\n### 训练\n\n直接执行以下命令，会训练人物由皱眉到微笑的sliders。\n\n```bash\npython train_text_sliders.py\n```\n\n### 推理\n\n单个slider LoRA使用\n\n```python\nfrom datetime import datetime\nfrom pathlib import Path\n\nimport torch\nfrom diffusers import FluxPipeline\n\nlora_path = \"flux-age_sliders_latest.safetensors\"\npipe = FluxPipeline.from_pretrained(\"models/FLUX.1-dev\", torch_dtype=torch.bfloat16)\npipe.to(\"cuda\")\npipe.load_lora_weights(lora_path)\n\ntime_stamp = datetime.strftime(datetime.now(), \"%Y-%m-%d-%H-%M-%S\")\nsave_dir = Path(\"outputs\") / time_stamp\nsave_dir.mkdir(parents=True, exist_ok=True)\n\nscales = (-5, -2.5, 0, 2.5, 5)\nprompt = \"female person\"\n\nfor scale in scales:\n    out = pipe(\n        prompt=prompt,\n        guidance_scale=3.5,\n        height=512,\n        width=512,\n        num_inference_steps=25,\n        joint_attention_kwargs={\"scale\": scale * 1 / 16},\n        generator=torch.Generator().manual_seed(42),\n    ).images[0]\n\n    save_img_path = save_dir / f\"{time_stamp}_scale_{scale}.jpg\"\n    out.save(save_img_path)\n```\n\n多个sliders LoRA结合使用\n\n```python\nfrom datetime import datetime\nfrom pathlib import Path\n\nimport torch\nfrom diffusers import FluxPipeline\n\npipe = FluxPipeline.from_pretrained(\"models/FLUX.1-dev\", torch_dtype=torch.bfloat16)\npipe.to(\"cuda:1\")\n\nhair_lora_path = \"flux-hair_sliders_latest_multiplied_1.0.safetensors\"\nsmile_lora_path = \"flux-smile_sliders_latest_multiplied_1.0.safetensors\"\n\npipe.load_lora_weights(hair_lora_path, adapter_name=\"hair\")\npipe.load_lora_weights(smile_lora_path, adapter_name=\"smile\")\n\npipe.set_adapters([\"hair\", \"smile\"], adapter_weights=[1.0, 1.0])\n\ntime_stamp = datetime.strftime(datetime.now(), \"%Y-%m-%d-%H-%M-%S\")\nsave_dir = Path(\"outputs/tmp\") / time_stamp\nsave_dir.mkdir(parents=True, exist_ok=True)\n\nscales = (-5, -2.5, 0, 2.5, 5)\nprompt = \"female person\"\n\nfor scale in scales:\n    out = pipe(\n        prompt=prompt,\n        guidance_scale=3.5,\n        height=512,\n        width=512,\n        num_inference_steps=25,\n        joint_attention_kwargs={\"scale\": scale * 1 / 16},\n        generator=torch.Generator().manual_seed(42),\n    ).images[0]\n\n    save_img_path = save_dir / f\"{time_stamp}_scale_{scale}.jpg\"\n    out.save(save_img_path)\n```\n\n### 推理结果\n\n![smiling_demo1](assets/smile_sliders_demo1.jpg)\n![smiling_demo2](assets/smile_sliders_demo2.jpg)\n\n更多的Sliders结果：\n\n- [smile-sliders-flux-1d-lora](https://civitai.com/models/1230985/smile-sliders-flux-1d-lora)\n- [age-sliders-flux-1d-lora](https://civitai.com/models/1242004/age-sliders-flux-1d-lora)\n- [hair-sliders-flux-1d-lora](https://civitai.com/models/1245348/hair-sliders-flux-1d-lora)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswhl%2Fflux-sliders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswhl%2Fflux-sliders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswhl%2Fflux-sliders/lists"}