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 JSON 다운로드API 문서 ↗
# 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)