Skip to content

Commit

Permalink
add her demo
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowcz007 committed Sep 7, 2024
1 parent 5612047 commit 97f12f3
Show file tree
Hide file tree
Showing 7 changed files with 3,775 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ For business cooperation, please contact email 389570357@qq.com

##### `最新`

- [增加 Her 的DEMO页面,和数字人对话](https://github.com/shadowcz007/ComfyUI-Backend-MixlabNodes/blob/main/workflow/her_demo_workflow.json)

- 右键菜单支持 text-to-text,方便对 prompt 词补全,支持云LLM或者是本地LLM。

- 增加 MiniCPM-V 2.6 int4
Expand Down
22 changes: 14 additions & 8 deletions nodes/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ def tensor2pil(image):
return Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))


def create_temp_file(image):
def create_temp_file(image,counter=1):
output_dir = folder_paths.get_temp_directory()

(
full_output_folder,
filename,
counter,
_,
subfolder,
_,
) = folder_paths.get_save_image_path('tmp', output_dir)
Expand Down Expand Up @@ -601,6 +601,7 @@ def INPUT_TYPES(s):
"link":("STRING",{"multiline": False,"default": "https://","dynamicPrompts": False}),
"category":("STRING",{"multiline": False,"default": "","dynamicPrompts": False}),
"auto_save": (["enable","disable"],),
"idle_animation": ("BOOLEAN", {"default": False},),
}

}
Expand All @@ -616,14 +617,19 @@ def INPUT_TYPES(s):
INPUT_IS_LIST = True
# OUTPUT_IS_LIST = (True,)

def run(self,name,input_ids,output_ids,image,description,version,share_prefix,link,category,auto_save):
def run(self,name,input_ids,output_ids,image,description,version,share_prefix,link,category,auto_save,idle_animation):
name=name[0]

idle_animation=idle_animation[0]

im=None
im=[]
if image:
im=image[0][0]
#TODO batch 的方式需要处理
im=create_temp_file(im)
# img=image[0][0]
print('AppInfo_image',len(image))
# batch 的方式需要处理
for i in range(len(image)):
img=image[i]
im.append(create_temp_file(img,i+1)[0])
# image [img,] img[batch,w,h,a] 列表里面是batch,

input_ids=input_ids[0]
Expand All @@ -636,7 +642,7 @@ def run(self,name,input_ids,output_ids,image,description,version,share_prefix,li

# id=get_json_hash([name,im,input_ids,output_ids,description,version])

return {"ui": {"json": [name,im,input_ids,output_ids,description,version,share_prefix,link,category]}, "result": ()}
return {"ui": {"json": [name,im,input_ids,output_ids,description,version,share_prefix,link,category,idle_animation]}, "result": ()}



Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui-mixlab-nodes"
description = "3D, ScreenShareNode & FloatingVideoNode, SpeechRecognition & SpeechSynthesis, GPT, LoadImagesFromLocal, Layers, Other Nodes, ..."
version = "0.40.0"
version = "0.41.0"
license = "MIT"
dependencies = ["numpy", "pyOpenSSL", "watchdog", "opencv-python-headless", "matplotlib", "openai", "simple-lama-inpainting", "clip-interrogator==0.6.0", "transformers>=4.36.0", "lark-parser", "imageio-ffmpeg", "rembg[gpu]", "omegaconf==2.3.0", "Pillow>=9.5.0", "einops==0.7.0", "trimesh>=4.0.5", "huggingface-hub", "scikit-image"]

Expand Down
42 changes: 36 additions & 6 deletions web/javascript/app_mixlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { api } from '../../../scripts/api.js'

import { td_bg } from './td_background.js'
// console.log('td_bg', td_bg)
import { getUrl, base64Df, get_position_style, getObjectInfo } from './common.js'
import {
getUrl,
base64Df,
get_position_style,
getObjectInfo
} from './common.js'

//本机安装的插件节点全集
window._nodesAll = null
Expand Down Expand Up @@ -229,8 +234,6 @@ async function extractInputAndOutputData (
return { input, output, seed, seedTitle }
}



async function save_app (json) {
let url = getUrl()

Expand Down Expand Up @@ -265,18 +268,20 @@ function downloadJsonFile (jsonData, fileName = 'mix_app.json') {
async function save (json, download = false, showInfo = true) {
let nodesAll = window._nodesAll || (await getObjectInfo())

console.log('####SAVE', nodesAll, json[0])
console.log('####SAVE', nodesAll, json)

const name = json[0],
version = json[5],
share_prefix = json[6], //用于分享的功能扩展
link = json[7], //用于创建界面上的跳转链接
category = json[8] || '', //用于分类
idle_animation = json[9], //用于动画,比如数字人her
description = json[4],
inputIds = json[2].split('\n').filter(f => f),
outputIds = json[3].split('\n').filter(f => f)

const iconData = json[1][0]

let { filename, subfolder, type } = iconData
let iconUrl = api.apiURL(
`/view?filename=${encodeURIComponent(
Expand Down Expand Up @@ -329,6 +334,27 @@ async function save (json, download = false, showInfo = true) {
try {
data.app.icon = await drawImageToCanvas(iconUrl)
} catch (error) {}

let images = []
if (json[1].length > 1 && idle_animation) {
images = Array.from(json[1], j => {
let { filename, subfolder, type } = j
return api.apiURL(
`/view?filename=${encodeURIComponent(
filename
)}&type=${type}&subfolder=${subfolder}${app.getPreviewFormatParam()}${app.getRandParam()}`
)
})
}

try {
for (let index = 0; index < images.length; index++) {
const imgurl = images[index]
images[index] = await drawImageToCanvas(imgurl)
}
data.app.idle_animation = images
} catch (error) {}

// console.log(data.app)
// let http_workflow = app.graph.serialize()
await save_app(data)
Expand All @@ -338,13 +364,17 @@ async function save (json, download = false, showInfo = true) {

if (showInfo) {
let open = window.confirm(
`You can now access the standalone application on a new page!\n${getUrl()}/mixlab/app?filename=${encodeURIComponent(
`You can now access the standalone application on a new page!\n${getUrl()}/mixlab/app${
data.app.idle_animation ? '/her.html' : ''
}?filename=${encodeURIComponent(
data.app.filename
)}&category=${encodeURIComponent(data.app.category)}`
)
if (open)
window.open(
`${getUrl()}/mixlab/app?filename=${encodeURIComponent(
`${getUrl()}/mixlab/app${
data.app.idle_animation ? '/her.html' : ''
}?filename=${encodeURIComponent(
data.app.filename
)}&category=${encodeURIComponent(data.app.category)}`
)
Expand Down
2 changes: 1 addition & 1 deletion web/javascript/checkVersion_mixlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { app } from '../../../scripts/app.js'
const repoOwner = 'shadowcz007' // 替换为仓库的所有者
const repoName = 'comfyui-mixlab-nodes' // 替换为仓库的名称

const version = 'v0.40.0'
const version = 'v0.41.0'

fetch(`https://api.github.com/repos/${repoOwner}/${repoName}/releases/latest`)
.then(response => response.json())
Expand Down
Loading

0 comments on commit 97f12f3

Please sign in to comment.