Package: mmagic
MultimodalAdvanced,Generative, andIntelligentCreation (MMagic [em'mædʒɪk])OpenMMLab websiteHOTOpenMMLab platformTRY IT OUT📘Documentation|🛠️Installation|📊Model Zoo|🆕Update News|🚀Ongoing Projects|🤔Reporting IssuesEnglish |简体中文🚀 What's NewNew releaseMMagic v1.2.0[18/12/2023]:An advanced and powerful inpainting algorithm named PowerPaint is released in our repository.Click to ViewWe are excited to announce the release of MMagic v1.0.0 that inherits fromMMEditingandMMGeneration.After iterative updates with OpenMMLab 2.0 framework and merged with MMGeneration, MMEditing has become a powerful tool that supports low-level algorithms based on both GAN and CNN. Today, MMEditing embraces Generative AI and transforms into a more advanced and comprehensive AIGC toolkit:MMagic(MultimodalAdvanced,Generative, andIntelligentCreation). MMagic will provide more agile and flexible experimental support for researchers and AIGC enthusiasts, and help you on your AIGC exploration journey.We highlight the following new features.1. New ModelsWe support 11 new models in 4 new tasks.Text2Image / DiffusionControlNetDreamBoothStable DiffusionDisco DiffusionGLIDEGuided Diffusion3D-aware GenerationEG3DImage RestorationNAFNetRestormerSwinIRImage ColorizationInstColorization2. Magic Diffusion ModelFor the Diffusion Model, we provide the following "magic" :Support image generation based on Stable Diffusion and Disco Diffusion.Support Finetune methods such as Dreambooth and DreamBooth LoRA.Support controllability in text-to-image generation using ControlNet.Support acceleration and optimization strategies based on xFormers to improve training and inference efficiency.Support video generation based on MultiFrame Render.Support calling basic models and sampling strategies through DiffuserWrapper.3. Upgraded FrameworkBy using MMEngine and MMCV of OpenMMLab 2.0 framework, MMagic has upgraded in the following new features:Refactor DataSample to support the combination and splitting of batch dimensions.Refactor DataPreprocessor and unify the data format for various tasks during training and inference.Refactor MultiValLoop and MultiTestLoop, supporting the evaluation of both generation-type metrics (e.g. FID) and reconstruction-type metrics (e.g. SSIM), and supporting the evaluation of multiple datasets at once.Support visualization on local files or using tensorboard and wandb.Support for 33+ algorithms accelerated by Pytorch 2.0.MMagichas supported all the tasks, models, metrics, and losses inMMEditingandMMGenerationand unifies interfaces of all components based onMMEngine😍.Please refer tochangelog.mdfor details and release history.Please refer tomigration documentsto migrate fromold versionMMEditing 0.x to new version MMagic 1.x .📄 Table of Contents📖 Introduction🙌 Contributing🛠️ Installation📊 Model Zoo🤝 Acknowledgement🖊️ Citation🎫 License🏗️ ️OpenMMLab Family📖 IntroductionMMagic (MultimodalAdvanced,Generative, andIntelligentCreation) is an advanced and comprehensive AIGC toolkit that inherits fromMMEditingandMMGeneration. It is an open-source image and video editing&generating toolbox based on PyTorch. It is a part of theOpenMMLabproject.Currently, MMagic support multiple image and video generation/editing tasks.https://user-images.githubusercontent.com/49083766/233564593-7d3d48ed-e843-4432-b610-35e3d257765c.mp4✨ Major featuresState of the Art ModelsMMagic provides state-of-the-art generative models to process, edit and synthesize images and videos.Powerful and Popular ApplicationsMMagic supports popular and contemporary image restoration, text-to-image, 3D-aware generation, inpainting, matting, super-resolution and generation applications. Specifically, MMagic supports fine-tuning for stable diffusion and many exciting diffusion's application such as ControlNet Animation with SAM. MMagic also supports GAN interpolation, GAN projection, GAN manipulations and many other popular GAN’s applications. It’s time to begin your AIGC exploration journey!Efficient FrameworkBy using MMEngine and MMCV of OpenMMLab 2.0 framework, MMagic decompose the editing framework into different modules and one can easily construct a customized editor framework by combining different modules. We can define the training process just like playing with Legos and provide rich components and strategies. In MMagic, you can complete controls on the training process with different levels of APIs. With the support ofMMSeparateDistributedDataParallel, distributed training for dynamic architectures can be easily implemented.✨ Best PracticeThe best practice on our main branch works withPython 3.9+andPyTorch 2.0+.🔝Back to Table of Contents🙌 ContributingMore and more community contributors are joining us to make our repo better. Some recent projects are contributed by the community including:SDXLis contributed by  @okotaku.AnimateDiffis contributed by @ElliotQi.ViCois contributed by @FerryHuang.DragGanis contributed by @qsun1.FastComposeris contributed by @xiaomile.Projectsis opened to make it easier for everyone to add projects to MMagic.We appreciate all contributions to improve MMagic. Please refer toCONTRIBUTING.mdin MMCV andCONTRIBUTING.mdin MMEngine for more details about the contributing guideline.🔝Back to Table of Contents🛠️ InstallationMMagic depends onPyTorch,MMEngineandMMCV.
Below are quick steps for installation.Step 1.Install PyTorch followingofficial instructions.Step 2.Install MMCV, MMEngine and MMagic withMIM.pip3installopenmim
miminstallmmcv>=2.0.0
miminstallmmengine
miminstallmmagicStep 3.Verify MMagic has been successfully installed.cd~
python-c"import mmagic; print(mmagic.__version__)"# Example output: 1.0.0Getting StartedAfter installing MMagic successfully, now you are able to play with MMagic! To generate an image from text, you only need several lines of codes by MMagic!frommmagic.apisimportMMagicInferencersd_inferencer=MMagicInferencer(model_name='stable_diffusion')text_prompts='A panda is having dinner at KFC'result_out_dir='output/sd_res.png'sd_inferencer.infer(text=text_prompts,result_out_dir=result_out_dir)Please seequick runandinferencefor the basic usage of MMagic.Install MMagic from sourceYou can also experiment on the latest developed version rather than the stable release by installing MMagic from source with the following commands:gitclonehttps://github.com/open-mmlab/mmagic.gitcdmmagic
pip3install-e.Please refer toinstallationfor more detailed instruction.🔝Back to Table of Contents📊 Model ZooSupported algorithmsConditional GANsUnconditional GANsImage RestorationImage Super-ResolutionSNGAN/Projection GAN (ICLR'2018)SAGAN (ICML'2019)BIGGAN/BIGGAN-DEEP (ICLR'2018)DCGAN (ICLR'2016)WGAN-GP (NeurIPS'2017)LSGAN (ICCV'2017)GGAN (ArXiv'2017)PGGAN (ICLR'2018)SinGAN (ICCV'2019)StyleGANV1 (CVPR'2019)StyleGANV2 (CVPR'2019)StyleGANV3 (NeurIPS'2021)DragGan (2023)SwinIR (ICCVW'2021)NAFNet (ECCV'2022)Restormer (CVPR'2022)SRCNN (TPAMI'2015)SRResNet&SRGAN (CVPR'2016)EDSR (CVPR'2017)ESRGAN (ECCV'2018)RDN (CVPR'2018)DIC (CVPR'2020)TTSR (CVPR'2020)GLEAN (CVPR'2021)LIIF (CVPR'2021)Real-ESRGAN (ICCVW'2021)Video Super-ResolutionVideo InterpolationImage ColorizationImage TranslationEDVR (CVPR'2018)TOF (IJCV'2019)TDAN (CVPR'2020)BasicVSR (CVPR'2021)IconVSR (CVPR'2021)BasicVSR++ (CVPR'2022)RealBasicVSR (CVPR'2022)TOFlow (IJCV'2019)CAIN (AAAI'2020)FLAVR (CVPR'2021)InstColorization (CVPR'2020)Pix2Pix (CVPR'2017)CycleGAN (ICCV'2017)InpaintingMattingText-to-Image(Video)3D-aware GenerationGlobal&Local (ToG'2017)DeepFillv1 (CVPR'2018)PConv (ECCV'2018)DeepFillv2 (CVPR'2019)AOT-GAN (TVCG'2019)Stable Diffusion Inpainting (CVPR'2022)DIM (CVPR'2017)IndexNet (ICCV'2019)GCA (AAAI'2020)GLIDE (NeurIPS'2021)Guided Diffusion (NeurIPS'2021)Disco-Diffusion (2022)Stable-Diffusion (2022)DreamBooth (2022)Textual Inversion (2022)Prompt-to-Prompt (2022)Null-text Inversion (2022)ControlNet (2023)ControlNet Animation (2023)Stable Diffusion XL (2023)AnimateDiff (2023)ViCo (2023)FastComposer (2023)PowerPaint (2023)EG3D (CVPR'2022)Please refer tomodel_zoofor more details.🔝Back to Table of Contents🤝 AcknowledgementMMagic is an open source project that is contributed by researchers and engineers from various colleges and companies. We wish that the toolbox and benchmark could serve the growing research community by providing a flexible toolkit to reimplement existing methods and develop their own new methods.We appreciate all the contributors who implement their methods or add new features, as well as users who give valuable feedbacks. Thank you all!🔝Back to Table of Contents🖊️ CitationIf MMagic is helpful to your research, please cite it as below.@misc{mmagic2023,title={{MMagic}: {OpenMMLab} Multimodal Advanced, Generative, and Intelligent Creation Toolbox},author={{MMagic Contributors}},howpublished={\url{https://github.com/open-mmlab/mmagic}},year={2023}}@misc{mmediting2022,title={{MMEditing}: {OpenMMLab} Image and Video Editing Toolbox},author={{MMEditing Contributors}},howpublished={\url{https://github.com/open-mmlab/mmediting}},year={2022}}🔝Back to Table of Contents🎫 LicenseThis project is released under theApache 2.0 license.
Please refer toLICENSESfor the careful check, if you are using our code for commercial matters.🔝Back to Table of Contents🏗️ ️OpenMMLab FamilyMMEngine: OpenMMLab foundational library for training deep learning models.MMCV: OpenMMLab foundational library for computer vision.MIM: MIM installs OpenMMLab packages.MMPreTrain: OpenMMLab Pre-training Toolbox and Benchmark.MMDetection: OpenMMLab detection toolbox and benchmark.MMDetection3D: OpenMMLab's next-generation platform for general 3D object detection.MMRotate: OpenMMLab rotated object detection toolbox and benchmark.MMSegmentation: OpenMMLab semantic segmentation toolbox and benchmark.MMOCR: OpenMMLab text detection, recognition, and understanding toolbox.MMPose: OpenMMLab pose estimation toolbox and benchmark.MMHuman3D: OpenMMLab 3D human parametric model toolbox and benchmark.MMSelfSup: OpenMMLab self-supervised learning toolbox and benchmark.MMRazor: OpenMMLab model compression toolbox and benchmark.MMFewShot: OpenMMLab fewshot learning toolbox and benchmark.MMAction2: OpenMMLab's next-generation action understanding toolbox and benchmark.MMTracking: OpenMMLab video perception toolbox and benchmark.MMFlow: OpenMMLab optical flow toolbox and benchmark.MMagic: OpenMMLab Multimodal Advanced, Generative, and Intelligent Creation Toolbox.MMDeploy: OpenMMLab model deployment framework.🔝Back to Table of Contents