├── requirements.txt ├── config.json ├── .github └── FUNDING.yml ├── __init__.py ├── js └── GeminiAPINode.js ├── Gemini_workflows ├── Gemini-pro Chatbot【Zho】.json ├── Gemini 1.5 Pro + Stable Diffusion + ComfyUI = DALL·3 【Zho】.json ├── Gemini-pro【Zho】.json ├── Gemini-pro-vision【Zho】.json └── All-in-One LoRa Training【Zho】.json ├── README.md ├── GeminiAPINode.py └── LICENSE /requirements.txt: -------------------------------------------------------------------------------- 1 | google-generativeai>0.4.1 2 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "GEMINI_API_KEY": "your key" 3 | } 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: https://afdian.net/a/ZHOZHO # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import filecmp 4 | import shutil 5 | import __main__ 6 | import json 7 | 8 | python = sys.executable 9 | 10 | 11 | extentions_folder = os.path.join(os.path.dirname(os.path.realpath(__main__.__file__)), 12 | "web" + os.sep + "extensions" + os.sep + "Gemini_Zho") 13 | javascript_folder = os.path.join(os.path.dirname(os.path.realpath(__file__)), "js") 14 | 15 | if not os.path.exists(extentions_folder): 16 | print('Making the "web\extensions\Gemini_Zho" folder') 17 | os.mkdir(extentions_folder) 18 | 19 | result = filecmp.dircmp(javascript_folder, extentions_folder) 20 | 21 | if result.left_only or result.diff_files: 22 | print('Update to javascripts files detected') 23 | file_list = list(result.left_only) 24 | file_list.extend(x for x in result.diff_files if x not in file_list) 25 | 26 | for file in file_list: 27 | print(f'Copying {file} to extensions folder') 28 | src_file = os.path.join(javascript_folder, file) 29 | dst_file = os.path.join(extentions_folder, file) 30 | if os.path.exists(dst_file): 31 | os.remove(dst_file) 32 | #print("disabled") 33 | shutil.copy(src_file, dst_file) 34 | 35 | 36 | # create config 37 | if not os.path.isfile(os.path.join(os.path.dirname(os.path.realpath(__file__)),"config.json")): 38 | config = { 39 | "GEMINI_API_KEY": "your key" 40 | } 41 | with open(os.path.join(os.path.dirname(os.path.realpath(__file__)),"config.json"), "w") as f: 42 | json.dump(config, f, indent=4) 43 | 44 | #load config 45 | with open(os.path.join(os.path.dirname(os.path.realpath(__file__)),"config.json"), "r") as f: 46 | config = json.load(f) 47 | 48 | 49 | from .GeminiAPINode import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS 50 | 51 | # Combine the dictionaries 52 | #NODE_CLASS_MAPPINGS = {**NODE_CLASS_MAPPINGS_G} 53 | 54 | __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] 55 | -------------------------------------------------------------------------------- /js/GeminiAPINode.js: -------------------------------------------------------------------------------- 1 | 2 | import { app } from "/scripts/app.js"; 3 | import { ComfyWidgets } from "/scripts/widgets.js"; 4 | 5 | app.registerExtension({ 6 | name: "Comfy.GeminiAPINode", 7 | async beforeRegisterNodeDef(nodeType, nodeData, app) { 8 | // --- DisplayText_Zho Node 9 | if (nodeData.name === "DisplayText_Zho") { 10 | // Node Created 11 | const onNodeCreated = nodeType.prototype.onNodeCreated; 12 | nodeType.prototype.onNodeCreated = function () { 13 | const ret = onNodeCreated 14 | ? onNodeCreated.apply(this, arguments) 15 | : undefined; 16 | 17 | let DisplayText_Zho = app.graph._nodes.filter( 18 | (wi) => wi.type == nodeData.name 19 | ), 20 | nodeName = `${nodeData.name}_${DisplayText_Zho.length}`; 21 | 22 | console.log(`Create ${nodeData.name}: ${nodeName}`); 23 | 24 | const wi = ComfyWidgets.STRING( 25 | this, 26 | nodeName, 27 | [ 28 | "STRING", 29 | { 30 | default: "", 31 | placeholder: "Text output...", 32 | multiline: true, 33 | }, 34 | ], 35 | app 36 | ); 37 | wi.widget.inputEl.readOnly = true; 38 | return ret; 39 | }; 40 | // Function set value 41 | const outSet = function (texts) { 42 | if (texts.length > 0) { 43 | let widget_id = this?.widgets.findIndex( 44 | (w) => w.type == "customtext" 45 | ); 46 | 47 | if (Array.isArray(texts)) 48 | texts = texts 49 | .filter((word) => word.trim() !== "") 50 | .map((word) => word.trim()) 51 | .join(" "); 52 | 53 | this.widgets[widget_id].value = texts; 54 | app.graph.setDirtyCanvas(true); 55 | } 56 | }; 57 | 58 | // onExecuted 59 | const onExecuted = nodeType.prototype.onExecuted; 60 | nodeType.prototype.onExecuted = function (texts) { 61 | onExecuted?.apply(this, arguments); 62 | outSet.call(this, texts?.string); 63 | }; 64 | // onConfigure 65 | const onConfigure = nodeType.prototype.onConfigure; 66 | nodeType.prototype.onConfigure = function (w) { 67 | onConfigure?.apply(this, arguments); 68 | if (w?.widgets_values?.length) { 69 | outSet.call(this, w.widgets_values); 70 | } 71 | }; 72 | } 73 | // --- DisplayText_Zho Node 74 | }, 75 | }); 76 | -------------------------------------------------------------------------------- /Gemini_workflows/Gemini-pro Chatbot【Zho】.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 2, 3 | "last_link_id": 1, 4 | "nodes": [ 5 | { 6 | "id": 1, 7 | "type": "Gemini_API_S_Chat_Zho", 8 | "pos": [ 9 | 420, 10 | 370 11 | ], 12 | "size": [ 13 | 260, 14 | 140 15 | ], 16 | "flags": {}, 17 | "order": 0, 18 | "mode": 0, 19 | "outputs": [ 20 | { 21 | "name": "response", 22 | "type": "STRING", 23 | "links": [ 24 | 1 25 | ], 26 | "shape": 3, 27 | "slot_index": 0 28 | } 29 | ], 30 | "properties": { 31 | "Node name for S&R": "Gemini_API_S_Chat_Zho" 32 | }, 33 | "widgets_values": [ 34 | "展开说一下AIGC在文本、图像领域的发展", 35 | "gemini-pro" 36 | ] 37 | }, 38 | { 39 | "id": 2, 40 | "type": "DisplayText_Zho", 41 | "pos": [ 42 | 690, 43 | 370 44 | ], 45 | "size": [ 46 | 720, 47 | 1070 48 | ], 49 | "flags": {}, 50 | "order": 1, 51 | "mode": 0, 52 | "inputs": [ 53 | { 54 | "name": "text", 55 | "type": "STRING", 56 | "link": 1, 57 | "widget": { 58 | "name": "text" 59 | } 60 | } 61 | ], 62 | "outputs": [ 63 | { 64 | "name": "text", 65 | "type": "STRING", 66 | "links": null, 67 | "shape": 3 68 | } 69 | ], 70 | "properties": { 71 | "Node name for S&R": "DisplayText_Zho" 72 | }, 73 | "widgets_values": [ 74 | "", 75 | "user: 解释一下AIGC\n----------------------------------------\nmodel: AIGC,全称“人工智能生成内容”(Artificial Intelligence Generated Content),是指计算机利用人工智能技术自动生成内容。这些内容可以是文本、图像、代码、音乐、视频等形式,也可以是代码的自动生成。AIGC包括自然语言生成(NLG)、机器翻译(MT)、图像生成、音乐生成、代码生成等多种技术。\n\nAIGC近年来发展迅速,并逐步实现商业化落地。AIGC技术可用于提升广告、内容和服务的个性化推荐,增强生产力和效率,促进科技创新,具有广阔的应用前景。\n\nAIGC技术目前存在的主要挑战包括:\n\n- **数据挑战:** AIGC模型需要大量高质量数据进行训练,但是获取和标记这些数据通常非常耗时且昂贵。\n- **模型挑战:** AIGC模型通常非常复杂,需要强大的计算资源和专业知识才能构建和部署。\n- **应用挑战:** AIGC技术需要与现有系统和流程集成,才能真正发挥作用。\n\n尽管面临这些挑战,AIGC技术仍然具有很大的发展潜力。随着数据、模型和应用技术的不断进步,AIGC技术将逐渐被广泛采用,并对各种行业产生重大影响。\n\nAIGC技术的主要优势包括:\n\n- **效率高:** AIGC技术可以自动生成内容,从而提高效率。\n- **成本低:** AIGC技术可以降低内容生产成本。\n- **创造性:** AIGC技术可以生成出人类无法创造的内容。\n- **定制化:** AIGC技术可以根据用户需求生成定制化内容。\n- **可扩展性:** AIGC技术可以扩展到大量数据和任务。\n----------------------------------------\nuser: 展开说一下AIGC在文本、图像领域的发展\n----------------------------------------\nmodel: **文本领域**\n\n在文本领域,AIGC技术主要包括自然语言生成(NLG)和机器翻译(MT)。\n\n- **自然语言生成(NLG):** NLG技术可以将结构化数据或代码转换成自然语言文本。例如,NLG技术可以将天气数据转换成天气预报文本,将财务数据转换成财务报告文本,将代码转换成注释清晰的代码文档。\n- **机器翻译(MT):** MT技术可以将一种语言的文本翻译成另一种语言的文本。MT技术在新闻、旅游、电子商务等领域都有广泛的应用。\n\n近年来,随着深度学习技术的进步,NLG和MT技术取得了显著的进展。NLG模型在文本生成任务上的表现已经接近甚至超过了人类。MT模型的翻译质量也大幅提高,在许多场景下已经可以替代人工翻译。\n\n**图像领域**\n\n在图像领域,AIGC技术主要包括图像生成和图像编辑。\n\n- **图像生成:** 图像生成技术可以根据文本描述、草图或其他信息自动生成图像。例如,用户可以输入“一只坐在草地上的猫”这样的文本描述,图像生成模型就可以生成一张符合描述的猫的图像。\n- **图像编辑:** 图像编辑技术可以对现有图像进行编辑、增强或风格转换。例如,用户可以将一张黑白照片转换成彩色照片,或者将一张照片转换成油画风格的照片。\n\n近年来,随着GAN(生成对抗网络)技术和扩散模型技术的进步,图像生成和图像编辑技术取得了突破性的进展。图像生成模型可以生成逼真度极高的图像,图像编辑模型也可以实现各种复杂的效果。\n\n## AIGC在文本和图像领域的应用\n\nAIGC技术在文本和图像领域有广泛的应用,包括:\n\n- **新闻写作:** AIGC技术可以自动生成新闻报道、体育报道、财经报道等。\n- **文学创作:** AIGC技术可以自动生成小说、诗歌、剧本等。\n- **广告文案创作:** AIGC技术可以自动生成广告文案、产品介绍文案等。\n- **客服服务:** AIGC技术可以自动生成客服回复、常见问题解答等。\n- **图像创作:** AIGC技术可以自动生成插图、海报、广告图片等。\n- **图像编辑:** AIGC技术可以自动编辑图片、修复图片、风格转换等。\n\n## AIGC在文本和图像领域的未来发展\n\nAIGC技术在文本和图像领域仍处于早期发展阶段,但其发展潜力巨大。随着数据、模型和应用技术的不断进步,AIGC技术将逐渐被广泛采用,并对各种行业产生重大影响。\n\n在未来,AIGC技术可能会在以下方面取得进一步的发展:\n\n- **更逼真、更具创造性的内容生成:** AIGC模型将能够生成更加逼真、更加具创造性的文本和图像内容。\n- **更广泛的应用场景:** AIGC技术将被应用到更多场景中,例如医疗、教育、娱乐等。\n- **更无缝的与人类合作:** AIGC技术将与人类合作,共同创造出更加优质的内容。\n\nAIGC技术有望成为未来内容生产和消费的新范式,并对人类社会产生深远的影响。\n----------------------------------------" 76 | ] 77 | } 78 | ], 79 | "links": [ 80 | [ 81 | 1, 82 | 1, 83 | 0, 84 | 2, 85 | 0, 86 | "STRING" 87 | ] 88 | ], 89 | "groups": [], 90 | "config": {}, 91 | "extra": {}, 92 | "version": 0.4 93 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Gemini项目图

2 | 3 | 6 | 7 |

Gemini in ComfyUI

8 | 11 | 12 | 🆕 最新 Gemini 1.5 Pro 模型已加入! 13 | 14 | ![G1 5发](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/8c3105c7-e165-4b6b-8a46-6ed09ecfb388) 15 | 16 | - 支持系统指令设置(System Instruction) 17 | - 支持多模态 + 多轮对话 18 | - 可以读取视频、音频等文件(上限 20G) 19 | - 支持输入的 token 上限达到了 104万8576 20 | - 目前速率限制比较严,每分钟只有 2 次,每天只有 1000 次 21 | 22 | 25 | 26 | ![Dingtalk_20240411194828](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/c1f71846-db5e-4bb1-a1b7-0b278ee95ea8) 27 | 28 | 29 | 已支持文件上传功能,不过还仅限于单个文件(图片、txt文件、pdf文件、音频mp3文件等),未来会支持多文件上传(用于读取视频) 30 | 31 | 34 | 35 | All-in-One LoRa Training 预处理、自动打标、训练、测试 LoRA 一条龙工作流 36 | 37 | https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/d461f656-6888-48a8-b4f8-b70b7e46504d 38 | 39 | 40 | V2.0 聊天机器人节点 41 | 42 | https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/cb64ee29-a983-47fd-b26b-55386314afdd 43 | 44 | 45 | 将 Gemini pro vision 用于批量打标 46 | 47 | 48 | https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/00addc94-1587-40d6-83f4-6b47dc1db665 49 | 50 | 51 | 52 | ## 项目介绍 | Info 53 | 54 | - 将 Google Gemini 引入到 ComfyUI 中,现在你可以用它为你生成提示词、描述图像,也可与它畅聊人生 55 | 56 | - 目前 Gemini API 免费开放(20240502 开始计费),你可以在这里申请一个自己的 API Key:[Gemini API 申请](https://makersuite.google.com/app/apikey) 57 | 58 | - 最新 Gemini 1.5 Pro 模型: 59 | 60 | - 支持系统指令设置(System Instruction) 61 | - 支持多模态 + 多轮对话, 62 | - 可以读取视频、音频等文件(上限 20G) 63 | - 支持输入的 token 上限达到了 104万8576 64 | - 目前速率限制比较严,每分钟只有 2 次,每天只有 1000 次 65 | 66 | - 版本:V3.0 新增 Gemini 1.5 Pro 模型、系统指令、文件上传 67 | 68 | 69 | 70 | ## 详细说明 | Features 71 | 72 | - Gemini 目前提供 3 种模型: 73 | 74 | - Gemini-pro: 文本模型 75 | 76 | - Genimi-pro-vision: 文本 + 图像模型 77 | 78 | - Gemini 1.5 Pro:文本 + 图像 + 文件(音频、视频等各类) 模型 79 | 80 | 81 | - Gemini 1.5 Pro 新节点: 82 | 83 | - 🆕Gemini_15P_Advance_Zho:支持系统指令设置(System Instruction) 84 | 85 | - 🆕Gemini_15P_Chat_Advance_Zho:支持系统指令设置(System Instruction)+ 多轮对话 86 | 87 | - 📄Gemini_FileUpload_Zho:支持单文件上传(图片、音频、文本txt、pdf等),暂未支持视频(多文件)上传 88 | 89 | - 📄Gemini_File_Zho:文件读取对话,最大 token 数为 1048576 90 | 91 | 92 | - 2 类节点: 93 | 94 | - 隐式 API KEY:将 Gemini_API_Key 设置为了环境变量,更安全,方便分享工作流(不会外泄 API KEY) 95 | 96 | ㊙️Gemini_Zho:同时支持 3 种模型,其中 Genimi-pro-vision 和 Gemini 1.5 Pro 可接受图像作为输入 97 | 98 | ㊙️Gemini_Vsion_ImgURL_Zho:Genimi-pro-vision 和 Gemini 1.5 Pro 模型,接受图像链接作为输入 99 | 100 | ㊙️Gemini_Chat_Zho:Genimi-pro 和 Gemini 1.5 Pro 模型,支持上下文对话,聊天机器人,Gemini 1.5 Pro 支持图像输入的上下文对话 101 | 102 | - 显式API KEY:直接在节点中输入 Gemini_API_Key,仅供个人私密使用,请勿将包含 API KEY 的工作流分享出去 103 | 104 | ✨Gemini_API_Zho:同时支持 3 种模型,其中 Genimi-pro-vision 和 Gemini 1.5 Pro 可接受图像作为输入 105 | 106 | ✨Gemini_API_Vsion_ImgURL_Zho:Genimi-pro-vision 和 Gemini 1.5 Pro 模型,接受图像链接作为输入 107 | 108 | ✨Gemini_API_Chat_Zho::Genimi-pro 和 Gemini 1.5 Pro 模型,支持上下文对话,聊天机器人,Gemini 1.5 Pro 支持图像输入的上下文对话 109 | 110 | - 辅助节点: 111 | 112 | - ✨DisplayText_Zho:显示文本 113 | 114 | - ✨ConcatText_Zho:使用 “,” 连接文本 115 | 116 | - 节点示例: 117 | 118 | 121 | 122 | ![Dingtalk_20231220180446](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/3cba8d69-09bb-470c-940c-7f796c869d63) 123 | 124 | 聊天机器人 125 | 126 | ![image](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/8a38f437-0148-4777-b872-e88995dd53d2) 127 | 128 | 129 | ## 参数说明 | Parameters 130 | 131 | - image(非必要):选择 Gemini-pro 时无需接入图像,选择 Genimi-pro-vision 时需要接入图像,选择 Gemini 1.5 Pro 既可接入也可不接 132 | - prompt:提示词 133 | - model_name:模型选择,Gemini-pro 或 Genimi-pro-vision 或 Gemini 1.5 Pro 134 | - stream:流式传输响应 135 | - api_key:输入 Gemini_API_Key (仅在显式节点上有) 136 | 137 | ## 使用方法 | How to use 138 | 139 | - 首先需要申请一个自己的 Gemini_API_Key:[Gemini API 申请](https://makersuite.google.com/app/apikey) 140 | 141 | - 选择隐式节点㊙️(推荐):将你的 Gemini_API_Key 添加到 `config.json` 文件中,运行时会自动加载 142 | 143 | - 选择显示节点✨:直接将 Gemini_API_Key 输入到节点的 api_key 中(注意:请勿将包含此节点的工作流分享出去,以免泄露你的 API Key) 144 | 145 | - 使用注意:本地使用请确保你可以有效连接到 Google Gemini 的服务,推荐使用 Colab 或 Kaggle(无连接问题) 146 | 147 | - 使用新版 Gemini 1.5 Pro 需要更新依赖 google-generativeai > 0.4.1 148 | 149 | ## 安装 | Install 150 | 151 | - 推荐使用管理器 ComfyUI Manager 安装 152 | 153 | - 手动安装: 154 | 1. `cd custom_nodes` 155 | 2. `git clone https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini.git` 156 | 3. `cd custom_nodes/ComfyUI-Gemini` 157 | 4. `pip install -r requirements.txt` 158 | 5. 重启 ComfyUI 159 | 160 | ## 工作流 | Workflow 161 | 162 | ### V3.0 平替 DALL·3 163 | 164 | [Gemini 1.5 Pro + Stable Diffusion + ComfyUI = DALL·3 ](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/blob/main/Gemini_workflows/Gemini%201.5%20Pro%20%2B%20Stable%20Diffusion%20%2B%20ComfyUI%20%3D%20DALL%C2%B73%20%E3%80%90Zho%E3%80%91.json) 165 | 166 | 167 | ![Dingtalk_20240411195451](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/4e32d13d-615e-4441-931e-233c07cc958c) 168 | 169 | 170 | ### V2.0 工作流(隐式)(V1.1工作流依旧可用) 171 | 172 | [Gemini-pro Chatbot【Zho】](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/blob/main/Gemini_workflows/Gemini-pro%20Chatbot%E3%80%90Zho%E3%80%91.json) 173 | 174 | ![image](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/8a38f437-0148-4777-b872-e88995dd53d2) 175 | 176 | ### V1.1 工作流(隐式) 177 | 178 | [Gemini-pro【Zho】](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/blob/main/Gemini_workflows/Gemini-pro%E3%80%90Zho%E3%80%91.json) 179 | 180 | ![Dingtalk_20231220183708](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/7f0e222a-2de4-4c5b-883a-2172667d1d5b) 181 | 182 | [Genimi-pro-vision【Zho】](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/blob/main/Gemini_workflows/Gemini-pro-vision%E3%80%90Zho%E3%80%91.json) 183 | 184 | ![Dingtalk_20231220192932](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/db4f4bf6-a0cf-42af-ac5a-7e2afd1bda93) 185 | 186 | ![Dingtalk_20231220190218](https://github.com/ZHO-ZHO-ZHO/ComfyUI-Gemini/assets/140084057/5bb57f7b-f00f-454a-9435-c1b8a02ae71a) 187 | 188 | 189 | ## 更新日志 | Changelog 190 | 191 | 20240411 192 | 193 | - V3.0版:新增 Gemini 1.5 Pro 模型、系统指令、文件上传 194 | 195 | - 新增 平替 DALL·3 工作流(Gemini 1.5 Pro + Stable Diffusion + ComfyUI = DALL·3) 196 | 197 | 20231229 198 | 199 | - V2.1版:修复 Deadline of 60.0s bug,方法来自官方:https://github.com/google/generative-ai-python/issues/117 200 | 201 | 20231222 202 | 203 | - V2.0版:新增上下文聊天节点,相当于聊天机器人 204 | - 💬Gemini_Chat_Zho(隐式) 205 | - 💬Gemini_API_Chat_Zho(显示) 206 | 207 | 20231221 208 | 209 | - V1.1版:修改 API KEY 的加载方式为自动添加 config.json ,将 API KEY 写入即可 210 | 211 | - 已登陆 manager 不用手动安装了 212 | 213 | 20231220 214 | 215 | - 实现 Genimi-pro-vision 模型调用,支持图像或图像链接输入 216 | - 增加隐式节点,更加安全 217 | - 增加辅助节点 218 | 219 | 20231219 220 | 221 | - 创建 ComfyUI Gemini 项目,实现 Gemini-pro 模型调用 222 | 223 | 224 | ## Stars 225 | 226 | [![Star History Chart](https://api.star-history.com/svg?repos=ZHO-ZHO-ZHO/ComfyUI-Gemini&type=Timeline)](https://star-history.com/#ZHO-ZHO-ZHO/ComfyUI-Gemini&Timeline) 227 | 228 | 229 | ## 关于我 | About me 230 | 231 | 📬 **联系我**: 232 | - 邮箱:zhozho3965@gmail.com 233 | - QQ 群:839821928 234 | 235 | 🔗 **社交媒体**: 236 | - 个人页:[-Zho-](https://jike.city/zho) 237 | - Bilibili:[我的B站主页](https://space.bilibili.com/484366804) 238 | - X(Twitter):[我的Twitter](https://twitter.com/ZHOZHO672070) 239 | - 小红书:[我的小红书主页](https://www.xiaohongshu.com/user/profile/63f11530000000001001e0c8?xhsshare=CopyLink&appuid=63f11530000000001001e0c8&apptime=1690528872) 240 | 241 | 💡 **支持我**: 242 | - B站:[B站充电](https://space.bilibili.com/484366804) 243 | - 爱发电:[为我充电](https://afdian.net/a/ZHOZHO) 244 | 245 | 246 | ## Credits 247 | 248 | - DisplayText节点参考了:[ComfyUI_Custom_Nodes_AlekPet](https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet),感谢 AlekPet ! 249 | -------------------------------------------------------------------------------- /Gemini_workflows/Gemini 1.5 Pro + Stable Diffusion + ComfyUI = DALL·3 【Zho】.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 19, 3 | "last_link_id": 19, 4 | "nodes": [ 5 | { 6 | "id": 11, 7 | "type": "ModelSamplingContinuousEDM", 8 | "pos": [ 9 | 100, 10 | 280 11 | ], 12 | "size": [ 13 | 310, 14 | 110 15 | ], 16 | "flags": {}, 17 | "order": 4, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "model", 22 | "type": "MODEL", 23 | "link": 12, 24 | "slot_index": 0 25 | } 26 | ], 27 | "outputs": [ 28 | { 29 | "name": "MODEL", 30 | "type": "MODEL", 31 | "links": [ 32 | 11 33 | ], 34 | "shape": 3, 35 | "slot_index": 0 36 | } 37 | ], 38 | "properties": { 39 | "Node name for S&R": "ModelSamplingContinuousEDM" 40 | }, 41 | "widgets_values": [ 42 | "v_prediction", 43 | 120, 44 | 0.002 45 | ] 46 | }, 47 | { 48 | "id": 5, 49 | "type": "EmptyLatentImage", 50 | "pos": [ 51 | 100, 52 | 440 53 | ], 54 | "size": [ 55 | 310, 56 | 110 57 | ], 58 | "flags": {}, 59 | "order": 0, 60 | "mode": 0, 61 | "outputs": [ 62 | { 63 | "name": "LATENT", 64 | "type": "LATENT", 65 | "links": [ 66 | 2 67 | ], 68 | "slot_index": 0 69 | } 70 | ], 71 | "properties": { 72 | "Node name for S&R": "EmptyLatentImage" 73 | }, 74 | "widgets_values": [ 75 | 1024, 76 | 1024, 77 | 1 78 | ] 79 | }, 80 | { 81 | "id": 3, 82 | "type": "KSampler", 83 | "pos": [ 84 | 430, 85 | 350 86 | ], 87 | "size": [ 88 | 270, 89 | 260 90 | ], 91 | "flags": {}, 92 | "order": 7, 93 | "mode": 0, 94 | "inputs": [ 95 | { 96 | "name": "model", 97 | "type": "MODEL", 98 | "link": 11 99 | }, 100 | { 101 | "name": "positive", 102 | "type": "CONDITIONING", 103 | "link": 4 104 | }, 105 | { 106 | "name": "negative", 107 | "type": "CONDITIONING", 108 | "link": 6 109 | }, 110 | { 111 | "name": "latent_image", 112 | "type": "LATENT", 113 | "link": 2 114 | } 115 | ], 116 | "outputs": [ 117 | { 118 | "name": "LATENT", 119 | "type": "LATENT", 120 | "links": [ 121 | 7 122 | ], 123 | "slot_index": 0 124 | } 125 | ], 126 | "properties": { 127 | "Node name for S&R": "KSampler" 128 | }, 129 | "widgets_values": [ 130 | 619236096053712, 131 | "randomize", 132 | 30, 133 | 3, 134 | "dpmpp_2m", 135 | "karras", 136 | 1 137 | ] 138 | }, 139 | { 140 | "id": 7, 141 | "type": "CLIPTextEncode", 142 | "pos": [ 143 | 430, 144 | 230 145 | ], 146 | "size": [ 147 | 270, 148 | 76 149 | ], 150 | "flags": {}, 151 | "order": 5, 152 | "mode": 0, 153 | "inputs": [ 154 | { 155 | "name": "clip", 156 | "type": "CLIP", 157 | "link": 5 158 | } 159 | ], 160 | "outputs": [ 161 | { 162 | "name": "CONDITIONING", 163 | "type": "CONDITIONING", 164 | "links": [ 165 | 6 166 | ], 167 | "slot_index": 0 168 | } 169 | ], 170 | "properties": { 171 | "Node name for S&R": "CLIPTextEncode" 172 | }, 173 | "widgets_values": [ 174 | "text, watermark" 175 | ] 176 | }, 177 | { 178 | "id": 8, 179 | "type": "VAEDecode", 180 | "pos": [ 181 | 430, 182 | 660 183 | ], 184 | "size": [ 185 | 270, 186 | 50 187 | ], 188 | "flags": {}, 189 | "order": 8, 190 | "mode": 0, 191 | "inputs": [ 192 | { 193 | "name": "samples", 194 | "type": "LATENT", 195 | "link": 7 196 | }, 197 | { 198 | "name": "vae", 199 | "type": "VAE", 200 | "link": 8 201 | } 202 | ], 203 | "outputs": [ 204 | { 205 | "name": "IMAGE", 206 | "type": "IMAGE", 207 | "links": [ 208 | 10 209 | ], 210 | "slot_index": 0 211 | } 212 | ], 213 | "properties": { 214 | "Node name for S&R": "VAEDecode" 215 | } 216 | }, 217 | { 218 | "id": 17, 219 | "type": "DisplayText_Zho", 220 | "pos": [ 221 | 430, 222 | 760 223 | ], 224 | "size": [ 225 | 270, 226 | 130 227 | ], 228 | "flags": {}, 229 | "order": 3, 230 | "mode": 0, 231 | "inputs": [ 232 | { 233 | "name": "text", 234 | "type": "STRING", 235 | "link": 16, 236 | "widget": { 237 | "name": "text" 238 | } 239 | } 240 | ], 241 | "outputs": [ 242 | { 243 | "name": "text", 244 | "type": "STRING", 245 | "links": [ 246 | 17 247 | ], 248 | "shape": 3, 249 | "slot_index": 0 250 | } 251 | ], 252 | "properties": { 253 | "Node name for S&R": "DisplayText_Zho" 254 | }, 255 | "widgets_values": [ 256 | "", 257 | "" 258 | ] 259 | }, 260 | { 261 | "id": 10, 262 | "type": "PreviewImage", 263 | "pos": [ 264 | 720, 265 | 130 266 | ], 267 | "size": [ 268 | 740, 269 | 760 270 | ], 271 | "flags": {}, 272 | "order": 9, 273 | "mode": 0, 274 | "inputs": [ 275 | { 276 | "name": "images", 277 | "type": "IMAGE", 278 | "link": 10 279 | } 280 | ], 281 | "properties": { 282 | "Node name for S&R": "PreviewImage" 283 | } 284 | }, 285 | { 286 | "id": 13, 287 | "type": "Gemini_15P_API_S_Advance_Zho", 288 | "pos": [ 289 | 100, 290 | 600 291 | ], 292 | "size": [ 293 | 310, 294 | 290 295 | ], 296 | "flags": {}, 297 | "order": 1, 298 | "mode": 0, 299 | "inputs": [ 300 | { 301 | "name": "image", 302 | "type": "IMAGE", 303 | "link": null 304 | } 305 | ], 306 | "outputs": [ 307 | { 308 | "name": "text", 309 | "type": "STRING", 310 | "links": [ 311 | 16 312 | ], 313 | "shape": 3, 314 | "slot_index": 0 315 | } 316 | ], 317 | "properties": { 318 | "Node name for S&R": "Gemini_15P_API_S_Advance_Zho" 319 | }, 320 | "widgets_values": [ 321 | "cute cat, flowersm", 322 | "You are creating a prompt for Stable Diffusion to generate an image. First step: describe this image, then put description into text. Second step: generate a text prompt for %s based on first step. Only respond with the prompt itself, but embellish it as needed but keep it under 80 tokens.", 323 | "gemini-1.5-pro-latest", 324 | false 325 | ] 326 | }, 327 | { 328 | "id": 6, 329 | "type": "CLIPTextEncode", 330 | "pos": [ 331 | 430, 332 | 130 333 | ], 334 | "size": [ 335 | 270, 336 | 50 337 | ], 338 | "flags": {}, 339 | "order": 6, 340 | "mode": 0, 341 | "inputs": [ 342 | { 343 | "name": "clip", 344 | "type": "CLIP", 345 | "link": 3 346 | }, 347 | { 348 | "name": "text", 349 | "type": "STRING", 350 | "link": 17, 351 | "widget": { 352 | "name": "text" 353 | } 354 | } 355 | ], 356 | "outputs": [ 357 | { 358 | "name": "CONDITIONING", 359 | "type": "CONDITIONING", 360 | "links": [ 361 | 4 362 | ], 363 | "slot_index": 0 364 | } 365 | ], 366 | "properties": { 367 | "Node name for S&R": "CLIPTextEncode" 368 | }, 369 | "widgets_values": [ 370 | "van gogh, black background" 371 | ] 372 | }, 373 | { 374 | "id": 4, 375 | "type": "CheckpointLoaderSimple", 376 | "pos": [ 377 | 100, 378 | 130 379 | ], 380 | "size": [ 381 | 310, 382 | 100 383 | ], 384 | "flags": {}, 385 | "order": 2, 386 | "mode": 0, 387 | "outputs": [ 388 | { 389 | "name": "MODEL", 390 | "type": "MODEL", 391 | "links": [ 392 | 12 393 | ], 394 | "slot_index": 0 395 | }, 396 | { 397 | "name": "CLIP", 398 | "type": "CLIP", 399 | "links": [ 400 | 3, 401 | 5 402 | ], 403 | "slot_index": 1 404 | }, 405 | { 406 | "name": "VAE", 407 | "type": "VAE", 408 | "links": [ 409 | 8 410 | ], 411 | "slot_index": 2 412 | } 413 | ], 414 | "properties": { 415 | "Node name for S&R": "CheckpointLoaderSimple" 416 | }, 417 | "widgets_values": [ 418 | "cosxl.safetensors" 419 | ] 420 | } 421 | ], 422 | "links": [ 423 | [ 424 | 2, 425 | 5, 426 | 0, 427 | 3, 428 | 3, 429 | "LATENT" 430 | ], 431 | [ 432 | 3, 433 | 4, 434 | 1, 435 | 6, 436 | 0, 437 | "CLIP" 438 | ], 439 | [ 440 | 4, 441 | 6, 442 | 0, 443 | 3, 444 | 1, 445 | "CONDITIONING" 446 | ], 447 | [ 448 | 5, 449 | 4, 450 | 1, 451 | 7, 452 | 0, 453 | "CLIP" 454 | ], 455 | [ 456 | 6, 457 | 7, 458 | 0, 459 | 3, 460 | 2, 461 | "CONDITIONING" 462 | ], 463 | [ 464 | 7, 465 | 3, 466 | 0, 467 | 8, 468 | 0, 469 | "LATENT" 470 | ], 471 | [ 472 | 8, 473 | 4, 474 | 2, 475 | 8, 476 | 1, 477 | "VAE" 478 | ], 479 | [ 480 | 10, 481 | 8, 482 | 0, 483 | 10, 484 | 0, 485 | "IMAGE" 486 | ], 487 | [ 488 | 11, 489 | 11, 490 | 0, 491 | 3, 492 | 0, 493 | "MODEL" 494 | ], 495 | [ 496 | 12, 497 | 4, 498 | 0, 499 | 11, 500 | 0, 501 | "MODEL" 502 | ], 503 | [ 504 | 16, 505 | 13, 506 | 0, 507 | 17, 508 | 0, 509 | "STRING" 510 | ], 511 | [ 512 | 17, 513 | 17, 514 | 0, 515 | 6, 516 | 1, 517 | "STRING" 518 | ] 519 | ], 520 | "groups": [], 521 | "config": {}, 522 | "extra": {}, 523 | "version": 0.4 524 | } -------------------------------------------------------------------------------- /Gemini_workflows/Gemini-pro【Zho】.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 16, 3 | "last_link_id": 19, 4 | "nodes": [ 5 | { 6 | "id": 4, 7 | "type": "CheckpointLoaderSimple", 8 | "pos": [ 9 | 90, 10 | 190 11 | ], 12 | "size": [ 13 | 310, 14 | 100 15 | ], 16 | "flags": {}, 17 | "order": 0, 18 | "mode": 0, 19 | "outputs": [ 20 | { 21 | "name": "MODEL", 22 | "type": "MODEL", 23 | "links": [ 24 | 17 25 | ], 26 | "slot_index": 0 27 | }, 28 | { 29 | "name": "CLIP", 30 | "type": "CLIP", 31 | "links": [ 32 | 3, 33 | 5 34 | ], 35 | "slot_index": 1 36 | }, 37 | { 38 | "name": "VAE", 39 | "type": "VAE", 40 | "links": [ 41 | 8 42 | ], 43 | "slot_index": 2 44 | } 45 | ], 46 | "properties": { 47 | "Node name for S&R": "CheckpointLoaderSimple" 48 | }, 49 | "widgets_values": [ 50 | "XXMix_9realisticSDXL.safetensors" 51 | ] 52 | }, 53 | { 54 | "id": 6, 55 | "type": "CLIPTextEncode", 56 | "pos": [ 57 | 410, 58 | 310 59 | ], 60 | "size": [ 61 | 210, 62 | 50 63 | ], 64 | "flags": {}, 65 | "order": 7, 66 | "mode": 0, 67 | "inputs": [ 68 | { 69 | "name": "clip", 70 | "type": "CLIP", 71 | "link": 3 72 | }, 73 | { 74 | "name": "text", 75 | "type": "STRING", 76 | "link": 19, 77 | "widget": { 78 | "name": "text" 79 | }, 80 | "slot_index": 1 81 | } 82 | ], 83 | "outputs": [ 84 | { 85 | "name": "CONDITIONING", 86 | "type": "CONDITIONING", 87 | "links": [ 88 | 4 89 | ], 90 | "slot_index": 0 91 | } 92 | ], 93 | "properties": { 94 | "Node name for S&R": "CLIPTextEncode" 95 | }, 96 | "widgets_values": [ 97 | "beautiful scenery nature glass bottle landscape, , purple galaxy bottle," 98 | ] 99 | }, 100 | { 101 | "id": 7, 102 | "type": "CLIPTextEncode", 103 | "pos": [ 104 | 410, 105 | 400 106 | ], 107 | "size": [ 108 | 210, 109 | 90 110 | ], 111 | "flags": {}, 112 | "order": 4, 113 | "mode": 0, 114 | "inputs": [ 115 | { 116 | "name": "clip", 117 | "type": "CLIP", 118 | "link": 5 119 | } 120 | ], 121 | "outputs": [ 122 | { 123 | "name": "CONDITIONING", 124 | "type": "CONDITIONING", 125 | "links": [ 126 | 6 127 | ], 128 | "slot_index": 0 129 | } 130 | ], 131 | "properties": { 132 | "Node name for S&R": "CLIPTextEncode" 133 | }, 134 | "widgets_values": [ 135 | "(worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), tooth, open mouth" 136 | ] 137 | }, 138 | { 139 | "id": 5, 140 | "type": "EmptyLatentImage", 141 | "pos": [ 142 | 90, 143 | 330 144 | ], 145 | "size": [ 146 | 310, 147 | 110 148 | ], 149 | "flags": {}, 150 | "order": 1, 151 | "mode": 0, 152 | "outputs": [ 153 | { 154 | "name": "LATENT", 155 | "type": "LATENT", 156 | "links": [ 157 | 2 158 | ], 159 | "slot_index": 0 160 | } 161 | ], 162 | "properties": { 163 | "Node name for S&R": "EmptyLatentImage" 164 | }, 165 | "widgets_values": [ 166 | 768, 167 | 1280, 168 | 1 169 | ] 170 | }, 171 | { 172 | "id": 11, 173 | "type": "DisplayText_Zho", 174 | "pos": [ 175 | 410, 176 | 540 177 | ], 178 | "size": [ 179 | 210, 180 | 190 181 | ], 182 | "flags": {}, 183 | "order": 5, 184 | "mode": 0, 185 | "inputs": [ 186 | { 187 | "name": "text", 188 | "type": "STRING", 189 | "link": 10, 190 | "widget": { 191 | "name": "text" 192 | } 193 | } 194 | ], 195 | "outputs": [ 196 | { 197 | "name": "text", 198 | "type": "STRING", 199 | "links": [ 200 | 15 201 | ], 202 | "shape": 3, 203 | "slot_index": 0 204 | } 205 | ], 206 | "properties": { 207 | "Node name for S&R": "DisplayText_Zho" 208 | }, 209 | "widgets_values": [ 210 | "", 211 | "Cinematic portrait of a beautiful ethereal 20-year-old girl, soft smile and gentle eyes, elegant loose white dress, intricate gold jewelry, cherry blossom tree background, unreal engine cinematic lighting, photorealistic, octane render, trending on artstation, 4k, 8k" 212 | ], 213 | "color": "#223", 214 | "bgcolor": "#335" 215 | }, 216 | { 217 | "id": 10, 218 | "type": "Gemini_API_S_Zho", 219 | "pos": [ 220 | 90, 221 | 480 222 | ], 223 | "size": [ 224 | 310, 225 | 250 226 | ], 227 | "flags": {}, 228 | "order": 2, 229 | "mode": 0, 230 | "inputs": [ 231 | { 232 | "name": "image", 233 | "type": "IMAGE", 234 | "link": null 235 | } 236 | ], 237 | "outputs": [ 238 | { 239 | "name": "text", 240 | "type": "STRING", 241 | "links": [ 242 | 10 243 | ], 244 | "shape": 3, 245 | "slot_index": 0 246 | } 247 | ], 248 | "properties": { 249 | "Node name for S&R": "Gemini_API_S_Zho" 250 | }, 251 | "widgets_values": [ 252 | "text = 'Draw a beautiful 20-year-old girl, smiling' # @param {type:\"string\"}\n\nprompt = \"You are creating a prompt for Stable Diffusion to generate an image. Please generate a text prompt for %s. Only respond with the prompt itself, but embellish it as needed but keep it under 80 tokens.\" % text", 253 | "gemini-pro", 254 | false 255 | ], 256 | "color": "#223", 257 | "bgcolor": "#335" 258 | }, 259 | { 260 | "id": 8, 261 | "type": "VAEDecode", 262 | "pos": [ 263 | 630, 264 | 540 265 | ], 266 | "size": [ 267 | 220, 268 | 50 269 | ], 270 | "flags": {}, 271 | "order": 9, 272 | "mode": 0, 273 | "inputs": [ 274 | { 275 | "name": "samples", 276 | "type": "LATENT", 277 | "link": 7 278 | }, 279 | { 280 | "name": "vae", 281 | "type": "VAE", 282 | "link": 8 283 | } 284 | ], 285 | "outputs": [ 286 | { 287 | "name": "IMAGE", 288 | "type": "IMAGE", 289 | "links": [ 290 | 16 291 | ], 292 | "slot_index": 0 293 | } 294 | ], 295 | "properties": { 296 | "Node name for S&R": "VAEDecode" 297 | } 298 | }, 299 | { 300 | "id": 13, 301 | "type": "ConcatText_Zho", 302 | "pos": [ 303 | 630, 304 | 630 305 | ], 306 | "size": [ 307 | 220, 308 | 100 309 | ], 310 | "flags": {}, 311 | "order": 6, 312 | "mode": 0, 313 | "inputs": [ 314 | { 315 | "name": "text_2", 316 | "type": "STRING", 317 | "link": 15, 318 | "widget": { 319 | "name": "text_2" 320 | } 321 | } 322 | ], 323 | "outputs": [ 324 | { 325 | "name": "text", 326 | "type": "STRING", 327 | "links": [ 328 | 19 329 | ], 330 | "shape": 3, 331 | "slot_index": 0 332 | } 333 | ], 334 | "properties": { 335 | "Node name for S&R": "ConcatText_Zho" 336 | }, 337 | "widgets_values": [ 338 | "xxmixgirl", 339 | "" 340 | ], 341 | "color": "#223", 342 | "bgcolor": "#335" 343 | }, 344 | { 345 | "id": 16, 346 | "type": "SelfAttentionGuidance", 347 | "pos": [ 348 | 410, 349 | 190 350 | ], 351 | "size": [ 352 | 210, 353 | 80 354 | ], 355 | "flags": {}, 356 | "order": 3, 357 | "mode": 0, 358 | "inputs": [ 359 | { 360 | "name": "model", 361 | "type": "MODEL", 362 | "link": 17, 363 | "slot_index": 0 364 | } 365 | ], 366 | "outputs": [ 367 | { 368 | "name": "MODEL", 369 | "type": "MODEL", 370 | "links": [ 371 | 18 372 | ], 373 | "shape": 3, 374 | "slot_index": 0 375 | } 376 | ], 377 | "properties": { 378 | "Node name for S&R": "SelfAttentionGuidance" 379 | }, 380 | "widgets_values": [ 381 | 0.5, 382 | 2 383 | ] 384 | }, 385 | { 386 | "id": 3, 387 | "type": "KSampler", 388 | "pos": [ 389 | 630, 390 | 190 391 | ], 392 | "size": [ 393 | 220, 394 | 300 395 | ], 396 | "flags": {}, 397 | "order": 8, 398 | "mode": 0, 399 | "inputs": [ 400 | { 401 | "name": "model", 402 | "type": "MODEL", 403 | "link": 18 404 | }, 405 | { 406 | "name": "positive", 407 | "type": "CONDITIONING", 408 | "link": 4 409 | }, 410 | { 411 | "name": "negative", 412 | "type": "CONDITIONING", 413 | "link": 6 414 | }, 415 | { 416 | "name": "latent_image", 417 | "type": "LATENT", 418 | "link": 2 419 | } 420 | ], 421 | "outputs": [ 422 | { 423 | "name": "LATENT", 424 | "type": "LATENT", 425 | "links": [ 426 | 7 427 | ], 428 | "slot_index": 0 429 | } 430 | ], 431 | "properties": { 432 | "Node name for S&R": "KSampler" 433 | }, 434 | "widgets_values": [ 435 | 1121195339139873, 436 | "fixed", 437 | 20, 438 | 8, 439 | "euler", 440 | "normal", 441 | 1 442 | ] 443 | }, 444 | { 445 | "id": 15, 446 | "type": "PreviewImage", 447 | "pos": [ 448 | 860, 449 | 190 450 | ], 451 | "size": [ 452 | 310, 453 | 540 454 | ], 455 | "flags": {}, 456 | "order": 10, 457 | "mode": 0, 458 | "inputs": [ 459 | { 460 | "name": "images", 461 | "type": "IMAGE", 462 | "link": 16 463 | } 464 | ], 465 | "properties": { 466 | "Node name for S&R": "PreviewImage" 467 | } 468 | } 469 | ], 470 | "links": [ 471 | [ 472 | 2, 473 | 5, 474 | 0, 475 | 3, 476 | 3, 477 | "LATENT" 478 | ], 479 | [ 480 | 3, 481 | 4, 482 | 1, 483 | 6, 484 | 0, 485 | "CLIP" 486 | ], 487 | [ 488 | 4, 489 | 6, 490 | 0, 491 | 3, 492 | 1, 493 | "CONDITIONING" 494 | ], 495 | [ 496 | 5, 497 | 4, 498 | 1, 499 | 7, 500 | 0, 501 | "CLIP" 502 | ], 503 | [ 504 | 6, 505 | 7, 506 | 0, 507 | 3, 508 | 2, 509 | "CONDITIONING" 510 | ], 511 | [ 512 | 7, 513 | 3, 514 | 0, 515 | 8, 516 | 0, 517 | "LATENT" 518 | ], 519 | [ 520 | 8, 521 | 4, 522 | 2, 523 | 8, 524 | 1, 525 | "VAE" 526 | ], 527 | [ 528 | 10, 529 | 10, 530 | 0, 531 | 11, 532 | 0, 533 | "STRING" 534 | ], 535 | [ 536 | 15, 537 | 11, 538 | 0, 539 | 13, 540 | 0, 541 | "STRING" 542 | ], 543 | [ 544 | 16, 545 | 8, 546 | 0, 547 | 15, 548 | 0, 549 | "IMAGE" 550 | ], 551 | [ 552 | 17, 553 | 4, 554 | 0, 555 | 16, 556 | 0, 557 | "MODEL" 558 | ], 559 | [ 560 | 18, 561 | 16, 562 | 0, 563 | 3, 564 | 0, 565 | "MODEL" 566 | ], 567 | [ 568 | 19, 569 | 13, 570 | 0, 571 | 6, 572 | 1, 573 | "STRING" 574 | ] 575 | ], 576 | "groups": [], 577 | "config": {}, 578 | "extra": {}, 579 | "version": 0.4 580 | } -------------------------------------------------------------------------------- /Gemini_workflows/Gemini-pro-vision【Zho】.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 32, 3 | "last_link_id": 38, 4 | "nodes": [ 5 | { 6 | "id": 19, 7 | "type": "KSampler", 8 | "pos": [ 9 | 1050, 10 | 970 11 | ], 12 | "size": { 13 | "0": 220, 14 | "1": 300 15 | }, 16 | "flags": {}, 17 | "order": 9, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "model", 22 | "type": "MODEL", 23 | "link": 22 24 | }, 25 | { 26 | "name": "positive", 27 | "type": "CONDITIONING", 28 | "link": 23 29 | }, 30 | { 31 | "name": "negative", 32 | "type": "CONDITIONING", 33 | "link": 24 34 | }, 35 | { 36 | "name": "latent_image", 37 | "type": "LATENT", 38 | "link": 25 39 | } 40 | ], 41 | "outputs": [ 42 | { 43 | "name": "LATENT", 44 | "type": "LATENT", 45 | "links": [ 46 | 29 47 | ], 48 | "slot_index": 0 49 | } 50 | ], 51 | "properties": { 52 | "Node name for S&R": "KSampler" 53 | }, 54 | "widgets_values": [ 55 | 1121195339139873, 56 | "fixed", 57 | 20, 58 | 8, 59 | "euler", 60 | "normal", 61 | 1 62 | ] 63 | }, 64 | { 65 | "id": 21, 66 | "type": "CLIPTextEncode", 67 | "pos": [ 68 | 830, 69 | 1090 70 | ], 71 | "size": { 72 | "0": 210, 73 | "1": 50 74 | }, 75 | "flags": {}, 76 | "order": 8, 77 | "mode": 0, 78 | "inputs": [ 79 | { 80 | "name": "clip", 81 | "type": "CLIP", 82 | "link": 26 83 | }, 84 | { 85 | "name": "text", 86 | "type": "STRING", 87 | "link": 27, 88 | "widget": { 89 | "name": "text" 90 | }, 91 | "slot_index": 1 92 | } 93 | ], 94 | "outputs": [ 95 | { 96 | "name": "CONDITIONING", 97 | "type": "CONDITIONING", 98 | "links": [ 99 | 23 100 | ], 101 | "slot_index": 0 102 | } 103 | ], 104 | "properties": { 105 | "Node name for S&R": "CLIPTextEncode" 106 | }, 107 | "widgets_values": [ 108 | "beautiful scenery nature glass bottle landscape, , purple galaxy bottle," 109 | ] 110 | }, 111 | { 112 | "id": 22, 113 | "type": "CLIPTextEncode", 114 | "pos": [ 115 | 830, 116 | 1180 117 | ], 118 | "size": { 119 | "0": 210, 120 | "1": 90 121 | }, 122 | "flags": {}, 123 | "order": 4, 124 | "mode": 0, 125 | "inputs": [ 126 | { 127 | "name": "clip", 128 | "type": "CLIP", 129 | "link": 28 130 | } 131 | ], 132 | "outputs": [ 133 | { 134 | "name": "CONDITIONING", 135 | "type": "CONDITIONING", 136 | "links": [ 137 | 24 138 | ], 139 | "slot_index": 0 140 | } 141 | ], 142 | "properties": { 143 | "Node name for S&R": "CLIPTextEncode" 144 | }, 145 | "widgets_values": [ 146 | "(worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch), tooth, open mouth" 147 | ] 148 | }, 149 | { 150 | "id": 23, 151 | "type": "VAEDecode", 152 | "pos": [ 153 | 1050, 154 | 1320 155 | ], 156 | "size": { 157 | "0": 220, 158 | "1": 50 159 | }, 160 | "flags": {}, 161 | "order": 10, 162 | "mode": 0, 163 | "inputs": [ 164 | { 165 | "name": "samples", 166 | "type": "LATENT", 167 | "link": 29 168 | }, 169 | { 170 | "name": "vae", 171 | "type": "VAE", 172 | "link": 30 173 | } 174 | ], 175 | "outputs": [ 176 | { 177 | "name": "IMAGE", 178 | "type": "IMAGE", 179 | "links": [ 180 | 33 181 | ], 182 | "slot_index": 0 183 | } 184 | ], 185 | "properties": { 186 | "Node name for S&R": "VAEDecode" 187 | } 188 | }, 189 | { 190 | "id": 26, 191 | "type": "ConcatText_Zho", 192 | "pos": [ 193 | 1050, 194 | 1410 195 | ], 196 | "size": { 197 | "0": 220, 198 | "1": 100 199 | }, 200 | "flags": {}, 201 | "order": 7, 202 | "mode": 0, 203 | "inputs": [ 204 | { 205 | "name": "text_2", 206 | "type": "STRING", 207 | "link": 38, 208 | "widget": { 209 | "name": "text_2" 210 | } 211 | } 212 | ], 213 | "outputs": [ 214 | { 215 | "name": "text", 216 | "type": "STRING", 217 | "links": [ 218 | 27 219 | ], 220 | "shape": 3, 221 | "slot_index": 0 222 | } 223 | ], 224 | "properties": { 225 | "Node name for S&R": "ConcatText_Zho" 226 | }, 227 | "widgets_values": [ 228 | "xxmixgirl", 229 | "" 230 | ], 231 | "color": "#323", 232 | "bgcolor": "#535" 233 | }, 234 | { 235 | "id": 27, 236 | "type": "PreviewImage", 237 | "pos": [ 238 | 1280, 239 | 970 240 | ], 241 | "size": { 242 | "0": 310, 243 | "1": 540 244 | }, 245 | "flags": {}, 246 | "order": 11, 247 | "mode": 0, 248 | "inputs": [ 249 | { 250 | "name": "images", 251 | "type": "IMAGE", 252 | "link": 33 253 | } 254 | ], 255 | "properties": { 256 | "Node name for S&R": "PreviewImage" 257 | } 258 | }, 259 | { 260 | "id": 28, 261 | "type": "SelfAttentionGuidance", 262 | "pos": [ 263 | 830, 264 | 970 265 | ], 266 | "size": { 267 | "0": 210, 268 | "1": 80 269 | }, 270 | "flags": {}, 271 | "order": 3, 272 | "mode": 0, 273 | "inputs": [ 274 | { 275 | "name": "model", 276 | "type": "MODEL", 277 | "link": 34, 278 | "slot_index": 0 279 | } 280 | ], 281 | "outputs": [ 282 | { 283 | "name": "MODEL", 284 | "type": "MODEL", 285 | "links": [ 286 | 22 287 | ], 288 | "shape": 3, 289 | "slot_index": 0 290 | } 291 | ], 292 | "properties": { 293 | "Node name for S&R": "SelfAttentionGuidance" 294 | }, 295 | "widgets_values": [ 296 | 0.5, 297 | 2 298 | ] 299 | }, 300 | { 301 | "id": 20, 302 | "type": "EmptyLatentImage", 303 | "pos": [ 304 | 510, 305 | 1110 306 | ], 307 | "size": { 308 | "0": 310, 309 | "1": 110 310 | }, 311 | "flags": {}, 312 | "order": 0, 313 | "mode": 0, 314 | "outputs": [ 315 | { 316 | "name": "LATENT", 317 | "type": "LATENT", 318 | "links": [ 319 | 25 320 | ], 321 | "slot_index": 0 322 | } 323 | ], 324 | "properties": { 325 | "Node name for S&R": "EmptyLatentImage" 326 | }, 327 | "widgets_values": [ 328 | 768, 329 | 1280, 330 | 1 331 | ] 332 | }, 333 | { 334 | "id": 29, 335 | "type": "DisplayText_Zho", 336 | "pos": [ 337 | 830, 338 | 1320 339 | ], 340 | "size": [ 341 | 210, 342 | 190 343 | ], 344 | "flags": {}, 345 | "order": 6, 346 | "mode": 0, 347 | "inputs": [ 348 | { 349 | "name": "text", 350 | "type": "STRING", 351 | "link": 37, 352 | "widget": { 353 | "name": "text" 354 | } 355 | } 356 | ], 357 | "outputs": [ 358 | { 359 | "name": "text", 360 | "type": "STRING", 361 | "links": [ 362 | 38 363 | ], 364 | "shape": 3, 365 | "slot_index": 0 366 | } 367 | ], 368 | "properties": { 369 | "Node name for S&R": "DisplayText_Zho" 370 | }, 371 | "widgets_values": [ 372 | "", 373 | "A cute anime girl with big yellow ears that look like clouds. She's wearing a pink dress and is standing in a field of green grass on a clear day." 374 | ], 375 | "color": "#323", 376 | "bgcolor": "#535" 377 | }, 378 | { 379 | "id": 4, 380 | "type": "CheckpointLoaderSimple", 381 | "pos": [ 382 | 510, 383 | 970 384 | ], 385 | "size": [ 386 | 310, 387 | 100 388 | ], 389 | "flags": {}, 390 | "order": 1, 391 | "mode": 0, 392 | "outputs": [ 393 | { 394 | "name": "MODEL", 395 | "type": "MODEL", 396 | "links": [ 397 | 34 398 | ], 399 | "slot_index": 0 400 | }, 401 | { 402 | "name": "CLIP", 403 | "type": "CLIP", 404 | "links": [ 405 | 26, 406 | 28 407 | ], 408 | "slot_index": 1 409 | }, 410 | { 411 | "name": "VAE", 412 | "type": "VAE", 413 | "links": [ 414 | 30 415 | ], 416 | "slot_index": 2 417 | } 418 | ], 419 | "properties": { 420 | "Node name for S&R": "CheckpointLoaderSimple" 421 | }, 422 | "widgets_values": [ 423 | "XXMix_9realisticSDXL.safetensors" 424 | ] 425 | }, 426 | { 427 | "id": 17, 428 | "type": "Gemini_API_S_Zho", 429 | "pos": [ 430 | 510, 431 | 1260 432 | ], 433 | "size": { 434 | "0": 310, 435 | "1": 250 436 | }, 437 | "flags": {}, 438 | "order": 5, 439 | "mode": 0, 440 | "inputs": [ 441 | { 442 | "name": "image", 443 | "type": "IMAGE", 444 | "link": 21, 445 | "slot_index": 0 446 | } 447 | ], 448 | "outputs": [ 449 | { 450 | "name": "text", 451 | "type": "STRING", 452 | "links": [ 453 | 37 454 | ], 455 | "shape": 3, 456 | "slot_index": 0 457 | } 458 | ], 459 | "properties": { 460 | "Node name for S&R": "Gemini_API_S_Zho" 461 | }, 462 | "widgets_values": [ 463 | "text = ' ' # @param {type:\"string\"}\n\nprompt = \"You are creating a prompt for Stable Diffusion to generate an image. First step: describe this image, then put description into text. Second step: generate a text prompt for %s based on first step. Only respond with the prompt itself, but embellish it as needed but keep it under 80 tokens. \" % text", 464 | "gemini-pro-vision", 465 | false 466 | ], 467 | "color": "#323", 468 | "bgcolor": "#535" 469 | }, 470 | { 471 | "id": 18, 472 | "type": "LoadImage", 473 | "pos": [ 474 | 230, 475 | 970 476 | ], 477 | "size": [ 478 | 270, 479 | 540 480 | ], 481 | "flags": {}, 482 | "order": 2, 483 | "mode": 0, 484 | "outputs": [ 485 | { 486 | "name": "IMAGE", 487 | "type": "IMAGE", 488 | "links": [ 489 | 21 490 | ], 491 | "shape": 3, 492 | "slot_index": 0 493 | }, 494 | { 495 | "name": "MASK", 496 | "type": "MASK", 497 | "links": null, 498 | "shape": 3 499 | } 500 | ], 501 | "properties": { 502 | "Node name for S&R": "LoadImage" 503 | }, 504 | "widgets_values": [ 505 | "example.png", 506 | "image" 507 | ] 508 | } 509 | ], 510 | "links": [ 511 | [ 512 | 21, 513 | 18, 514 | 0, 515 | 17, 516 | 0, 517 | "IMAGE" 518 | ], 519 | [ 520 | 22, 521 | 28, 522 | 0, 523 | 19, 524 | 0, 525 | "MODEL" 526 | ], 527 | [ 528 | 23, 529 | 21, 530 | 0, 531 | 19, 532 | 1, 533 | "CONDITIONING" 534 | ], 535 | [ 536 | 24, 537 | 22, 538 | 0, 539 | 19, 540 | 2, 541 | "CONDITIONING" 542 | ], 543 | [ 544 | 25, 545 | 20, 546 | 0, 547 | 19, 548 | 3, 549 | "LATENT" 550 | ], 551 | [ 552 | 26, 553 | 4, 554 | 1, 555 | 21, 556 | 0, 557 | "CLIP" 558 | ], 559 | [ 560 | 27, 561 | 26, 562 | 0, 563 | 21, 564 | 1, 565 | "STRING" 566 | ], 567 | [ 568 | 28, 569 | 4, 570 | 1, 571 | 22, 572 | 0, 573 | "CLIP" 574 | ], 575 | [ 576 | 29, 577 | 19, 578 | 0, 579 | 23, 580 | 0, 581 | "LATENT" 582 | ], 583 | [ 584 | 30, 585 | 4, 586 | 2, 587 | 23, 588 | 1, 589 | "VAE" 590 | ], 591 | [ 592 | 33, 593 | 23, 594 | 0, 595 | 27, 596 | 0, 597 | "IMAGE" 598 | ], 599 | [ 600 | 34, 601 | 4, 602 | 0, 603 | 28, 604 | 0, 605 | "MODEL" 606 | ], 607 | [ 608 | 37, 609 | 17, 610 | 0, 611 | 29, 612 | 0, 613 | "STRING" 614 | ], 615 | [ 616 | 38, 617 | 29, 618 | 0, 619 | 26, 620 | 0, 621 | "STRING" 622 | ] 623 | ], 624 | "groups": [], 625 | "config": {}, 626 | "extra": {}, 627 | "version": 0.4 628 | } 629 | -------------------------------------------------------------------------------- /Gemini_workflows/All-in-One LoRa Training【Zho】.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 32, 3 | "last_link_id": 42, 4 | "nodes": [ 5 | { 6 | "id": 9, 7 | "type": "ImageScale", 8 | "pos": [ 9 | -40, 10 | 3150 11 | ], 12 | "size": { 13 | "0": 272.1335754394531, 14 | "1": 130 15 | }, 16 | "flags": {}, 17 | "order": 8, 18 | "mode": 0, 19 | "inputs": [ 20 | { 21 | "name": "image", 22 | "type": "IMAGE", 23 | "link": 22, 24 | "slot_index": 0 25 | } 26 | ], 27 | "outputs": [ 28 | { 29 | "name": "IMAGE", 30 | "type": "IMAGE", 31 | "links": [ 32 | 10, 33 | 23 34 | ], 35 | "shape": 3, 36 | "slot_index": 0 37 | } 38 | ], 39 | "properties": { 40 | "Node name for S&R": "ImageScale" 41 | }, 42 | "widgets_values": [ 43 | "nearest-exact", 44 | 512, 45 | 512, 46 | "center" 47 | ] 48 | }, 49 | { 50 | "id": 17, 51 | "type": "Gemini_API_S_Zho", 52 | "pos": [ 53 | 520, 54 | 3280 55 | ], 56 | "size": { 57 | "0": 260, 58 | "1": 102 59 | }, 60 | "flags": {}, 61 | "order": 16, 62 | "mode": 0, 63 | "inputs": [ 64 | { 65 | "name": "image", 66 | "type": "IMAGE", 67 | "link": null, 68 | "slot_index": 0 69 | }, 70 | { 71 | "name": "prompt", 72 | "type": "STRING", 73 | "link": 19, 74 | "widget": { 75 | "name": "prompt" 76 | }, 77 | "slot_index": 1 78 | } 79 | ], 80 | "outputs": [ 81 | { 82 | "name": "text", 83 | "type": "STRING", 84 | "links": [ 85 | 18 86 | ], 87 | "shape": 3, 88 | "slot_index": 0 89 | } 90 | ], 91 | "properties": { 92 | "Node name for S&R": "Gemini_API_S_Zho" 93 | }, 94 | "widgets_values": [ 95 | "Use concise phrases to describe the image, separated by commas, avoiding complete sentences. Provide an overview of key elements such as subject, colors, lighting, composition, details and texture, artistic techniques, style, brushwork, and camera use (if applicable). Ensure a quick and thorough understanding of the visual content", 96 | "gemini-pro", 97 | false 98 | ] 99 | }, 100 | { 101 | "id": 4, 102 | "type": "Gemini_API_S_Zho", 103 | "pos": [ 104 | 250, 105 | 3150 106 | ], 107 | "size": { 108 | "0": 250, 109 | "1": 220 110 | }, 111 | "flags": {}, 112 | "order": 11, 113 | "mode": 0, 114 | "inputs": [ 115 | { 116 | "name": "image", 117 | "type": "IMAGE", 118 | "link": 23, 119 | "slot_index": 0 120 | } 121 | ], 122 | "outputs": [ 123 | { 124 | "name": "text", 125 | "type": "STRING", 126 | "links": [ 127 | 7 128 | ], 129 | "shape": 3, 130 | "slot_index": 0 131 | } 132 | ], 133 | "properties": { 134 | "Node name for S&R": "Gemini_API_S_Zho" 135 | }, 136 | "widgets_values": [ 137 | "Use concise phrases to describe the image, separated by commas, avoiding complete sentences. Provide an overview of key elements such as subject, colors, lighting, composition, details and texture, artistic techniques, style, brushwork, and camera use (if applicable). Ensure a quick and thorough understanding of the visual content", 138 | "gemini-pro-vision", 139 | false 140 | ] 141 | }, 142 | { 143 | "id": 6, 144 | "type": "LoadImage", 145 | "pos": [ 146 | -390, 147 | 3150 148 | ], 149 | "size": { 150 | "0": 330, 151 | "1": 490 152 | }, 153 | "flags": {}, 154 | "order": 5, 155 | "mode": 0, 156 | "inputs": [ 157 | { 158 | "name": "image", 159 | "type": "COMBO", 160 | "link": 29, 161 | "widget": { 162 | "name": "image" 163 | }, 164 | "slot_index": 0 165 | } 166 | ], 167 | "outputs": [ 168 | { 169 | "name": "IMAGE", 170 | "type": "IMAGE", 171 | "links": [ 172 | 22 173 | ], 174 | "shape": 3, 175 | "slot_index": 0 176 | }, 177 | { 178 | "name": "MASK", 179 | "type": "MASK", 180 | "links": null, 181 | "shape": 3 182 | } 183 | ], 184 | "properties": { 185 | "Node name for S&R": "LoadImage" 186 | }, 187 | "widgets_values": [ 188 | "M1_00026_.png", 189 | "image" 190 | ] 191 | }, 192 | { 193 | "id": 18, 194 | "type": "DisplayText_Zho", 195 | "pos": [ 196 | 520, 197 | 3430 198 | ], 199 | "size": { 200 | "0": 260, 201 | "1": 90 202 | }, 203 | "flags": {}, 204 | "order": 17, 205 | "mode": 0, 206 | "inputs": [ 207 | { 208 | "name": "text", 209 | "type": "STRING", 210 | "link": 18, 211 | "widget": { 212 | "name": "text" 213 | } 214 | } 215 | ], 216 | "outputs": [ 217 | { 218 | "name": "text", 219 | "type": "STRING", 220 | "links": [ 221 | 30 222 | ], 223 | "shape": 3, 224 | "slot_index": 0 225 | } 226 | ], 227 | "properties": { 228 | "Node name for S&R": "DisplayText_Zho" 229 | }, 230 | "widgets_values": [ 231 | "", 232 | "cubism, painting, cat, blue, yellow, brown, black, white, sharp angles, lines, textured background" 233 | ] 234 | }, 235 | { 236 | "id": 10, 237 | "type": "SaveImage", 238 | "pos": [ 239 | -40, 240 | 3330 241 | ], 242 | "size": { 243 | "0": 270, 244 | "1": 310 245 | }, 246 | "flags": {}, 247 | "order": 10, 248 | "mode": 0, 249 | "inputs": [ 250 | { 251 | "name": "images", 252 | "type": "IMAGE", 253 | "link": 10 254 | } 255 | ], 256 | "properties": {}, 257 | "widgets_values": [ 258 | "LoraTest/1_TTTEST/T1" 259 | ] 260 | }, 261 | { 262 | "id": 31, 263 | "type": "VAEDecode", 264 | "pos": [ 265 | 720, 266 | 3720 267 | ], 268 | "size": { 269 | "0": 210, 270 | "1": 46 271 | }, 272 | "flags": {}, 273 | "order": 12, 274 | "mode": 2, 275 | "inputs": [ 276 | { 277 | "name": "samples", 278 | "type": "LATENT", 279 | "link": 40 280 | }, 281 | { 282 | "name": "vae", 283 | "type": "VAE", 284 | "link": 41, 285 | "slot_index": 1 286 | } 287 | ], 288 | "outputs": [ 289 | { 290 | "name": "IMAGE", 291 | "type": "IMAGE", 292 | "links": [ 293 | 42 294 | ], 295 | "shape": 3, 296 | "slot_index": 0 297 | } 298 | ], 299 | "properties": { 300 | "Node name for S&R": "VAEDecode" 301 | } 302 | }, 303 | { 304 | "id": 25, 305 | "type": "CheckpointLoaderSimple", 306 | "pos": [ 307 | -390, 308 | 3720 309 | ], 310 | "size": { 311 | "0": 330, 312 | "1": 100 313 | }, 314 | "flags": {}, 315 | "order": 0, 316 | "mode": 2, 317 | "outputs": [ 318 | { 319 | "name": "MODEL", 320 | "type": "MODEL", 321 | "links": [ 322 | 32 323 | ], 324 | "shape": 3, 325 | "slot_index": 0 326 | }, 327 | { 328 | "name": "CLIP", 329 | "type": "CLIP", 330 | "links": [ 331 | 33 332 | ], 333 | "shape": 3, 334 | "slot_index": 1 335 | }, 336 | { 337 | "name": "VAE", 338 | "type": "VAE", 339 | "links": [ 340 | 41 341 | ], 342 | "shape": 3 343 | } 344 | ], 345 | "properties": { 346 | "Node name for S&R": "CheckpointLoaderSimple" 347 | }, 348 | "widgets_values": [ 349 | "v1-5-pruned-emaonly.safetensors" 350 | ] 351 | }, 352 | { 353 | "id": 32, 354 | "type": "PreviewImage", 355 | "pos": [ 356 | 720, 357 | 3810 358 | ], 359 | "size": { 360 | "0": 370, 361 | "1": 370 362 | }, 363 | "flags": {}, 364 | "order": 14, 365 | "mode": 2, 366 | "inputs": [ 367 | { 368 | "name": "images", 369 | "type": "IMAGE", 370 | "link": 42 371 | } 372 | ], 373 | "properties": { 374 | "Node name for S&R": "PreviewImage" 375 | } 376 | }, 377 | { 378 | "id": 7, 379 | "type": "DisplayText_Zho", 380 | "pos": [ 381 | 250, 382 | 3420 383 | ], 384 | "size": { 385 | "0": 250, 386 | "1": 220 387 | }, 388 | "flags": {}, 389 | "order": 13, 390 | "mode": 0, 391 | "inputs": [ 392 | { 393 | "name": "text", 394 | "type": "STRING", 395 | "link": 7, 396 | "widget": { 397 | "name": "text" 398 | } 399 | } 400 | ], 401 | "outputs": [ 402 | { 403 | "name": "text", 404 | "type": "STRING", 405 | "links": [ 406 | 17 407 | ], 408 | "shape": 3, 409 | "slot_index": 0 410 | } 411 | ], 412 | "properties": { 413 | "Node name for S&R": "DisplayText_Zho" 414 | }, 415 | "widgets_values": [ 416 | "", 417 | "A cubism-style painting of a cat, with a blue and yellow background, the cat is brown, black, and white, with sharp angles and lines, and a textured background." 418 | ] 419 | }, 420 | { 421 | "id": 24, 422 | "type": "ConcatText_Zho", 423 | "pos": [ 424 | 520, 425 | 3560 426 | ], 427 | "size": { 428 | "0": 260, 429 | "1": 80 430 | }, 431 | "flags": {}, 432 | "order": 18, 433 | "mode": 0, 434 | "inputs": [ 435 | { 436 | "name": "text_2", 437 | "type": "STRING", 438 | "link": 30, 439 | "widget": { 440 | "name": "text_2" 441 | } 442 | } 443 | ], 444 | "outputs": [ 445 | { 446 | "name": "text", 447 | "type": "STRING", 448 | "links": [ 449 | 31 450 | ], 451 | "shape": 3, 452 | "slot_index": 0 453 | } 454 | ], 455 | "properties": { 456 | "Node name for S&R": "ConcatText_Zho" 457 | }, 458 | "widgets_values": [ 459 | "AlbertGleizesCat", 460 | "" 461 | ] 462 | }, 463 | { 464 | "id": 29, 465 | "type": "CLIPTextEncode", 466 | "pos": [ 467 | 190, 468 | 3880 469 | ], 470 | "size": [ 471 | 210, 472 | 90 473 | ], 474 | "flags": {}, 475 | "order": 7, 476 | "mode": 2, 477 | "inputs": [ 478 | { 479 | "name": "clip", 480 | "type": "CLIP", 481 | "link": 37 482 | } 483 | ], 484 | "outputs": [ 485 | { 486 | "name": "CONDITIONING", 487 | "type": "CONDITIONING", 488 | "links": [ 489 | 38 490 | ], 491 | "shape": 3, 492 | "slot_index": 0 493 | } 494 | ], 495 | "properties": { 496 | "Node name for S&R": "CLIPTextEncode" 497 | }, 498 | "widgets_values": [ 499 | "bad" 500 | ] 501 | }, 502 | { 503 | "id": 28, 504 | "type": "CLIPTextEncode", 505 | "pos": [ 506 | 190, 507 | 3720 508 | ], 509 | "size": [ 510 | 210, 511 | 110 512 | ], 513 | "flags": {}, 514 | "order": 6, 515 | "mode": 2, 516 | "inputs": [ 517 | { 518 | "name": "clip", 519 | "type": "CLIP", 520 | "link": 35 521 | } 522 | ], 523 | "outputs": [ 524 | { 525 | "name": "CONDITIONING", 526 | "type": "CONDITIONING", 527 | "links": [ 528 | 36 529 | ], 530 | "shape": 3, 531 | "slot_index": 0 532 | } 533 | ], 534 | "properties": { 535 | "Node name for S&R": "CLIPTextEncode" 536 | }, 537 | "widgets_values": [ 538 | "AlbertGleizesCat" 539 | ] 540 | }, 541 | { 542 | "id": 30, 543 | "type": "EmptyLatentImage", 544 | "pos": [ 545 | -390, 546 | 3870 547 | ], 548 | "size": { 549 | "0": 330, 550 | "1": 110 551 | }, 552 | "flags": {}, 553 | "order": 1, 554 | "mode": 2, 555 | "outputs": [ 556 | { 557 | "name": "LATENT", 558 | "type": "LATENT", 559 | "links": [ 560 | 39 561 | ], 562 | "shape": 3 563 | } 564 | ], 565 | "properties": { 566 | "Node name for S&R": "EmptyLatentImage" 567 | }, 568 | "widgets_values": [ 569 | 512, 570 | 512, 571 | 1 572 | ] 573 | }, 574 | { 575 | "id": 23, 576 | "type": "PrimitiveNode", 577 | "pos": [ 578 | -620, 579 | 3150 580 | ], 581 | "size": { 582 | "0": 210, 583 | "1": 106 584 | }, 585 | "flags": {}, 586 | "order": 2, 587 | "mode": 0, 588 | "outputs": [ 589 | { 590 | "name": "COMBO", 591 | "type": "COMBO", 592 | "links": [ 593 | 29 594 | ], 595 | "widget": { 596 | "name": "image" 597 | } 598 | } 599 | ], 600 | "title": "image", 601 | "properties": { 602 | "Run widget replace on values": false 603 | }, 604 | "widgets_values": [ 605 | "M1_00026_.png", 606 | "fixed", 607 | "" 608 | ] 609 | }, 610 | { 611 | "id": 27, 612 | "type": "KSampler", 613 | "pos": [ 614 | 420, 615 | 3720 616 | ], 617 | "size": { 618 | "0": 280, 619 | "1": 262 620 | }, 621 | "flags": {}, 622 | "order": 9, 623 | "mode": 2, 624 | "inputs": [ 625 | { 626 | "name": "model", 627 | "type": "MODEL", 628 | "link": 34 629 | }, 630 | { 631 | "name": "positive", 632 | "type": "CONDITIONING", 633 | "link": 36 634 | }, 635 | { 636 | "name": "negative", 637 | "type": "CONDITIONING", 638 | "link": 38 639 | }, 640 | { 641 | "name": "latent_image", 642 | "type": "LATENT", 643 | "link": 39, 644 | "slot_index": 3 645 | } 646 | ], 647 | "outputs": [ 648 | { 649 | "name": "LATENT", 650 | "type": "LATENT", 651 | "links": [ 652 | 40 653 | ], 654 | "shape": 3, 655 | "slot_index": 0 656 | } 657 | ], 658 | "properties": { 659 | "Node name for S&R": "KSampler" 660 | }, 661 | "widgets_values": [ 662 | 301423747180792, 663 | "fixed", 664 | 20, 665 | 8, 666 | "euler", 667 | "normal", 668 | 1 669 | ] 670 | }, 671 | { 672 | "id": 26, 673 | "type": "LoraLoader", 674 | "pos": [ 675 | -40, 676 | 3720 677 | ], 678 | "size": { 679 | "0": 210, 680 | "1": 130 681 | }, 682 | "flags": {}, 683 | "order": 4, 684 | "mode": 2, 685 | "inputs": [ 686 | { 687 | "name": "model", 688 | "type": "MODEL", 689 | "link": 32 690 | }, 691 | { 692 | "name": "clip", 693 | "type": "CLIP", 694 | "link": 33 695 | } 696 | ], 697 | "outputs": [ 698 | { 699 | "name": "MODEL", 700 | "type": "MODEL", 701 | "links": [ 702 | 34 703 | ], 704 | "shape": 3, 705 | "slot_index": 0 706 | }, 707 | { 708 | "name": "CLIP", 709 | "type": "CLIP", 710 | "links": [ 711 | 35, 712 | 37 713 | ], 714 | "shape": 3, 715 | "slot_index": 1 716 | } 717 | ], 718 | "properties": { 719 | "Node name for S&R": "LoraLoader" 720 | }, 721 | "widgets_values": [ 722 | "TEST-1.safetensors", 723 | 1, 724 | 1 725 | ] 726 | }, 727 | { 728 | "id": 20, 729 | "type": "Save Text File_mne", 730 | "pos": [ 731 | 800, 732 | 3150 733 | ], 734 | "size": { 735 | "0": 290, 736 | "1": 174 737 | }, 738 | "flags": {}, 739 | "order": 19, 740 | "mode": 0, 741 | "inputs": [ 742 | { 743 | "name": "text", 744 | "type": "STRING", 745 | "link": 31, 746 | "widget": { 747 | "name": "text" 748 | } 749 | } 750 | ], 751 | "outputs": [ 752 | { 753 | "name": "STRING", 754 | "type": "STRING", 755 | "links": null, 756 | "shape": 3 757 | }, 758 | { 759 | "name": "STRING", 760 | "type": "STRING", 761 | "links": null, 762 | "shape": 3 763 | } 764 | ], 765 | "properties": { 766 | "Node name for S&R": "Save Text File_mne" 767 | }, 768 | "widgets_values": [ 769 | "", 770 | "./output/LoraTest/1_TTTEST", 771 | "T1", 772 | "_", 773 | 5, 774 | "false" 775 | ] 776 | }, 777 | { 778 | "id": 16, 779 | "type": "ConcatText_Zho", 780 | "pos": [ 781 | 520, 782 | 3150 783 | ], 784 | "size": { 785 | "0": 260, 786 | "1": 80 787 | }, 788 | "flags": {}, 789 | "order": 15, 790 | "mode": 0, 791 | "inputs": [ 792 | { 793 | "name": "text_2", 794 | "type": "STRING", 795 | "link": 17, 796 | "widget": { 797 | "name": "text_2" 798 | } 799 | } 800 | ], 801 | "outputs": [ 802 | { 803 | "name": "text", 804 | "type": "STRING", 805 | "links": [ 806 | 19 807 | ], 808 | "shape": 3, 809 | "slot_index": 0 810 | } 811 | ], 812 | "properties": { 813 | "Node name for S&R": "ConcatText_Zho" 814 | }, 815 | "widgets_values": [ 816 | "Transform the following text into tags, separated by commas:", 817 | "" 818 | ] 819 | }, 820 | { 821 | "id": 1, 822 | "type": "Lora Training in ComfyUI", 823 | "pos": [ 824 | 800, 825 | 3370 826 | ], 827 | "size": { 828 | "0": 290, 829 | "1": 270 830 | }, 831 | "flags": {}, 832 | "order": 3, 833 | "mode": 2, 834 | "properties": { 835 | "Node name for S&R": "Lora Training in ComfyUI" 836 | }, 837 | "widgets_values": [ 838 | "v1-5-pruned-emaonly.safetensors", 839 | "./output/LoraTest", 840 | 1, 841 | 40, 842 | 10, 843 | "TEST-1", 844 | 1, 845 | "models/loras" 846 | ] 847 | } 848 | ], 849 | "links": [ 850 | [ 851 | 7, 852 | 4, 853 | 0, 854 | 7, 855 | 0, 856 | "STRING" 857 | ], 858 | [ 859 | 10, 860 | 9, 861 | 0, 862 | 10, 863 | 0, 864 | "IMAGE" 865 | ], 866 | [ 867 | 17, 868 | 7, 869 | 0, 870 | 16, 871 | 0, 872 | "STRING" 873 | ], 874 | [ 875 | 18, 876 | 17, 877 | 0, 878 | 18, 879 | 0, 880 | "STRING" 881 | ], 882 | [ 883 | 19, 884 | 16, 885 | 0, 886 | 17, 887 | 1, 888 | "STRING" 889 | ], 890 | [ 891 | 22, 892 | 6, 893 | 0, 894 | 9, 895 | 0, 896 | "IMAGE" 897 | ], 898 | [ 899 | 23, 900 | 9, 901 | 0, 902 | 4, 903 | 0, 904 | "IMAGE" 905 | ], 906 | [ 907 | 29, 908 | 23, 909 | 0, 910 | 6, 911 | 0, 912 | "COMBO" 913 | ], 914 | [ 915 | 30, 916 | 18, 917 | 0, 918 | 24, 919 | 0, 920 | "STRING" 921 | ], 922 | [ 923 | 31, 924 | 24, 925 | 0, 926 | 20, 927 | 0, 928 | "STRING" 929 | ], 930 | [ 931 | 32, 932 | 25, 933 | 0, 934 | 26, 935 | 0, 936 | "MODEL" 937 | ], 938 | [ 939 | 33, 940 | 25, 941 | 1, 942 | 26, 943 | 1, 944 | "CLIP" 945 | ], 946 | [ 947 | 34, 948 | 26, 949 | 0, 950 | 27, 951 | 0, 952 | "MODEL" 953 | ], 954 | [ 955 | 35, 956 | 26, 957 | 1, 958 | 28, 959 | 0, 960 | "CLIP" 961 | ], 962 | [ 963 | 36, 964 | 28, 965 | 0, 966 | 27, 967 | 1, 968 | "CONDITIONING" 969 | ], 970 | [ 971 | 37, 972 | 26, 973 | 1, 974 | 29, 975 | 0, 976 | "CLIP" 977 | ], 978 | [ 979 | 38, 980 | 29, 981 | 0, 982 | 27, 983 | 2, 984 | "CONDITIONING" 985 | ], 986 | [ 987 | 39, 988 | 30, 989 | 0, 990 | 27, 991 | 3, 992 | "LATENT" 993 | ], 994 | [ 995 | 40, 996 | 27, 997 | 0, 998 | 31, 999 | 0, 1000 | "LATENT" 1001 | ], 1002 | [ 1003 | 41, 1004 | 25, 1005 | 2, 1006 | 31, 1007 | 1, 1008 | "VAE" 1009 | ], 1010 | [ 1011 | 42, 1012 | 31, 1013 | 0, 1014 | 32, 1015 | 0, 1016 | "IMAGE" 1017 | ] 1018 | ], 1019 | "groups": [], 1020 | "config": {}, 1021 | "extra": {}, 1022 | "version": 0.4 1023 | } -------------------------------------------------------------------------------- /GeminiAPINode.py: -------------------------------------------------------------------------------- 1 | import os 2 | import io 3 | import json 4 | import requests 5 | import torch 6 | import google.generativeai as genai 7 | from io import BytesIO 8 | from PIL import Image 9 | 10 | p = os.path.dirname(os.path.realpath(__file__)) 11 | 12 | def get_gemini_api_key(): 13 | try: 14 | config_path = os.path.join(p, 'config.json') 15 | with open(config_path, 'r') as f: 16 | config = json.load(f) 17 | api_key = config["GEMINI_API_KEY"] 18 | except: 19 | print("出错啦 Error: API key is required") 20 | return "" 21 | return api_key 22 | 23 | class Gemini_API_Zho: 24 | 25 | def __init__(self, api_key=None): 26 | self.api_key = api_key 27 | if self.api_key is not None: 28 | genai.configure(api_key=self.api_key,transport='rest') 29 | 30 | @classmethod 31 | def INPUT_TYPES(cls): 32 | return { 33 | "required": { 34 | "prompt": ("STRING", {"default": "What is the meaning of life?", "multiline": True}), 35 | "model_name": (["gemini-pro", "gemini-pro-vision", "gemini-1.5-pro-latest"],), 36 | "stream": ("BOOLEAN", {"default": False}), 37 | "api_key": ("STRING", {"default": ""}) # Add api_key as an input 38 | }, 39 | "optional": { 40 | "image": ("IMAGE",), 41 | } 42 | } 43 | 44 | RETURN_TYPES = ("STRING",) 45 | RETURN_NAMES = ("text",) 46 | FUNCTION = "generate_content" 47 | 48 | CATEGORY = "Zho模块组/✨Gemini" 49 | 50 | def tensor_to_image(self, tensor): 51 | # 确保张量是在CPU上 52 | tensor = tensor.cpu() 53 | 54 | # 将张量数据转换为0-255范围并转换为整数 55 | # 这里假设张量已经是H x W x C格式 56 | image_np = tensor.squeeze().mul(255).clamp(0, 255).byte().numpy() 57 | 58 | # 创建PIL图像 59 | image = Image.fromarray(image_np, mode='RGB') 60 | return image 61 | 62 | def generate_content(self, prompt, model_name, stream, api_key, image=None): 63 | if api_key: 64 | self.api_key = api_key 65 | genai.configure(api_key=self.api_key,transport='rest') 66 | if not self.api_key: 67 | raise ValueError("API key is required") 68 | 69 | model = genai.GenerativeModel(model_name) 70 | 71 | if model_name == 'gemini-pro': 72 | if stream: 73 | response = model.generate_content(prompt, stream=True) 74 | textoutput = "\n".join([chunk.text for chunk in response]) 75 | else: 76 | response = model.generate_content(prompt) 77 | textoutput = response.text 78 | 79 | if model_name == 'gemini-pro-vision': 80 | if image == None: 81 | raise ValueError("gemini-pro-vision needs image") 82 | else: 83 | # 转换图像 84 | pil_image = self.tensor_to_image(image) 85 | 86 | # 直接使用PIL图像 87 | if stream: 88 | response = model.generate_content([prompt, pil_image], stream=True) 89 | textoutput = "\n".join([chunk.text for chunk in response]) 90 | else: 91 | response = model.generate_content([prompt, pil_image]) 92 | textoutput = response.text 93 | 94 | if model_name == 'gemini-1.5-pro-latest': 95 | if image == None: 96 | if stream: 97 | response = model.generate_content(prompt, stream=True) 98 | textoutput = "\n".join([chunk.text for chunk in response]) 99 | else: 100 | response = model.generate_content(prompt) 101 | textoutput = response.text 102 | else: 103 | # 转换图像 104 | pil_image = self.tensor_to_image(image) 105 | 106 | # 直接使用PIL图像 107 | if stream: 108 | response = model.generate_content([prompt, pil_image], stream=True) 109 | textoutput = "\n".join([chunk.text for chunk in response]) 110 | else: 111 | response = model.generate_content([prompt, pil_image]) 112 | textoutput = response.text 113 | 114 | return (textoutput,) 115 | 116 | 117 | class Gemini_API_Vsion_ImgURL_Zho: 118 | 119 | def __init__(self, api_key=None): 120 | self.api_key = api_key 121 | if self.api_key is not None: 122 | genai.configure(api_key=self.api_key,transport='rest') 123 | 124 | @classmethod 125 | def INPUT_TYPES(cls): 126 | return { 127 | "required": { 128 | "prompt": ("STRING", {"default": "Describe this image", "multiline": True}), 129 | "image_url": ("STRING", {"default": ""}), 130 | "model_name": (["gemini-pro-vision", "gemini-1.5-pro-latest"],), 131 | "stream": ("BOOLEAN", {"default": False}), 132 | "api_key": ("STRING", {"default": ""}) # Add api_key as an input 133 | } 134 | } 135 | 136 | RETURN_TYPES = ("STRING",) 137 | RETURN_NAMES = ("text",) 138 | FUNCTION = "generate_content" 139 | 140 | CATEGORY = "Zho模块组/✨Gemini" 141 | 142 | def generate_content(self, prompt, model_name, stream, api_key, image_url): 143 | if api_key: 144 | self.api_key = api_key 145 | genai.configure(api_key=self.api_key,transport='rest') 146 | if not self.api_key: 147 | raise ValueError("API key is required") 148 | 149 | # Load the image from the URL 150 | response = requests.get(image_url) 151 | if response.status_code != 200: 152 | raise ValueError("Failed to load image from URL") 153 | img = Image.open(BytesIO(response.content)) 154 | 155 | model = genai.GenerativeModel(model_name) 156 | 157 | if stream: 158 | response = model.generate_content([prompt, img], stream=True) 159 | textoutput = "\n".join([chunk.text for chunk in response]) 160 | else: 161 | response = model.generate_content([prompt, img]) 162 | textoutput = response.text 163 | 164 | return (textoutput,) 165 | 166 | #chat 167 | class Gemini_API_Chat_Zho: 168 | 169 | def __init__(self, api_key=None): 170 | self.api_key = api_key 171 | self.chat = None # 初始化时,聊天实例为空 172 | if self.api_key is not None: 173 | genai.configure(api_key=self.api_key,transport='rest') 174 | 175 | @classmethod 176 | def INPUT_TYPES(cls): 177 | return { 178 | "required": { 179 | "prompt": ("STRING", {"default": "What is the meaning of life?", "multiline": True}), 180 | "model_name": (["gemini-pro", "gemini-1.5-pro-latest"],), 181 | "api_key": ("STRING", {"default": ""}) # Add api_key as an input 182 | }, 183 | "optional": { 184 | "image": ("IMAGE",), 185 | } 186 | } 187 | 188 | RETURN_TYPES = ("STRING",) 189 | RETURN_NAMES = ("response",) 190 | FUNCTION = "generate_chat" 191 | 192 | CATEGORY = "Zho模块组/✨Gemini" 193 | 194 | def generate_chat(self, prompt, model_name, api_key): 195 | if api_key: 196 | self.api_key = api_key 197 | genai.configure(api_key=self.api_key,transport='rest') 198 | if not self.api_key: 199 | raise ValueError("API key is required") 200 | 201 | if not self.chat: 202 | model = genai.GenerativeModel(model_name) 203 | self.chat = model.start_chat(history=[]) 204 | 205 | if model_name == 'gemini-pro': 206 | response = self.chat.send_message(prompt) 207 | textoutput = response.text 208 | chat_history = self.format_chat_history(self.chat) 209 | 210 | if model_name == 'gemini-1.5-pro-latest': 211 | if image == None: 212 | response = self.chat.send_message(prompt) 213 | textoutput = response.text 214 | chat_history = self.format_chat_history(self.chat) 215 | else: 216 | # 转换图像 217 | pil_image = self.tensor_to_image(image) 218 | 219 | response = self.chat.send_message([prompt, pil_image]) 220 | textoutput = response.text 221 | chat_history = self.format_chat_history(self.chat) 222 | 223 | return (chat_history,) 224 | 225 | def format_chat_history(self, chat): 226 | formatted_history = [] 227 | for message in chat.history: 228 | formatted_message = f"{message.role}: {message.parts[0].text}" 229 | formatted_history.append(formatted_message) 230 | formatted_history.append("-" * 40) # 添加分隔线 231 | return "\n".join(formatted_history) 232 | 233 | 234 | class Gemini_API_S_Zho: 235 | 236 | def __init__(self): 237 | self.api_key = get_gemini_api_key() 238 | if self.api_key is not None: 239 | genai.configure(api_key=self.api_key,transport='rest') 240 | 241 | @classmethod 242 | def INPUT_TYPES(cls): 243 | return { 244 | "required": { 245 | "prompt": ("STRING", {"default": "What is the meaning of life?", "multiline": True}), 246 | "model_name": (["gemini-pro", "gemini-pro-vision", "gemini-1.5-pro-latest"],), 247 | "stream": ("BOOLEAN", {"default": False}), 248 | }, 249 | "optional": { 250 | "image": ("IMAGE",), 251 | } 252 | } 253 | 254 | RETURN_TYPES = ("STRING",) 255 | RETURN_NAMES = ("text",) 256 | FUNCTION = "generate_content" 257 | 258 | CATEGORY = "Zho模块组/✨Gemini" 259 | 260 | def tensor_to_image(self, tensor): 261 | # 确保张量是在CPU上 262 | tensor = tensor.cpu() 263 | 264 | # 将张量数据转换为0-255范围并转换为整数 265 | # 这里假设张量已经是H x W x C格式 266 | image_np = tensor.squeeze().mul(255).clamp(0, 255).byte().numpy() 267 | 268 | # 创建PIL图像 269 | image = Image.fromarray(image_np, mode='RGB') 270 | return image 271 | 272 | def generate_content(self, prompt, model_name, stream, image=None): 273 | if not self.api_key: 274 | raise ValueError("API key is required") 275 | 276 | model = genai.GenerativeModel(model_name) 277 | 278 | if model_name == 'gemini-pro': 279 | if stream: 280 | response = model.generate_content(prompt, stream=True) 281 | textoutput = "\n".join([chunk.text for chunk in response]) 282 | else: 283 | response = model.generate_content(prompt) 284 | textoutput = response.text 285 | 286 | if model_name == 'gemini-pro-vision': 287 | if image == None: 288 | raise ValueError("gemini-pro-vision needs image") 289 | else: 290 | # 转换图像 291 | pil_image = self.tensor_to_image(image) 292 | 293 | # 直接使用PIL图像 294 | if stream: 295 | response = model.generate_content([prompt, pil_image], stream=True) 296 | textoutput = "\n".join([chunk.text for chunk in response]) 297 | else: 298 | response = model.generate_content([prompt, pil_image]) 299 | textoutput = response.text 300 | 301 | if model_name == 'gemini-1.5-pro-latest': 302 | if image == None: 303 | if stream: 304 | response = model.generate_content(prompt, stream=True) 305 | textoutput = "\n".join([chunk.text for chunk in response]) 306 | else: 307 | response = model.generate_content(prompt) 308 | textoutput = response.text 309 | else: 310 | # 转换图像 311 | pil_image = self.tensor_to_image(image) 312 | 313 | # 直接使用PIL图像 314 | if stream: 315 | response = model.generate_content([prompt, pil_image], stream=True) 316 | textoutput = "\n".join([chunk.text for chunk in response]) 317 | else: 318 | response = model.generate_content([prompt, pil_image]) 319 | textoutput = response.text 320 | 321 | return (textoutput,) 322 | 323 | 324 | class Gemini_API_S_Vsion_ImgURL_Zho: 325 | 326 | def __init__(self): 327 | self.api_key = get_gemini_api_key() 328 | if self.api_key is not None: 329 | genai.configure(api_key=self.api_key,transport='rest') 330 | 331 | @classmethod 332 | def INPUT_TYPES(cls): 333 | return { 334 | "required": { 335 | "prompt": ("STRING", {"default": "Describe this image", "multiline": True}), 336 | "image_url": ("STRING", {"default": ""}), 337 | "model_name": (["gemini-pro-vision", "gemini-1.5-pro-latest"],), 338 | "stream": ("BOOLEAN", {"default": False}), 339 | } 340 | } 341 | 342 | RETURN_TYPES = ("STRING",) 343 | RETURN_NAMES = ("text",) 344 | FUNCTION = "generate_content" 345 | 346 | CATEGORY = "Zho模块组/✨Gemini" 347 | 348 | def generate_content(self, prompt, model_name, stream, image_url): 349 | if not self.api_key: 350 | raise ValueError("API key is required") 351 | 352 | # Load the image from the URL 353 | response = requests.get(image_url) 354 | if response.status_code != 200: 355 | raise ValueError("Failed to load image from URL") 356 | img = Image.open(BytesIO(response.content)) 357 | 358 | model = genai.GenerativeModel(model_name) 359 | 360 | if stream: 361 | response = model.generate_content([prompt, img], stream=True) 362 | textoutput = "\n".join([chunk.text for chunk in response]) 363 | else: 364 | response = model.generate_content([prompt, img]) 365 | textoutput = response.text 366 | 367 | return (textoutput,) 368 | 369 | 370 | #chat 371 | class Gemini_API_S_Chat_Zho: 372 | 373 | def __init__(self): 374 | self.api_key = get_gemini_api_key() 375 | self.chat = None # 初始化时,聊天实例为空 376 | if self.api_key is not None: 377 | genai.configure(api_key=self.api_key,transport='rest') 378 | 379 | @classmethod 380 | def INPUT_TYPES(cls): 381 | return { 382 | "required": { 383 | "prompt": ("STRING", {"default": "What is the meaning of life?", "multiline": True}), 384 | "model_name": (["gemini-pro", "gemini-1.5-pro-latest"],), 385 | }, 386 | "optional": { 387 | "image": ("IMAGE",), 388 | } 389 | } 390 | 391 | RETURN_TYPES = ("STRING",) 392 | RETURN_NAMES = ("response",) 393 | FUNCTION = "generate_chat" 394 | 395 | CATEGORY = "Zho模块组/✨Gemini" 396 | 397 | def tensor_to_image(self, tensor): 398 | # 确保张量是在CPU上 399 | tensor = tensor.cpu() 400 | 401 | # 将张量数据转换为0-255范围并转换为整数 402 | # 这里假设张量已经是H x W x C格式 403 | image_np = tensor.squeeze().mul(255).clamp(0, 255).byte().numpy() 404 | 405 | # 创建PIL图像 406 | image = Image.fromarray(image_np, mode='RGB') 407 | return image 408 | 409 | def generate_chat(self, prompt, model_name): 410 | if not self.api_key: 411 | raise ValueError("API key is required") 412 | 413 | if not self.chat: 414 | model = genai.GenerativeModel(model_name) 415 | self.chat = model.start_chat(history=[]) 416 | 417 | if model_name == 'gemini-pro': 418 | response = self.chat.send_message(prompt) 419 | textoutput = response.text 420 | chat_history = self.format_chat_history(self.chat) 421 | 422 | if model_name == 'gemini-1.5-pro-latest': 423 | if image == None: 424 | response = self.chat.send_message(prompt) 425 | textoutput = response.text 426 | chat_history = self.format_chat_history(self.chat) 427 | else: 428 | # 转换图像 429 | pil_image = self.tensor_to_image(image) 430 | 431 | response = self.chat.send_message([prompt, pil_image]) 432 | textoutput = response.text 433 | chat_history = self.format_chat_history(self.chat) 434 | 435 | return (chat_history,) 436 | 437 | def format_chat_history(self, chat): 438 | formatted_history = [] 439 | for message in chat.history: 440 | formatted_message = f"{message.role}: {message.parts[0].text}" 441 | formatted_history.append(formatted_message) 442 | formatted_history.append("-" * 40) # 添加分隔线 443 | return "\n".join(formatted_history) 444 | 445 | 446 | # System instructions 447 | class Gemini_15P_API_S_Advance_Zho: 448 | 449 | def __init__(self): 450 | self.api_key = get_gemini_api_key() 451 | if self.api_key is not None: 452 | genai.configure(api_key=self.api_key,transport='rest') 453 | 454 | @classmethod 455 | def INPUT_TYPES(cls): 456 | return { 457 | "required": { 458 | "prompt": ("STRING", {"default": "What is the meaning of life?", "multiline": True}), 459 | "system_instruction": ("STRING", {"default": "You are creating a prompt for Stable Diffusion to generate an image. First step: describe this image, then put description into text. Second step: generate a text prompt for %s based on first step. Only respond with the prompt itself, but embellish it as needed but keep it under 80 tokens.", "multiline": True}), 460 | "model_name": (["gemini-1.5-pro-latest"],), 461 | "stream": ("BOOLEAN", {"default": False}), 462 | }, 463 | "optional": { 464 | "image": ("IMAGE",), 465 | } 466 | } 467 | 468 | RETURN_TYPES = ("STRING",) 469 | RETURN_NAMES = ("text",) 470 | FUNCTION = "generate_content" 471 | 472 | CATEGORY = "Zho模块组/✨Gemini" 473 | 474 | def tensor_to_image(self, tensor): 475 | # 确保张量是在CPU上 476 | tensor = tensor.cpu() 477 | 478 | # 将张量数据转换为0-255范围并转换为整数 479 | # 这里假设张量已经是H x W x C格式 480 | image_np = tensor.squeeze().mul(255).clamp(0, 255).byte().numpy() 481 | 482 | # 创建PIL图像 483 | image = Image.fromarray(image_np, mode='RGB') 484 | return image 485 | 486 | def generate_content(self, prompt, system_instruction, model_name, stream, image=None): 487 | if not self.api_key: 488 | raise ValueError("API key is required") 489 | 490 | model = genai.GenerativeModel(model_name, system_instruction=system_instruction) 491 | 492 | if image == None: 493 | if stream: 494 | response = model.generate_content(prompt, stream=True) 495 | textoutput = "\n".join([chunk.text for chunk in response]) 496 | else: 497 | response = model.generate_content(prompt) 498 | textoutput = response.text 499 | else: 500 | # 转换图像 501 | pil_image = self.tensor_to_image(image) 502 | 503 | # 直接使用PIL图像 504 | if stream: 505 | response = model.generate_content([prompt, pil_image], stream=True) 506 | textoutput = "\n".join([chunk.text for chunk in response]) 507 | else: 508 | response = model.generate_content([prompt, pil_image]) 509 | textoutput = response.text 510 | 511 | return (textoutput,) 512 | 513 | 514 | class Gemini_15P_API_S_Chat_Advance_Zho: 515 | 516 | def __init__(self): 517 | self.api_key = get_gemini_api_key() 518 | self.chat = None # 初始化时,聊天实例为空 519 | if self.api_key is not None: 520 | genai.configure(api_key=self.api_key,transport='rest') 521 | 522 | @classmethod 523 | def INPUT_TYPES(cls): 524 | return { 525 | "required": { 526 | "prompt": ("STRING", {"default": "What is the meaning of life?", "multiline": True}), 527 | "system_instruction": ("STRING", {"default": "You are creating a prompt for Stable Diffusion to generate an image. First step: describe this image, then put description into text. Second step: generate a text prompt for %s based on first step. Only respond with the prompt itself, but embellish it as needed but keep it under 80 tokens.", "multiline": True}), 528 | "model_name": (["gemini-1.5-pro-latest"],), 529 | }, 530 | "optional": { 531 | "image": ("IMAGE",), 532 | } 533 | } 534 | 535 | RETURN_TYPES = ("STRING",) 536 | RETURN_NAMES = ("response",) 537 | FUNCTION = "generate_chat" 538 | 539 | CATEGORY = "Zho模块组/✨Gemini" 540 | 541 | def tensor_to_image(self, tensor): 542 | # 确保张量是在CPU上 543 | tensor = tensor.cpu() 544 | 545 | # 将张量数据转换为0-255范围并转换为整数 546 | # 这里假设张量已经是H x W x C格式 547 | image_np = tensor.squeeze().mul(255).clamp(0, 255).byte().numpy() 548 | 549 | # 创建PIL图像 550 | image = Image.fromarray(image_np, mode='RGB') 551 | return image 552 | 553 | def generate_chat(self, prompt, system_instruction, model_name, image=None): 554 | if not self.api_key: 555 | raise ValueError("API key is required") 556 | 557 | if not self.chat: 558 | model = genai.GenerativeModel(model_name, system_instruction=system_instruction) 559 | self.chat = model.start_chat(history=[]) 560 | 561 | if model_name == 'gemini-1.5-pro-latest': 562 | if image == None: 563 | response = self.chat.send_message(prompt) 564 | textoutput = response.text 565 | chat_history = self.format_chat_history(self.chat) 566 | else: 567 | # 转换图像 568 | pil_image = self.tensor_to_image(image) 569 | 570 | response = self.chat.send_message([prompt, pil_image]) 571 | textoutput = response.text 572 | chat_history = self.format_chat_history(self.chat) 573 | 574 | return (chat_history,) 575 | 576 | def format_chat_history(self, chat): 577 | formatted_history = [] 578 | for message in chat.history: 579 | formatted_message = f"{message.role}: {message.parts[0].text}" 580 | formatted_history.append(formatted_message) 581 | formatted_history.append("-" * 40) # 添加分隔线 582 | return "\n".join(formatted_history) 583 | 584 | 585 | # File API 586 | class Gemini_FileUpload_API_S_Zho: 587 | 588 | def __init__(self): 589 | self.api_key = get_gemini_api_key() 590 | if self.api_key is not None: 591 | genai.configure(api_key=self.api_key,transport='rest') 592 | 593 | @classmethod 594 | def INPUT_TYPES(cls): 595 | return { 596 | "required": { 597 | "file": ("STRING", {"default": "./sample.mp3", "multiline": False}), 598 | } 599 | } 600 | 601 | RETURN_TYPES = ("FILE",) 602 | RETURN_NAMES = ("file",) 603 | FUNCTION = "file_upload" 604 | 605 | CATEGORY = "Zho模块组/✨Gemini" 606 | 607 | def file_upload(self, file): 608 | if not self.api_key: 609 | raise ValueError("API key is required") 610 | 611 | your_file = genai.upload_file(file) 612 | 613 | return [your_file] 614 | 615 | 616 | class Gemini_File_API_S_Zho: 617 | 618 | def __init__(self): 619 | self.api_key = get_gemini_api_key() 620 | if self.api_key is not None: 621 | genai.configure(api_key=self.api_key,transport='rest') 622 | 623 | @classmethod 624 | def INPUT_TYPES(cls): 625 | return { 626 | "required": { 627 | "file": ("FILE",), 628 | "prompt": ("STRING", {"default": "Listen carefully to the following audio file. Provide a brief summary.", "multiline": True}), 629 | "model_name": (["gemini-1.5-pro-latest"],), 630 | "stream": ("BOOLEAN", {"default": False}), 631 | } 632 | } 633 | 634 | RETURN_TYPES = ("STRING",) 635 | RETURN_NAMES = ("text",) 636 | FUNCTION = "generate_content" 637 | 638 | CATEGORY = "Zho模块组/✨Gemini" 639 | 640 | def generate_content(self, prompt, model_name, stream, file): 641 | if not self.api_key: 642 | raise ValueError("API key is required") 643 | 644 | model = genai.GenerativeModel(model_name) 645 | 646 | if stream: 647 | response = model.generate_content([prompt, file], stream=True) 648 | textoutput = "\n".join([chunk.text for chunk in response]) 649 | else: 650 | response = model.generate_content([prompt, file]) 651 | textoutput = response.text 652 | 653 | return (textoutput,) 654 | 655 | 656 | class ConcatText_Zho: 657 | 658 | def __init__(self): 659 | pass 660 | 661 | @classmethod 662 | def INPUT_TYPES(cls): 663 | return { 664 | "required": { 665 | "text_1": ("STRING", {"multiline": True}), 666 | "text_2": ("STRING", {"multiline": True}), 667 | # 可以根据需要添加更多的文本输入 668 | }, 669 | } 670 | 671 | RETURN_TYPES = ("STRING",) 672 | RETURN_NAMES = ("text",) 673 | 674 | FUNCTION = "concat_texts" 675 | 676 | CATEGORY = "Zho模块组/✨Gemini" 677 | 678 | def concat_texts(self, **kwargs): 679 | # 将所有输入的文本合并为一个以逗号分隔的字符串 680 | texts = [kwargs[key] for key in kwargs if key.startswith('text')] 681 | combined_text = ', '.join(texts) 682 | return (combined_text,) 683 | 684 | 685 | # DisplayText node is forked from AlekPet,thanks to AlekPet! 686 | class DisplayText_Zho: 687 | def __init__(self): 688 | pass 689 | 690 | @classmethod 691 | def INPUT_TYPES(s): 692 | 693 | return { 694 | "required": { 695 | "text": ("STRING", {"forceInput": True}), 696 | }, 697 | "hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"}, 698 | } 699 | 700 | RETURN_TYPES = ("STRING",) 701 | RETURN_NAMES = ("text",) 702 | OUTPUT_NODE = True 703 | FUNCTION = "display_text" 704 | 705 | CATEGORY = "Zho模块组/✨Gemini" 706 | 707 | def display_text(self, text, prompt=None, extra_pnginfo=None): 708 | return {"ui": {"string": [text,]}, "result": (text,)} 709 | 710 | 711 | NODE_CLASS_MAPPINGS = { 712 | "Gemini_API_Zho": Gemini_API_Zho, 713 | "Gemini_API_Vsion_ImgURL_Zho": Gemini_API_Vsion_ImgURL_Zho, 714 | "Gemini_API_Chat_Zho": Gemini_API_Chat_Zho, 715 | "Gemini_API_S_Zho": Gemini_API_S_Zho, 716 | "Gemini_API_S_Vsion_ImgURL_Zho": Gemini_API_S_Vsion_ImgURL_Zho, 717 | "Gemini_API_S_Chat_Zho": Gemini_API_S_Chat_Zho, 718 | "Gemini_15P_API_S_Advance_Zho": Gemini_15P_API_S_Advance_Zho, 719 | "Gemini_15P_API_S_Chat_Advance_Zho": Gemini_15P_API_S_Chat_Advance_Zho, 720 | "Gemini_FileUpload_API_S_Zho": Gemini_FileUpload_API_S_Zho, 721 | "Gemini_File_API_S_Zho": Gemini_File_API_S_Zho, 722 | "ConcatText_Zho": ConcatText_Zho, 723 | "DisplayText_Zho": DisplayText_Zho 724 | } 725 | 726 | NODE_DISPLAY_NAME_MAPPINGS = { 727 | "Gemini_API_Zho": "✨Gemini_API_Zho", 728 | "Gemini_API_Vsion_ImgURL_Zho": "✨Gemini_API_Vsion_ImgURL_Zho", 729 | "Gemini_API_Chat_Zho": "✨Gemini_API_Chat_Zho", 730 | "Gemini_API_S_Zho": "㊙️Gemini_Zho", 731 | "Gemini_API_S_Vsion_ImgURL_Zho": "㊙️Gemini_ImgURL_Zho", 732 | "Gemini_API_S_Chat_Zho": "㊙️Gemini_Chat_Zho", 733 | "Gemini_15P_API_S_Advance_Zho": "🆕Gemini_15P_Advance_Zho", 734 | "Gemini_15P_API_S_Chat_Advance_Zho": "🆕Gemini_15P_Chat_Advance_Zho", 735 | "Gemini_FileUpload_API_S_Zho": "📄Gemini_FileUpload_Zho", 736 | "Gemini_File_API_S_Zho": "📄Gemini_File_Zho", 737 | "ConcatText_Zho": "✨ConcatText_Zho", 738 | "DisplayText_Zho": "✨DisplayText_Zho" 739 | } 740 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------