comfyapi

command module
v0.0.0-...-88c3a73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

README

CFY

cfy is a command-line tool that lets you interact with comfyui servers. It's basically curl for comfyui servers.

Its main function is to template the workflow JSON files of comfyui, separating the parameters for easy modification.

Installation

macOS:

make install

Quick Start

Create your workflow JSON template. For more details, please refer to workflows/ folder.

prompt2image
cfy qp -c 127.0.0.1:8188 -f workflows/prompt2image.json -d '{"positivePrompt":"beautiful scenery nature glass bottle landscape, , purple galaxy bottle,", "negativePrompt":"text, watermark"}' -o output -w
image2image
cfy qp -c 127.0.0.1:8188 -f workflows/image2image.json -d '{"negativePrompt":"nsfw","image":"1.png"}' -o output -i input/1.png -w
hold watch

Open the terminal.

cfy watch -c 127.0.0.1:8188
2024/03/29 16:46:47 Client Id: 45a9251e-e265-4d3a-92b3-dbd702bd0290

Open anothers terminal.

cfy qp -f workflows/prompt2image.json -d '{"positivePrompt":"beautiful scenery nature glass bottle landscape, , purple galaxy bottle,", "negativePrompt":"text, watermark"}' -o output --id [same with watch client id]
code
package main

import (
	"log"
	"math/rand"

	"github.com/347255699/comfyapi/pkg/comfyctl"
)

func main() {
	queuePrompt("workflows/prompt2image.json")
}

func queuePrompt(filePath string) {
	cli := comfyctl.NewWithPlainText("localhost:8188", "")
	log.Printf("Client Id: %s", cli.Id())
	values := map[string]interface{}{
		"positivePrompt": "beautiful scenery nature glass bottle landscape, , purple galaxy bottle,",
		"negativePrompt": "text, watermark",
		"seed":           rand.Intn(999999999999999),
	}

	// block way
	if ret, err := cli.QueuePrompt(filePath, "output", "", values, true); err != nil {
		log.Fatal(err)
		return
	} else {
		log.Printf("Ret: %v", ret)
	}
}

Documentation

Overview

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Directories

Path Synopsis
examples
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL