Built-in Data Type Conversion Example
Demonstrate how to convert between various built-in data types within a workflow. Input any data value and output its converted form.
下載工作流程在 Cloud 中試用 API 文件
關於
Demonstrate how to convert between various built-in data types within a workflow. Input any data value and output its converted form.
您提供的內容
- 正在讀取工作流程
在 ComfyUI 中執行。 此工作流程無法在此頁面上執行。請下載並在 ComfyUI 中開啟。
下載工作流程此工作流程尚無範例輸出。
工作流程內部
節點圖的唯讀預覽。請在 Comfy Cloud 中開啟,或下載後編輯節點。
Loading the graph
Open full-size workflow preview- Comfy Cloud
- 是
- 作者
- 作者無法使用
需要自訂節點
- 正在讀取工作流程
從程式碼使用此工作流程
可行時會根據工作流程圖和輸入內容產生;否則會顯示儲存的範例。執行可能產生費用的程式碼前,請檢查認證資訊和端點。
1 取得 API 金鑰 ↗
What you need
- Runs on
- Comfy Cloud
- 金鑰
- COMFY_API_KEY
需要付費 Cloud 方案與點數。
下載 API JSONAPI 文件 ↗
# Python 3.10+: pip install comfy-sdk==0.4.0
import os
from comfy_sdk import Comfy
api_key = os.environ.get("COMFY_API_KEY", "").strip()
if not api_key: raise RuntimeError("Set COMFY_API_KEY")
os.environ.setdefault("COMFY_BASE_URL", "https://cloud.comfy.org")
client = Comfy(api_key=api_key)
workflow = client.workflows.from_json({
"2": {
"class_type": "PrimitiveStringMultiline",
"inputs": {
"value": "1"
},
"_meta": {
"title": "Text (Multiline)"
}
},
"3": {
"class_type": "ComfyNumberConvert",
"inputs": {
"value": [
"2",
0
]
},
"_meta": {
"title": "Convert Number"
}
},
"5": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"3",
0
]
},
"_meta": {
"title": "Preview as Text (Float)"
}
},
"6": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"3",
1
]
},
"_meta": {
"title": "Preview as Text (Int)"
}
},
"8": {
"class_type": "PrimitiveInt",
"inputs": {
"value": 0
},
"_meta": {
"title": "Int"
}
},
"9": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"8",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"10": {
"class_type": "PrimitiveFloat",
"inputs": {
"value": 1.5
},
"_meta": {
"title": "Float"
}
},
"11": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"10",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"12": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"9",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"13": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"11",
0
]
},
"_meta": {
"title": "Preview as Text (String)"
}
},
"14": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a",
"values.a": [
"8",
0
]
},
"_meta": {
"title": "Math Expression"
}
},
"15": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"14",
2
]
},
"_meta": {
"title": "Preview as Text"
}
},
"16": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"14",
0
]
},
"_meta": {
"title": "Preview as Text"
}
},
"17": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"14",
1
]
},
"_meta": {
"title": "Preview as Text"
}
},
"18": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a",
"values.a": [
"10",
0
]
},
"_meta": {
"title": "Math Expression"
}
},
"20": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"18",
0
]
},
"_meta": {
"title": "Preview as Text (Float)"
}
},
"21": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"18",
1
]
},
"_meta": {
"title": "Preview as Text (Int)"
}
},
"22": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"18",
2
]
},
"_meta": {
"title": "Preview as Text (Boolean)"
}
},
"23": {
"class_type": "ComfyMathExpression",
"inputs": {
"expression": "a",
"values.a": [
"3",
1
]
},
"_meta": {
"title": "Math Expression"
}
},
"24": {
"class_type": "PreviewAny",
"inputs": {
"source": [
"23",
2
]
},
"_meta": {
"title": "Preview as Text (Boolean)"
}
}
})
# run() also passes api_key to the partner nodes in this workflow.
job = client.run(workflow, api_key=api_key)