Skip to content

Commit

Permalink
fixbug
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowcz007 committed Aug 2, 2024
1 parent edd0303 commit 76a9da7
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 68 deletions.
77 changes: 39 additions & 38 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
print('#fix sys.stdout.isatty')
sys.stdout.isatty = lambda: False

llama_port=None
llama_model=""
llama_chat_format=""
_URL_=None


# try:
# from .nodes.ChatGPT import get_llama_models,get_llama_model_path,llama_cpp_client
Expand Down Expand Up @@ -320,22 +319,22 @@ def get_my_workflow_for_app(filename="my_workflow_app.json",category="",is_all=F

# 这个代码不需要
# if len(apps)==1 and category!='' and category!=None:
data=read_workflow_json_files(category_path)
data=read_workflow_json_files(category_path)

for item in data:
x=item["data"]
# print(apps[0]['filename'] ,item["filename"])
if apps[0]['filename']!=item["filename"]:
category=''
input=None
output=None
if 'category' in x['app']:
category=x['app']['category']
if 'input' in x['app']:
input=x['app']['input']
if 'output' in x['app']:
output=x['app']['output']
apps.append({
for item in data:
x=item["data"]
# print(apps[0]['filename'] ,item["filename"])
if apps[0]['filename']!=item["filename"]:
category=''
input=None
output=None
if 'category' in x['app']:
category=x['app']['category']
if 'input' in x['app']:
input=x['app']['input']
if 'output' in x['app']:
output=x['app']['output']
apps.append({
"filename":item["filename"],
# "category":category,
"data":{
Expand Down Expand Up @@ -455,6 +454,7 @@ async def check_port_available(address, port):

# https
async def new_start(self, address, port, verbose=True, call_on_start=None):
global _URL_
try:
runner = web.AppRunner(self.app, access_log=None)
await runner.setup()
Expand Down Expand Up @@ -534,7 +534,8 @@ async def new_start(self, address, port, verbose=True, call_on_start=None):
# print("\033[93mStarting server\n")
logging.info("\033[93mTo see the GUI go to: http://{}:{} or http://{}:{}".format(ip_address, http_port,address,http_port))
logging.info("\033[93mTo see the GUI go to: https://{}:{} or https://{}:{}\033[0m".format(ip_address, https_port,address,https_port))


_URL_="http://{}:{}".format(address,http_port)
# print("\033[93mTo see the GUI go to: http://{}:{}".format(address, http_port))
# print("\033[93mTo see the GUI go to: https://{}:{}\033[0m".format(address, https_port))

Expand Down Expand Up @@ -754,15 +755,16 @@ def random_seed(seed, data):

for id, value in data.items():
# print(seed,id)
if 'seed' in value['inputs'] and not isinstance(value['inputs']['seed'], list) and seed[id] in ['increment', 'decrement', 'randomize']:
value['inputs']['seed'] = round(random.random() * max_seed)

if 'noise_seed' in value['inputs'] and not isinstance(value['inputs']['noise_seed'], list) and seed[id] in ['increment', 'decrement', 'randomize']:
value['inputs']['noise_seed'] = round(random.random() * max_seed)

if value.get('class_type') == "Seed_" and seed[id] in ['increment', 'decrement', 'randomize']:
value['inputs']['seed'] = round(random.random() * max_seed)

if id in seed:
if 'seed' in value['inputs'] and not isinstance(value['inputs']['seed'], list) and seed[id] in ['increment', 'decrement', 'randomize']:
value['inputs']['seed'] = round(random.random() * max_seed)

if 'noise_seed' in value['inputs'] and not isinstance(value['inputs']['noise_seed'], list) and seed[id] in ['increment', 'decrement', 'randomize']:
value['inputs']['noise_seed'] = round(random.random() * max_seed)

if value.get('class_type') == "Seed_" and seed[id] in ['increment', 'decrement', 'randomize']:
value['inputs']['seed'] = round(random.random() * max_seed)

print('new Seed', value)

return data
Expand Down Expand Up @@ -992,7 +994,10 @@ def re_start(request):
pass
return os.execv(sys.executable, [sys.executable] + sys.argv)


# 状态
@routes.get('/mixlab/status')
def mix_status(request):
return web.Response(text="running#"+_URL_)

# 导入节点
from .nodes.PromptNode import GLIGENTextBoxApply_Advanced,EmbeddingPrompt,RandomPrompt,PromptSlide,PromptSimplification,PromptImage,JoinWithDelimiter
Expand All @@ -1001,7 +1006,7 @@ def re_start(request):
from .nodes.ScreenShareNode import ScreenShareNode,FloatingVideo

from .nodes.Audio import AudioPlayNode,SpeechRecognition,SpeechSynthesis
from .nodes.Utils import IncrementingListNode,ListSplit,CreateLoraNames,CreateSampler_names,CreateCkptNames,CreateSeedNode,TESTNODE_,TESTNODE_TOKEN,AppInfo,IntNumber,FloatSlider,TextInput,ColorInput,FontInput,TextToNumber,DynamicDelayProcessor,LimitNumber,SwitchByIndex,MultiplicationNode
from .nodes.Utils import KeyInput,IncrementingListNode,ListSplit,CreateLoraNames,CreateSampler_names,CreateCkptNames,CreateSeedNode,TESTNODE_,TESTNODE_TOKEN,AppInfo,IntNumber,FloatSlider,TextInput,ColorInput,FontInput,TextToNumber,DynamicDelayProcessor,LimitNumber,SwitchByIndex,MultiplicationNode
from .nodes.Mask import PreviewMask_,MaskListReplace,MaskListMerge,OutlineMask,FeatheredMask

from .nodes.Style import ApplyVisualStylePrompting,StyleAlignedReferenceSampler,StyleAlignedBatchAlign,StyleAlignedSampleReferenceLatents
Expand Down Expand Up @@ -1061,6 +1066,7 @@ def re_start(request):

"SpeechRecognition":SpeechRecognition,
"SpeechSynthesis":SpeechSynthesis,
"KeyInput":KeyInput,
"Color":ColorInput,
"FloatSlider":FloatSlider,
"IntNumber":IntNumber,
Expand Down Expand Up @@ -1153,7 +1159,6 @@ def re_start(request):
# web ui的节点功能
WEB_DIRECTORY = "./web"


logging.info('--------------')
logging.info('\033[91m ### Mixlab Nodes: \033[93mLoaded')
# print('\033[91m ### Mixlab Nodes: \033[93mLoaded')
Expand All @@ -1162,7 +1167,7 @@ def re_start(request):
from .nodes.ChatGPT import ChatGPTNode,ShowTextForGPT,CharacterInText,TextSplitByDelimiter,SiliconflowFreeNode
logging.info('ChatGPT.available True')

NODE_CLASS_MAPPINGS_V = {
NODE_CLASS_MAPPINGS_V = {
"ChatGPTOpenAI":ChatGPTNode,
"SiliconflowLLM":SiliconflowFreeNode,
"ShowTextForGPT":ShowTextForGPT,
Expand All @@ -1171,7 +1176,7 @@ def re_start(request):
}

# 一个包含节点友好/可读的标题的字典
NODE_DISPLAY_NAME_MAPPINGS_V = {
NODE_DISPLAY_NAME_MAPPINGS_V = {
"ChatGPTOpenAI":"ChatGPT & Local LLM ♾️Mixlab",
"SiliconflowLLM":"LLM Siliconflow ♾️Mixlab",
"ShowTextForGPT":"Show Text ♾️MixlabApp",
Expand Down Expand Up @@ -1268,7 +1273,7 @@ def re_start(request):
try:
from .nodes.TripoSR import LoadTripoSRModel,TripoSRSampler,SaveTripoSRMesh
logging.info('TripoSR.available')

# logging.info( folder_paths.get_temp_directory())
NODE_CLASS_MAPPINGS['LoadTripoSRModel_']=LoadTripoSRModel
NODE_DISPLAY_NAME_MAPPINGS["LoadTripoSRModel_"]= "Load TripoSR Model"

Expand All @@ -1283,8 +1288,4 @@ def re_start(request):
logging.info('TripoSR.available False' )






logging.info('\033[93m -------------- \033[0m')
22 changes: 22 additions & 0 deletions nodes/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,28 @@ def run(self,color):
return (h,r,g,b,a,)


class KeyInput:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"key":("KEY",),
},
}

RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("key",)

FUNCTION = "run"

CATEGORY = "♾️Mixlab/Input"

INPUT_IS_LIST = False
OUTPUT_IS_LIST = (False,)

def run(self,key):
return (key,)



class FontInput:
@classmethod
Expand Down
18 changes: 14 additions & 4 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1740,15 +1740,15 @@
if (data.class_type === 'CheckpointLoaderSimple') {
if (window._appData.data) window._appData.data[data.id].inputs.ckpt_name = selectDom.value;
//更新输入参数
updateInputData(nodeId, (inputs) => {
updateInputData(data.id, (inputs) => {
inputs.ckpt_name = selectDom.value;
return inputs
})
}
if (data.class_type === 'LoraLoader') {
if (window._appData.data) window._appData.data[data.id].inputs.lora_name = selectDom.value;
//更新输入参数
updateInputData(nodeId, (inputs) => {
updateInputData(data.id, (inputs) => {
inputs.lora_name = selectDom.value;
return inputs
})
Expand Down Expand Up @@ -2870,7 +2870,12 @@
window._appData.category,
window._appData.seed,
inp,
api.clientId
api.clientId,
window._appData.data ? [{
data: {
output: window._appData.data
}
}] : null
).then(res => {

if (!res) {
Expand Down Expand Up @@ -2900,7 +2905,12 @@
window._appData.category,
window._appData.seed,
window._appData.input.filter(inp => inp),
api.clientId
api.clientId,
window._appData.data ? [{
data: {
output: window._appData.data
}
}] : null
).then(res => {

if (!res) {
Expand Down
3 changes: 2 additions & 1 deletion web/javascript/app_mixlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { $el } from '../../../scripts/ui.js'
import { api } from '../../../scripts/api.js'

import { td_bg } from './td_background.js'
console.log('td_bg', td_bg)
// console.log('td_bg', td_bg)

//本机安装的插件节点全集
window._nodesAll = null

Expand Down
11 changes: 10 additions & 1 deletion web/javascript/command.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
function get_url () {
// 如果有缓存记录
let hostUrl = localStorage.getItem('_hostUrl') || ''
if (hostUrl) {
return hostUrl
}
let api_host = `${window.location.hostname}:${window.location.port}`
let api_base = ''
let url = `${window.location.protocol}//${api_host}${api_base}`
Expand Down Expand Up @@ -143,8 +148,12 @@ function queuePromptNew (filename, category, seed, input, client_id) {

// 随机seed
// promptWorkflow = randomSeed(seed, promptWorkflow);
let d = { filename, category, seed, input, client_id }
if (apps) {
d.apps = apps
}

const data = JSON.stringify({ filename, category, seed, input, client_id })
const data = JSON.stringify(d)
return new Promise((res, rej) => {
fetch(`${url}/mixlab/prompt`, {
method: 'POST',
Expand Down
Loading

0 comments on commit 76a9da7

Please sign in to comment.