-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[help] used in multiple tabs and support for mark imags by programmatically | 能否在多个选项卡里同时使用,以及标记功能的支持 #322
Comments
The following are my ideas, and I believe they are all achievable, at least that's the case for me. Start the backend server and configure it to use "foo" as the base. AppUtils(base = "foo").wrap_app(app) Add a container for IIB + gr.HTML("error", elem_id="bar_iib_container")
- gr.HTML("error", elem_id="infinite_image_browsing_container_wrapper") Load index.js on the browser side. const jscodeResp = await fetch("/file?path=/path/to/your/submodue-iib/index.js") // fake api
const jscode = await jscodeResp.text()
eval(jscode.replace("__root_conatiner__", "#bar_iib_container").replace("__base__", "foo")) If you want to mark an image, you can achieve it by using postmessage, and the same goes for other operations. const iib = gradioApp().querySelector('#bar_iib_container iframe').contentWindow
iib.postMessage({
type: 'mark-images',
data: [ { path: 'path1', tags: ['tag1', 'tag2'] } , { path: 'path2', tags: ['tag3', 'tag4'] } ]
}) |
Thank you for your answer, I will try it out. I noticed that Sean Wang implemented something similar, maybe something for css is required, but I will find out. |
By the way, it should be noted that these are just some feasible solutions, but I haven't implemented them on IIB yet. It may take a few days as I am currently quite busy. |
I made a fork of your repository, maybe I can figure it out. |
Okay, if you complete it successfully, you can consider submitting a PR to merge it into my repository. |
My question is, if the user has already installed the script_callbacks.on_app_started(
AppUtils().wrap_app
) If need, will there be no conflicts ? |
Both methods are feasible. I don't think there will be conflicts even if it is installed as a submodule. The advantage of using iib as a submodule is that the version can be fixed. In addition, with the variables "base" and "root_container" isolation can be achieved to a large extent. |
If we want to reuse the installed iib extension, can we do something like these: I noticed that My extension performs clustering and duplication detection by folder (my extension does not support recursive processing of subfolders), and every time the clustering or duplication detection results come out, I send a jump request to At the same time, I send the clustering or duplication detection labels of each image in the folder to 如果要复用已经安装的iib扩展,是否能这样: Or can we have a temporary workspace for users to process, like the update on 2023-7-22, where I will send the file paths and their labels of the images being processed to 或者我们是否能像2023-7-22的更新那样,有一个临时工作区提供给用户进行处理,我会向iib的临时工作区发送所处理的文件路径以及他们的标签,就像发送给gr.Gallery那样 This is the gallery that I have implemented in my extension. |
不然直接把那些函数暴露给好了 AppUtils(base = "foo", export_frontend = True ).wrap_app(app) const iib = gradioApp().querySelector('#bar_iib_container iframe').contentWindow;
iib.insertTabPane({
tabIdx: 0,
paneIdx: 0,
pane: {
type: 'gridView',
files: [{
size: '',
type: 'file',
created_time: '',
name: 'xxxxx.png',
date: '',
bytes: 0,
fullpath: '/path/to/xxx.png',
tags: [{text: 'foo'}, {text: 'bar'}]
}]
}
});
iib.insertTabPane({
tabIdx: 0,
paneIdx: 0,
pane: {
type: 'local',
path: '/path/to/your/target/directory'
}
}); |
@zanllp
Yes, the 对的,就是那个归档,我觉得把它当成临时工作区也不错,这样就不用考虑临时标签需要清除的问题了,处理完直接把图片全清空就行。
So, you recommend us to use the 就是推荐我们使用
My extension may not have an iib submodule, I’m considering reusing the running iib extension 我的扩展可能不会内置一个子模块的iib,我考虑复用正在运行的iib |
Yes, we should agree on some APIs, and then I don't care about the implementation on your side, similar to the bridge between native and web. If you need any API, you can ask me to add it or you can submit a pull request yourself. I haven't implemented the specific APIs yet, so it's more like an RFC. As @picobyte mentioned earlier, he wanted to try modifying it first, but I'm not sure about his progress. However, the frontend of IIB is quite complex, and I feel that modifying it won't be an easy task if you haven't specialized in frontend development. If you encounter any difficulties, you can always hand over this work to me.
I think this is feasible |
Yes, I totally agree with that. Don’t worry about the implementation on my side. Whether it’s 是的,我十分同意这一点。不用在乎我这边的实现,无论是
Thank you very much. I know nothing about frontend development, I will wait patiently. I will do some other work first, don’t mind me. 十分感谢你。我对前端开发一无所知,我会耐心等待的。我会先做一些其他的工作,不用在乎我这边。 |
Thank you for your reply. Because of my work I can mostly spend time in the weekends. A rudimentary version was working, mostly thanks to Sean Wang. working though disabled if the iib extension is in Automatic1111. I've actually mostly focused on other issues, sorry, I may have misunderstood. |
These features have been roughly implemented and are available in the AppUtils(base = "/foo", export_fe_fn=True).wrap_app(app) Add a container for IIB + gr.HTML("error", elem_id="bar_iib_container")
- gr.HTML("error", elem_id="infinite_image_browsing_container_wrapper") Load index.js on the browser side. // Make a fetch request to a fake API endpoint to retrieve the JavaScript code
const jscodeResp = await fetch("/file?path=/path/to/your/submodue-iib/index.js") // Replace this with the actual API endpoint that serves the IIB code
// Convert the response into a text string
const jsText = await jscodeResp.text()
// Replace certain strings in the JavaScript code with new values
const js = jsText
.replace("__iib_root_container__", "'#bar_iib_container'") // Set the root container for the IIB
.replace("__iib_should_maximize__", "false") // Set the initial maximized state for the IIB
// Replace all occurrences of "/infinite_image_browsing" with "/foo"
// Change the base URL used by the IIB to load its resources
.replace(/\/infinite_image_browsing/g, "/foo")
// Evaluate the modified JavaScript code
eval(js) // Initialize the IIB with the modified configuration const iib = gradioApp().querySelector('#bar_iib_container iframe').contentWindow
const { insertTabPane, getTabList, getPageRef, createGridViewFile: f } = iib
// The createGridViewFile function is a helper function that simplifies the creation of a FileNodeInfo object.
const files = [
// Create an array of files with their corresponding tags.
f('/path/to/img/1', ['tag1', 'tag2']),
f('/path/to/img/2', ['tag3', 'tag4', 'tag6']),
f('/path/to/img/3', ['tag2', 'tag5']),
f('/path/to/img/4', ['tag1', 'tag2'])
]
// Insert a new tab pane of grid view type and assign it to the gridView variable.
const gridView = insertTabPane({
// Optional parameters for tab index and pane index.
tabIdx: 0,
paneIdx: 0,
pane: {
type: 'grid-view', // Other types are also available, see https://github.com/zanllp/sd-webui-infinite-image-browsing/tree/main/vue/src/store/useGlobalStore.ts#L15
name: 'Grid View 1',
removable: true, // Optional parameter to allow the files to be removed, default is false.
allowDragAndDrop: true, // Optional parameter to allow drag and drop, default is false.
files // Use the files array created earlier for this pane.
}
})
// Retrieve the files from the gridView pane and set them back to the same pane.
const files = gridView.ref.getFiles()
gridView.ref.setFiles(files)
// Get the tab list
const tabList = getTabList()
tabList[0].panes.key
// Get the file list from the first pane of the first tab.
const pane = tabList[0].panes[0]
getPageRef(pane.key).getFiles()
// Insert a new tab pane of local type with the specified directory path.
const localDirPane = insertTabPane({
pane: {
type: 'local',
path: 'E:/_归档/green'
}
})
localDirPane.ref.close() // Closes the newly created tab pane To learn more information, you can refer to the type definition in the following file: sd-webui-infinite-image-browsing/vue/src/store/useGlobalStore.ts Lines 16 to 98 in 80dc801
|
感谢!
我注意到它不像 而且无法用ctrl批量选择图片;那个拖拽好像也有问题,我把图片从 是它就是被设计成这样的吗?我觉得只要他能像 Is 如果 If 如果要用 If use batch-download as a temporary workspace, the current interface seems to not accept (‘/path/to/img/1’, [‘tag1’, ‘tag2’])? iib是否已经实现过一个跳转功能呢?就是把当前界面切到iib去(在新网页打开也行)。 如果还没有的话,只要在A1111-WebUI里注册的 有的话我就不造轮子了。 Has iib already implemented a jump function? I mean, jump to the page displayed by iib (it’s okay to open it in a new web page). |
First of all, I do not recommend using
The biggest difference between In addition, I have added several useful functions. const { setTagColor, setTags, getTags } = iib
setTagColor("tag1", "#1890ff")
setTagColor("tag2", "green")
const localDirPane = insertTabPane({
pane: {
type: 'local',
path: 'E:/_归档/green'
}
})
const path = E:\\_归档\\green\\1.png'
setTags(path, ['tag1', 'tag2', 'tag3'])
const tags = getTags(path) You can use switch2IIB and openIIBInNewTab to implement navigation. |
Thank for your quick response.
那么,先让用户在 但更新后可以从别的地方拖拽图片到 如果采用这个方案的话,用户确实能通过
So, how about letting the user select the desired images in
此外, 还有 The image thumbnails of
我觉得,如果 I think, if
然后我注意到了
|
Maybe you need to pay attention to the escaping of paths and the use of separators. By the way, If it's not a critical feature, you can wait until I have some free time to see how to implement these features. I need to find a new job recently. |
You are right. Now it works normally. Thanks.
It's ok, I can wait for it. Wishing you find a satisfying job.
Maybe I can understand some of the code, but writing a complete js code is very difficult for me right now, I can only do most of the work in python. But, thanks anyway. |
Used in multiple tabs
@picobyte and I are discussing how to embed
iib
in our own gradio extension tabMy current understanding is that in A1111 WebUI,
iib
interacts with the backend through JavaScript, which requires a fixed elem_id of gradio componentI am trying to create the same
gradio.HTML
component in another extension, which can indeed embediib
in another extensionbut it has resulted in the original
iib
being unable to be used.Is there any way to achieve this?
Mark imags
Our extension can provide images tagger, such as duplicate images or restricted level images.
Can
iib
identify these markings for us? We can provide a txt file with the same name of images, a JSON file, or a Python interfaceEspecially for duplicate image, we are not satisfied with the gradio gallery components
The text was updated successfully, but these errors were encountered: