{"id":21135278,"url":"https://github.com/cloneofsimo/magicmix","last_synced_at":"2025-11-09T05:04:01.747Z","repository":{"id":62982597,"uuid":"561062385","full_name":"cloneofsimo/magicmix","owner":"cloneofsimo","description":"Unofficial Implementation of MagicMix","archived":false,"fork":false,"pushed_at":"2022-11-03T15:06:53.000Z","size":4083,"stargazers_count":85,"open_issues_count":2,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-02T23:16:27.005Z","etag":null,"topics":["diffusion","interpolation","stable-diffusion"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2210.16056","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloneofsimo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-02T21:30:56.000Z","updated_at":"2023-02-16T09:35:04.000Z","dependencies_parsed_at":"2022-11-10T09:15:25.785Z","dependency_job_id":null,"html_url":"https://github.com/cloneofsimo/magicmix","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fmagicmix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fmagicmix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fmagicmix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fmagicmix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloneofsimo","download_url":"https://codeload.github.com/cloneofsimo/magicmix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225482022,"owners_count":17481179,"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":["diffusion","interpolation","stable-diffusion"],"created_at":"2024-11-20T06:48:02.413Z","updated_at":"2025-11-09T05:03:56.711Z","avatar_url":"https://github.com/cloneofsimo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MagicMix with Stable Diffusion\n\n\u003c!-- #region --\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg  src=\"contents/test.jpg\"\u003e\n\u003c/p\u003e\n\u003c!-- #endregion --\u003e\n\n\u003c!-- #region --\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg  src=\"contents/test_cat.jpg\"\u003e\n\u003c/p\u003e\n\u003c!-- #endregion --\u003e\n\n\u003e Output from this repo's implementation of MagicMix.\n\u003e Original Image, $\\nu$ = 0.75, $\\nu$ = 0.9 respectively.\n\nImplementation of MagicMix with Stable Diffusion (https://arxiv.org/abs/2210.16056) in PyTorch. _This is unofficial Implementation_.\n\n# Installation\n\n```bash\npip install git+https://github.com/cloneofsimo/magicmix.git\n```\n\nTo get it to work with CUDA GPU, install necessary pytorch and cuda versions.\n\n# Explanations\n\nThere are three main parameters for MagicMix. $K_{min} = k_{min ratio} T$, $K_{max} = k_{max ratio} T$, and $\\nu$. $T$ is the number of sampling steps for the scheduler.\n\n![magicmix](contents/magicmix.png)\n\nBasically, $\\nu$ determines _how little layout image_ (in the photo above, the corgi) is going to effect the diffusion process. Greater the $\\nu$, greater the content is going to effect.\n\n$k_{min ratio}$ and $k_{max ratio}$ determines the range of the mixing process. If $K_{max}$ is large, this will have the same effect as loosing much info of the original layout image. If $K_{min}$ is large, this will have the effect of letting content semantic to have effect more freely.\n\n# Basic Usage\n\nIn the package `magic_mix`, you can find the implementation of MagicMix with Stable Diffusion.\nBefore running, fill in the variable `HF_TOKEN` in `.env` file with Huggingface token for Stable Diffusion, and load_dotenv().\n\n```python\nfrom magic_mix import magic_mix_single_image\n\nload_dotenv(verbose=True)\nimage = Image.open(input_image_path).convert(\"RGB\")\n\nmixed_sementics = magic_mix_single_image(\n    layout_image=image,\n    num_inference_steps=50,\n    content_semantics_prompts=[\"coffee machine\", \"tiger\"],\n    k_min=20,\n    k_max=30,\n    nu=0.5,\n    guidance_scale_at_mix=7.5,\n    seed=0,\n    device=\"cuda:0\"\n) # mixed sementics is PIL image files...\n\nimage[0].save(\"mixed_sementics.png\")\n\n```\n\nOr simply run the following command to generate mixed images.\n\n```bash\npython scripts/run_text_image_mix.py \\\n    --input_image ./examples/inputs/1.jpg \\\n    --output_dir ./examples/outputs \\\n    --num_inference_steps 50 \\\n    --content_semantics_prompts \"coffee machine\" \"tiger\" \\\n    --k_min_ratio 0.3 \\\n    --k_max_ratio 0.6 \\\n    --nu 0.5 \\\n    --guidance_scale_at_mix 7.5 \\\n    --seed 0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloneofsimo%2Fmagicmix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloneofsimo%2Fmagicmix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloneofsimo%2Fmagicmix/lists"}