Skip to content

Commit

Permalink
Dev modelhost v2 (#137)
Browse files Browse the repository at this point in the history
* update: test

* update: test

* test

* update: test

* update: test

* test

* update: test

* update: test

* update: test

* update: test

* update: test

* test

* test

* test

* test

* test

* test

* test

* test

* test

* fix

* test

* test

* frontend

* update: test

* init

* update: list-files

* init

* fix

* update: list-files

* update: list-files

* fix

* update: list-files

* fix

* Dev modelhost yaochi (#109)

* remove florence2 caption node (#98)

* fix bug of category name (#100)

* Add ultimate-sd-upscale (#102)

* Add ultimate-sd-upscale

* refine

* refine

* ultimate_sd_upscale

* refine

* remove model that cannot be used in commercial

* Update README.md

* Update README.md

---------

Co-authored-by: Yao Chi <[email protected]>

* add sr deprecated message (#103)

* formatting code (#106)

* formatting code

* refine

* Refactor Bizyair and Code Formatting Improvements (#104)

* Refactor Bizyair and Code Formatting Improvements

* refine

* Delete redundant code

* Delete redundant code

* fix UNIQUE_ID

* refine

* refine

* refine

* skip Super Resolution test

* Add lora test server (#105)

* refine

* Delete src/bizyair/commands/servers/server_base.py

---------

Co-authored-by: Yao Chi <[email protected]>

* reformat

* news to new url

---------

Co-authored-by: FengWen <[email protected]>

* add Single file upload

* fix: add get_api_key

* fix: dependencies check and invalid api_key errno

* fix: dependencies check and invalid api_key errno

* fix: print message

* refine the text content

* reformat

* fix

* refine content

* update: reduce allow types

* update: reduce allow types

* update: reduce allow types

* update: merge requirements_adv.txt to requirements.txt

* fix

* fix

* fix

* fix

* reformat

* update: change all server_address to bizyair-api.siliconflow.cn

* update ci ComfyUI version

* reformat and updage

* fix

* fix

* update: upload limit

* update: upload limit

* update: upload limit

* update: upload limit

* fix

* update: upload limit

* change to wait for bizyair logo

* fix

* update: adjust structure

* fix

* refine the queue btn CI

* use comfy queue btn class

* use js to wait queue finished

* refine

* write ini file and reformat

* fix: oss progressbar

* fix

* update: clear upload cache

* fix

* fix

* fix

* Fix Model Find (#112)

Co-authored-by: Yao Chi <[email protected]>

* remformat

* fix

* fix: model repeat delete

* Dev modelhost async upload file (#113)

* refine

* refine get loop

* chagne to async upload

* fix: path_manager.py

* fix: remove useless dependency

* fix: service_address

* fix

* flux dev fp8 (#107)

* flux dev fp8

* refine

---------

Co-authored-by: Yao Chi <[email protected]>

* fix: service_address

* add docs for lora model host (#115)

* refine

* fix the url route

* update readme

* update: replace to websocket

* update: upload by ws

* update: upload by ws

* temp

* fix

* fix

* fix: upload by ws

* fix: upload by ws

* fix: upload by ws

* fix: upload by ws

* fix

* update: send pong when receive ping

* update: send pong when receive ping

* update: send pong when receive ping

* fix: execution.py

* fix

* update: add valid_user_info

* update: add valid_user_info

* update: send synced status

* update: add valid_user_info

* fix

* fix

* fix

* fix

* fix

* fix: modelhost.py

* update: modelhost.py

* fix

* fix: modelhost.py

* fix

* fix

* adjust the timeout setting and refine the try catch block

* fix

* add docs

---------

Co-authored-by: dantegarden <[email protected]>
Co-authored-by: root <root@vscode-1631487780716577-vscode-master-0.vscode-1631487780716577-vscode.org-1599978210328609.svc.cluster.local>
Co-authored-by: Yao Chi <[email protected]>
Co-authored-by: FengWen <[email protected]>
Co-authored-by: Li Jing <[email protected]>
Co-authored-by: Your Name <[email protected]>
  • Loading branch information
7 people authored Sep 19, 2024
1 parent ff37db1 commit 0014802
Show file tree
Hide file tree
Showing 36 changed files with 1,578 additions and 643 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# BizyAir

- [2024/09/19] 🌩️ BizyAir has updated the model upload feature, allowing the upload process to display a progress bar, and the size of the models uploaded is no longer restricted by ComfyUI. (https://siliconflow.github.io/BizyAir/model-host/introduce.html)
- [2024/09/06] 🌩️ BizyAir supports InstantID for SDXL now. [SDXL InstantID workflow](./examples/bizyair_sdxl_InstantID_basic.json)
- [2024/09/05] 🌩️ BizyAir supports users in running custom LoRA models, including SDXL and Flux LoRA. [How to upload and run custom model](https://siliconflow.github.io/BizyAir/model-host/introduce.html)
- [2024/08/23] 🌩️ BizyAir now support ultimateSDupscale nodes [upscale workflow](./examples/bizyair_ultimate_sd_upscale.json)
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/bznews.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"09/06 发布 v0.2.0,支持试用自定义 LoRA,欢迎升级使用": "https://siliconflow.github.io/BizyAir/model-host/introduce.html"
"09/19 更新模型上传功能,显示上传进度条,上传模型大小不受 ComfyUI 限制": "https://siliconflow.github.io/BizyAir/model-host/introduce.html",
"09/06 发布 v0.2.0,支持使用自定义 LoRA,欢迎升级使用": "https://siliconflow.github.io/BizyAir/model-host/introduce.html"
}
Binary file removed docs/docs/model-host/imgs/model-ready.jpg
Binary file not shown.
Binary file removed docs/docs/model-host/imgs/modelbtn.jpg
Binary file not shown.
Binary file added docs/docs/model-host/imgs/modelsmenu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/docs/model-host/imgs/remotefolders.jpg
Binary file not shown.
Binary file added docs/docs/model-host/imgs/remotefolders.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/docs/model-host/imgs/uploadfiles.jpg
Binary file not shown.
Binary file added docs/docs/model-host/imgs/uploadfiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 16 additions & 7 deletions docs/docs/model-host/introduce.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,29 @@

## 在 ComfyUI 中上传模型

!!! note
ComfyUI 默认传输数据大小为 100MB,建议启动时,将最大值设置大一些,如 `python main.py --max-upload-size 1000` 设置最大上传数据为 1000MB。

点击 BizyAir 的 "Model" 按钮,可以打开模型对话框。
点击 BizyAir 的 "Model" 按钮,有 "Remote Folders" 和 "Upload" 两个菜单选项。

分别对应了已经上传的模型和上传模型功能。

![](./imgs/modelbtn.jpg)
![](./imgs/modelsmenu.png)

在 “Remote Folders” 中可以查看已经上传的模型。

![](./imgs/remotefolders.jpg)
![](./imgs/remotefolders.png)

- 点击 "垃圾桶" 图标可以删除上传的模型
- Status 为 "Avaliable" 的模型,表示已经可以在推理中使用。

在 “Upload” 中可以上传模型。

![](./imgs/uploadfiles.jpg)
![](./imgs/uploadfiles.png)

其中:

- Type 选择类型(当前只支持 “lora”)
- Name 是远程目录的名字,如果与已经上传的远程模型重名,将会覆盖已有的远程模型
- Local Path 是本地需要上传目录的 **绝对路径**。如果你是 Linux/Mac 用户,它看上去应该是 "/yourpath/xxxx",如果你是 Windows 用户,它看上去应该是 "C:\yourpath\xxxx"。

## 使用 SiliconCloud Client 上传模型

Expand Down Expand Up @@ -77,7 +86,7 @@ siliconcloud upload --type "bizyair/lora" --path /localpath/XLabs-AI/flux-lora-

当模型的状态显示为 “Available” 时,表示模型已经可以在 BizyAir 工作流中使用。

![](./imgs/model-ready.jpg)
![](./imgs/remotefolders.png)

!!! note
上传的模型,即使完成后,也需要一定时间才能在 BizyAir 中使用,一般为 20~30 分钟。如果状态不为 “Available”,请稍等片刻。
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/news.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"BizyAir NEWS": {
"09/06 发布 v0.2.0,支持试用自定义 LoRA,欢迎升级使用": "https://siliconflow.github.io/BizyAir/model-host/introduce.html"
"09/19 更新模型上传功能,显示上传进度条,上传模型大小不受 ComfyUI 限制": "https://siliconflow.github.io/BizyAir/model-host/introduce.html",
"09/06 发布 v0.2.0,支持使用自定义 LoRA,欢迎升级使用": "https://siliconflow.github.io/BizyAir/model-host/introduce.html"
}
}
51 changes: 39 additions & 12 deletions js/apis.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,47 @@
import { ConfirmDialog } from './subassembly/confirm.js';
import { dialog } from './subassembly/dialog.js';

const fetchCache = new Map();

function customFetch(url, options = {}) {
const now = Date.now();
if (fetchCache.has(url)) {
const lastFetchTime = fetchCache.get(url);
if (now - lastFetchTime < 1200) {
console.log(`请求过于频繁,忽略请求:${url}`);
dialog({
content: "The request is too frequent.",
type: 'warning',
noText: 'Close',
})
return Promise.resolve(null);
}
}
fetchCache.set(url, now);
return window.fetch(url, options)
.then(response => {
if (response.status == 404) {
new ConfirmDialog({
warning: true,
message: "You may be missing dependencies at the moment. For details, please refer to the ComfyUI logs."
dialog({
content: "You may be missing dependencies at the moment. For details, please refer to the ComfyUI logs.",
type: 'error'
})
}
return response.json();
})
.then(data => {
const { code, message } = data;
if (code !== 20000) {
const warning = new ConfirmDialog({
warning: true,
message
})
warning.listen(e => {
console.log(e)
if (e.behavior === 'close') {
dialog({
type: 'warning',
content: message,
noText: 'Close',
onNo: () => {
if (code === 401000) {
document.querySelector('.menus-item-key').click()
}
}
})
return

return;
}
return data;
})
Expand All @@ -36,6 +51,7 @@ function customFetch(url, options = {}) {
});
}


export function check_model_exists ( type, name ) {
return customFetch(`/bizyair/modelhost/check_model_exists`, {
method: 'POST',
Expand Down Expand Up @@ -75,6 +91,17 @@ export function model_types () {
return customFetch(`/bizyair/modelhost/model_types`, {method: 'GET'})
}

export function check_folder (url) {
return customFetch(`/bizyair/modelhost/check_folder?absolute_path=${encodeURIComponent(url)}`, {method: 'GET'})
}

export function submit_upload (data) {
return customFetch(`/bizyair/modelhost/submit_upload?clientId=${sessionStorage.getItem('clientId')}`, {
method: 'POST',
body: JSON.stringify(data)
})
}

export function delModels ( data ) {
return customFetch(`/bizyair/modelhost/models`, {
method: 'DELETE',
Expand Down
129 changes: 46 additions & 83 deletions js/dialog/apiKey.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,16 @@
import { $el, ComfyDialog } from "../../../scripts/ui.js";
import { ConfirmDialog } from "../subassembly/confirm.js";

export class ApiKey extends ComfyDialog {
constructor() {
super();

const close_button = $el("button.comfy-bizyair-close", {
type: "button",
textContent: "Close",
onclick: () => this.remove()
});
const submit_button = $el("button.comfy-bizyair-submit", {
type: "button",
textContent: "Submit",
onclick: () => this.toSubmit()
});
const content =
$el("div.comfy-modal-content",
[
$el("p", {}, [
$el("font", { size: 6, color: "white" }, [`Set API Key`]),]
),
$el("br", {}, []),
$el("br", {}, []),
$el('input.cm-input-item', {
id: 'bizyair-api-key',
type: 'password',
placeholder: 'API Key',
onchange: function() {
this.className = 'cm-input-item'
}
}),
$el('p.confirm-word', {}, ['Please visit', $el('a.bizyair-link', { href: 'https://cloud.siliconflow.cn', target: '_blank' }, ['https://cloud.siliconflow.cn']), " to get your key."]),
$el('p.confirm-word', {}, [
"Setting the API Key signifies agreement to the",
$el('a.bizyair-link', {
href: 'https://docs.siliconflow.cn/docs/user-agreement',
target: '_blank'
}, ['User Agreement']),
" and",
$el('a.bizyair-link', {
href: 'https://docs.siliconflow.cn/docs/privacy-policy',
target: '_blank'
}, ['Privacy Policy.']),
]),
$el('div.cm-bottom-footer', {}, [submit_button, close_button]),
]
);
this.element = $el('div.bizyair-modal', {
parent: document.body
}, [
$el("div.comfy-modal.bizyair-dialog.bizyair-dialog-sml", {
id: 'bizyair-api-key-dialog',
parent: document.body,
style: { display: 'block' }
}, [content])
])
document.addEventListener('keydown', (e) => this.keyDown(e));
}
async toSubmit() {
import { dialog } from '../subassembly/dialog.js';
import { $el } from "../../../scripts/ui.js";
export function apiKey() {
async function toSubmit() {
const apiKey = document.querySelector('#bizyair-api-key');
console.log(apiKey.value)
if (!apiKey.value) {
new ConfirmDialog({
title: "",
warning: true,
message: "Please input API Key",
})
dialog({
content: "Please input API Key",
noText: 'Close',
type: 'error',
});
apiKey.className = `${apiKey.className} cm-input-item-error`
return
return false

}
const response = await fetch('/bizyair/set_api_key', {
Expand All @@ -80,13 +22,13 @@ export class ApiKey extends ComfyDialog {
});
if (response.ok) {
alert('API Key set successfully!');
this.setCookie('api_key', apiKey.value, 30);
this.close();
setCookie('api_key', apiKey.value, 30);
} else {
alert('Failed to set API Key: ' + await response.text());
}
return response
}
setCookie(name, value, days) {
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
Expand All @@ -95,16 +37,37 @@ export class ApiKey extends ComfyDialog {
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
keyDown(e) {
if (e.key === 'Escape') {
this.remove();
}
}
remove() {
this.element.remove();
document.removeEventListener('keydown', (e) => this.keyDown(e));
}
showDialog() {
this.element.style.display = "block";
}
const content =
$el("div.comfy-modal-content-sml",
[
$el('input.cm-input-item', {
id: 'bizyair-api-key',
type: 'password',
placeholder: 'API Key',
onchange: function() {
this.className = 'cm-input-item'
}
}),
$el('p.confirm-word', {}, ['Please visit', $el('a.bizyair-link', { href: 'https://cloud.siliconflow.cn', target: '_blank' }, ['https://cloud.siliconflow.cn']), " to get your key."]),
$el('p.confirm-word', {}, [
"Setting the API Key signifies agreement to the",
$el('a.bizyair-link', {
href: 'https://docs.siliconflow.cn/docs/user-agreement',
target: '_blank'
}, ['User Agreement']),
" and",
$el('a.bizyair-link', {
href: 'https://docs.siliconflow.cn/docs/privacy-policy',
target: '_blank'
}, ['Privacy Policy.']),
])
]
);
dialog({
title: 'Set API Key',
content: content,
yesText: 'Submit',
noText: 'Close',
onYes: toSubmit
});
}
Loading

0 comments on commit 0014802

Please sign in to comment.