{"id":13672076,"url":"https://github.com/mazzzystar/disco-diffusion-wrapper","last_synced_at":"2025-04-04T13:08:36.277Z","repository":{"id":37099207,"uuid":"488156130","full_name":"mazzzystar/disco-diffusion-wrapper","owner":"mazzzystar","description":"Implementation of disco-diffusion wrapper that could run on your own GPU with batch text input.","archived":false,"fork":false,"pushed_at":"2024-03-02T14:52:23.000Z","size":6331,"stargazers_count":573,"open_issues_count":3,"forks_count":92,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T12:03:28.783Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://6pen.art","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mazzzystar.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":"2022-05-03T09:56:45.000Z","updated_at":"2025-03-13T03:54:49.000Z","dependencies_parsed_at":"2024-01-14T17:05:36.779Z","dependency_job_id":"f0db1fc1-2936-4fea-9367-be5669facf93","html_url":"https://github.com/mazzzystar/disco-diffusion-wrapper","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazzzystar%2Fdisco-diffusion-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazzzystar%2Fdisco-diffusion-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazzzystar%2Fdisco-diffusion-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mazzzystar%2Fdisco-diffusion-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mazzzystar","download_url":"https://codeload.github.com/mazzzystar/disco-diffusion-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247175312,"owners_count":20896264,"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":"2024-08-02T09:01:25.953Z","updated_at":"2025-04-04T13:08:36.260Z","avatar_url":"https://github.com/mazzzystar.png","language":"Jupyter Notebook","readme":"[English](#english) \n____\n\n# disco-diffusion-wrapper \n\n本项目为[disco diffusion](https://github.com/alembics/disco-diffusion)的封装实现，使其能够在您的GPU上批量处理输入文本运行。\n\n 基于此封装工作，我们构建了一个AI绘画网站（https://6pen.art/），欢迎您前去体验。\n\n## 此仓库实现的功能\n\n1. 将原始代码中的模型加载和模型推理部分分离。现在您可以像下面这样使用它：\n\n```python\n# 初始化并加载预训练模型。\ndisco = DiscoDiffusion()\n# 进行推理\ndisco.draw(text, ...)\n```\n\n2. 引入了[DeepL](https://www.deepl.com/translator)对文本进行预处理，因此您可以使用任何自己喜欢的语言进行绘图。默认的语言对是从`中文`至`英语`（`ZH`到`EN-US`），您可以在`run.py`或`run_batch.py`中更改这一设置。\n\n```python\ndef translate(text, source_lang=\"ZH\", target_lang=\"EN-US\"):\n    res = translator.translate_text(text, source_lang=\"ZH\", target_lang=\"EN-US\")\n    return res\n```\n\n同时，您也可以通过设置`USE_TRANSLATE=False`来关闭文本翻译功能，这样一来就不需要DeepL的authKey了。\n\n3. 批量生成与保存功能。\n   由于加载部分和推理部分已分离，在处理新句子时无需再次加载预训练模型，从而大大节省了时间。\n\n```python\ncd disco-diffusion-wrapper/wrapper\n# 创建并填充sentence.list文件\npython run_batch.py\n```\n\n输出的图像按照原始文本的名字命名，因此即使在经过DeepL翻译之后，您也能轻松找到对应的图像。\n\n\n## 使用方法\n\n```bash\n# 克隆项目仓库\ngit clone git@github.com:mazzzystar/disco-diffusion-wrapper.git\ncd disco-diffusion-wrapper/\n\n# 创建并激活名为disco的conda环境\nconda create --name disco\nconda activate disco\n\n# 安装依赖包\npip install -r requirements.txt\ncd wrapper/\n\n# 下载预训练模型检查点\n# 如果这一步骤下载速度较慢，您可以手动从mutils.py代码中的URL下载，并将这些检查点放在相应的文件夹内\npython mutils.py\n\n# 获取DeepL API密钥，然后将其添加到run.py或batch_run.py中替换以下内容：\nUSE_TRANSLATE=True\nauth_key = \"\"\n\n# 通过一句话生成图像\npython run.py \"一行白鹭上青天\"\n\n# 批量生成\ntouch sentence.list\n# 在该文件中逐行填入你的文本内容\npython run_batch.py\n```\n\n## 示例\n\n以下是使用本仓库生成的一些示例作品链接：\n\n- ![samples/A_half-acre_square_pond_is_open_the_sky_and_clouds_wandering_together_ink_painting.png](samples/A_half-acre_square_pond_is_open_the_sky_and_clouds_wandering_together_ink_painting.png)\n\n  \u003e 描述：半亩方塘一鉴开，天光云影共徘徊，水墨画风格\n\n- ![samples/Snowy_mountains_plains_army_of_ghosts_marching_at_night_with_fluorescent_green_torches_abstract_painting_Trending_on_artstation.png](samples/Snowy_mountains_plains_army_of_ghosts_marching_at_night_with_fluorescent_green_torches_abstract_painting_Trending_on_artstation.png)\n\n  \u003e 描述：雪山、平原，幽灵军队夜间手持荧光绿火把行进，抽象画风，在Artstation上热门\n\n- ![samples/Glass_whale_lying_in_ruins_abstract_painting_Trending_on_artstation.png](samples/Glass_whale_lying_in_ruins_abstract_painting_Trending_on_artstation.png)\n\n  \u003e 描述：废墟中躺着玻璃鲸鱼，抽象画\n\n- ![samples/明月松间照清泉石上流中国画.png](samples/明月松间照清泉石上流中国画.png)\n\n  \u003e 描述：明月松间照，清泉石上流，中国画风格\n\n- ![samples/Effie_castle.jpeg](samples/Effie_castle.jpeg)\n\n  \u003e 描述：精灵城堡\n\n- ![samples/山随平野尽江入大荒流Trending_on_artstation.png](samples/山随平野尽江入大荒流Trending_on_artstation.png)\n\n  \u003e 描述：山随平野尽，江入大荒流，Artstation热门作品\n\n您可以通过[这里](https://drive.google.com/file/d/1OIsupQqMaYYWu4B0eemUWgvPfTSGyaqf/view?usp=sharing)下载我们所有基于中国古诗生成的结果。\n\n如果您使用本项目创作出有趣的作品，我们欢迎投稿分享。\n\n## 问题与改进\n\n该项目初衷在于娱乐，因此并未深入研究诸多细节，为了加快理解和重构项目的进程，已删除了一些功能（如VR/3D/视频等）。若您对此感兴趣并愿意恢复原始功能，非常欢迎提交Pull Request（PR）进行改进和扩展。  \n\n\n\n----\n\n\n\n# English\n\n\n\n# disco-diffusion-wrapper\n\nImplementation of a [disco diffusion](https://github.com/alembics/disco-diffusion) wrapper that could run on your own GPU with a batch  of input text. \n\nBased on this work, an AI painting website (https://6pen.art/) was built, you may have a try.\n\n\n## What this repo did\n1.Separate the model loading and model inference parts of the initial code. Now you can use it like:\n```python\n# init and load pretrain model.\ndisco = DiscoDiffusion()\n# infer\ndisco.draw(text, ...)\n```\n\n2.Use [deepL](https://www.deepl.com/translator) to preprocess the text, so that you can use any language you like to draw.\nThe default language pair is from `Chinese`-\u003e`English`(`ZH`-\u003e`EN-US`)，you can change it in `run.py` or `run_batch.py`\n```python\ndef translate(text, source_lang=\"ZH\", target_lang=\"EN-US\"):\n    res = translator.translate_text(text, source_lang=\"ZH\", target_lang=\"EN-US\")\n    return res\n```\nYou can also turn-off text  translation by setting `USE_TRANSLATE=False` so that you don't need the DeepL authKey. \n\n3.Batch generating \u0026 saving.\nAs the loading part and the inferring part is seperated, you do not need to load pretrain model again for a new sentence. This reduces a bunch of time.\n```python\ncd disco-diffusion-wrapper/wrapper\n# create and fill the sentence.list\npython run_batch.py\n```\nThe output images is saved by the name of the  origin text, so you can easily find it even after a deepL.\n\n\n## Usage\n```bash\ngit clone git@github.com:mazzzystar/disco-diffusion-wrapper.git\ncd disco-diffusion-wrapper/\nconda create --name disco\nconda activate disco\npip install -r requirements.txt\ncd wrapper/\n\n# download pretrain model checkpoints\n\"\"\"If this step is slow, you can download these model mannually from urls in the \ncode of mutils.py, then put these checkpoints in the corresponding folder.\"\"\"\npython mutils.py\n\n# Get your deepL API key, then add it to your run.py or batch_run.py to replace:\nUSE_TRANSLATE=True\nauth_key = \"\"\n\n# generated image by one sentence\npython run.py \"一行白鹭上青天\"\n\n# batch generation\ntouch sentence.list\n# fill your text in, one by a line.\npython run_batch.py\n```\n\n## Samples\nBelow are some samples generated using this repo. \n![](samples/A_half-acre_square_pond_is_open_the_sky_and_clouds_wandering_together_ink_painting.png)\n\u003e 半亩方塘一鉴开，天光云影共徘徊，水墨画\n\n![](samples/Snowy_mountains_plains_army_of_ghosts_marching_at_night_with_fluorescent_green_torches_abstract_painting_Trending_on_artstation.png)\n\u003e 雪山，平原，幽鬼军队在夜里打着荧光绿色的火把前行，抽象画，Trending on artstation\n\n![](samples/Glass_whale_lying_in_ruins_abstract_painting_Trending_on_artstation.png)\n\u003e躺在废墟中的玻璃鲸鱼，抽象画\n\n\n![](samples/明月松间照清泉石上流中国画.png)\n\u003e 明月松间照，清泉石上流，中国画\n\n![](samples/Effie_castle.jpeg)\n\u003e Elf Castle\n\n![](samples/山随平野尽江入大荒流Trending_on_artstation.png)\n\u003e 山随平野尽，江入大荒流，Trending on artstation\n\nYou can download all our Chinese poem generating results from [here](https://drive.google.com/file/d/1OIsupQqMaYYWu4B0eemUWgvPfTSGyaqf/view?usp=sharing).\n\nIf you use this project and produced some interesting results, submissions are welcomed.\n\n\n\n## Problems\nAs it's for fun, I did not look much into the details, and deleted many features(such as VR/3D/Video ...) to make me faster and more clear on the project resonctruction. It's awesome if you're interested in restoring the original function, PR is wellcomed.\n\n\n\n","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmazzzystar%2Fdisco-diffusion-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmazzzystar%2Fdisco-diffusion-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmazzzystar%2Fdisco-diffusion-wrapper/lists"}