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.
À propos
Demonstrate how to convert between various built-in data types within a workflow. Input any data value and output its converted form.
Ce que vous fournissez
- Lecture du workflow
S’exécute dans ComfyUI. Ce workflow ne peut pas s’exécuter sur cette page. Téléchargez-le et ouvrez-le dans ComfyUI.
Télécharger le workflowPas encore d’exemples de résultats pour ce workflow.
Dans le workflow
Un aperçu en lecture seule du graphe de nœuds. Ouvrez-le dans Comfy Cloud ou téléchargez-le pour modifier les nœuds.
Loading the graph
Open full-size workflow preview- Comfy Cloud
- Oui
- Auteur
- Auteur indisponible
Nécessite des nœuds personnalisés
- Lecture du workflow
Utiliser ce workflow depuis du code
Généré à partir du graphe et des entrées du workflow lorsque cela est possible ; sinon, les exemples enregistrés sont affichés. Vérifiez les identifiants et les points de terminaison avant d’exécuter le code, ce qui peut entraîner des frais.
What you need
- Runs on
- Comfy Cloud
- Clé
- COMFY_API_KEY
Nécessite un forfait Cloud payant et des crédits.
# 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)