WSH032 / sd-webui-fast-dataset-maker

A funny extension that integrates image-browsing , downloader , deduplicate , cluster , can quickly collect, classify and process your images. | 一个有趣的扩展,整合了 图库,下载,去重,聚类 ,可以快速搜集、分类、处理你的图片。
Apache License 2.0
20 stars 1 forks source link

very interesting extension, can I include some? #4

Open picobyte opened 1 year ago

picobyte commented 1 year ago

Directed from here, it seems you have an extension that includes something very similar to what I would like to implement in the stable-diffusion-webui-wd14-tagger extension that I've recently handed maintainership of. Your license permits it, so I'll pick up some of your changes, unless you disagree. Your code looks pretty good, I'll have to translate some comments I am unable to read. Thanks.

WSH032 commented 1 year ago

Thank you for taking note of this repository Of course, please feel free to use it.😊

picobyte commented 1 year ago

Thank you!

WSH032 commented 1 year ago

Is that you want to display the sd-webui-infinite-image-browsing in gradio.Tab? This is the relevant section: https://github.com/WSH032/sd-webui-fast-dataset-maker/blob/5bc34f3edd1d6f4040f77cd94db3919b60b10a92/extensions/extensions_ui.py#L49


In fact, sd-webui-fast-dataset-maker simulates the startup behavior of A1111 WebUI

If you just want to display sd-webui-infinite-image-browsing in gradio.Tab, you should refer to https://github.com/zanllp/sd-webui-infinite-image-browsing/blob/b29242efc0dc72044e4b7ed439888841ed3ad178/scripts/iib_setup.py#L16

picobyte commented 1 year ago

Thanks. It seems that you have the extensions as git submodules, maybe that is the only option, but I was initally thinking about using the extensions from the parent directory. like so, if that is possible, I don't know yet.

WSH032 commented 1 year ago

Not very understanding Do you mean importing another independent extension sd-webui-infinite-image-browsing in stable-diffusion-webui-wd14-tagger ?

I don't think so, because users may change the folder name of iib, so you won't be able to find and import it. If you really want to embed iib into stable-diffusion-webui-wd14-tagger, I think it's best to control folder names through submodules


I noticed that you seem to be implementing the images deduplication function?

And, you want to display duplicate images in gradio?

picobyte commented 1 year ago

You are probably right and a submodule avoids conflicts. I am thinking about several options:

  1. Duplicates, correct, in particular also removing or moving files if they are, but a bit more than simple duplicate search; also a highly similar search within the set of images for a batch query that has been tagged.
  2. Sorting images based on selected tags and weights for the images that have been batch queried.
  3. Some file management (moving files) so that more images can be added to the batch query folder for tagging. From a gallery like yours on a tab, images can be interrogated (tagged) easily by a drag-drop.

It's a lot but I think it could be beneficial.

WSH032 commented 1 year ago

Cool !


Duplicates, correct, in particular also removing or moving files if they are, but a bit more than simple duplicate search; also a highly similar search within the set of images for a batch query that has been tagged.

I have an extension for deduplication.

My idea is to mark them by renaming, or move these duplicate images to another folder, and then view and process them through iib.

But I don't embed iib into this deduplication extension, but rather adapt to independently running iib by modifying the deduplication extension

Z()ZLPGI((B5)9WMM@{`CBP Z 5H0D3CU4Y}LE3 6P PA


supplement:

I provide users with easy viewing and processing methods through Gradio.Gallery, rather than through iib

If users need more advanced processing, I will provide move or rename functions to mark these images for use in iib

WSH032 commented 1 year ago

Thanks. It seems that you have the extensions as git submodules, maybe that is the only option, but I was initally thinking about using the extensions from the parent directory. like so, if that is possible, I don't know yet.

If you really want to embed iib into stable-diffusion-webui-wd14-tagger, it seems that you don't need to import iib

iib seems to rely on FastAPI and JS to work, which means that if the user has already installed iib extension, you don't need to import it again when use in A1111-WebUI. You just need to create your own Gradio components and keep the same elem_id.

gr.HTML("error", elem_id="infinite_image_browsing_container_wrapper")

I am not sure, I will try later


supplement:

Okay, it does work, but don't do that, it will invalidate the original iib P6)(YP46J366B$N2}6%9T}D

Perhaps we should ask the author of iib

picobyte commented 1 year ago

Thanks for the information. I've already started a bit, but it will take some time, before I understand and then I may have questions. Don't expect this to be included any time soon. It's a slow process. I'll first make a feature branch for this. That's for sure.

WSH032 commented 1 year ago

Looking forward to it😀

If there is anything I can help, I would be happy to

stable-diffusion-webui-wd14-tagger is a very useful extension that greatly helped me in SD-lora-training. Thank you for your work

picobyte commented 1 year ago

I have just started, and I've already made tons of changes. Though I do a lot of testing, I hope I didn't also break things for others. There were some issues already, e.g. fastapi, but I think I resolved them also. we'll see.. Thanks for the heads up.

picobyte commented 1 year ago

The feature branch I started with is here Its addition is just the extensions directory, with English added and some white space changes. I'm not even sure if I'm going to need all plugins, that's for later. If you like to help, you are welcome of course.

WSH032 commented 1 year ago

Awsome, these English translations are correct

But there is one thing to note. sd-webui-fast-dataset-maker only supports running independently of A1111-WebUI, do you know this?

Is that you want to embed iib here when use in A1111-WebUI? A~TOT`S 85SI5{%7JAH)LP1

If so, there would be a better implementation method instead of relying on sd-webui-fast-dataset-make

picobyte commented 1 year ago

ok, thanks a lot! yes, I'd like to run it on the tab, like you point out. you wrote about this before, I'll check it out. with lib you mean the infinite image browser? Or you mean that I can just import this as a library

WSH032 commented 1 year ago

with lib you mean the infinite image browser?

yes, iib == infinite image browser


I'd like to run it on the tab, like you point out.

In fact, sd-webui-fast-dataset-maker only provides a runtime environment similar to A1111-WebUI for iib, rather than embedding iib into specific tabs

I am sure there is a better way to run iib on the tab of own extension. I will communicate with the author of iib to see if it is possible.

picobyte commented 1 year ago

Well maybe a standalone version is a very interesting idea as well, a second app altogether, but currently I think I'll keep this an automatic1111 extension to keep it a little simple for myself. It's already a lot of changes. If you'd like to include some of the tagging features, then that would be an option as well.

WSH032 commented 1 year ago

I'll keep this an automatic1111 extension to keep it a little simple for myself.

I agree with you. As an extension, it will be more flexible


like this? HK58_$X`CXF@TT~Q3KP%M8J

picobyte commented 1 year ago

Yes, exactly like that.

WSH032 commented 1 year ago

image

That's it, dont change elem_id


But it will make the original iib unusable


supplement:

But why not let users install an iib extension themselves

picobyte commented 1 year ago

ok I'm trying it out now.

It just says error there.

WSH032 commented 1 year ago

Oh, sorry. forgive me, I overlooked that implementing this requires installing iib

picobyte commented 1 year ago

ah ok you install it as a submodule, or an import?

WSH032 commented 1 year ago

ah ok you install it as a submodule?

Of course, this can be achieved, but it still conflicts with the original iib I will ask the author of iib

picobyte commented 1 year ago

I could just fork the imagebrowser, clone my fork as a submodule and change the elem_ids in javascript, css and ui

WSH032 commented 1 year ago

This is a feasible solution

Do you konw about how fastapi and script_callbacks.on_app_started work?

As far as I know, iib needs to use this callback to register fastapi

If the user installs the original iib at the same time, I am not sure if there is a conflict between the two callbacks


And, this is javascript of iib

  • This is a file generated using yarn build.
  • If you want to make changes, please modify index.tpl.js and run the command to generate it again.
picobyte commented 1 year ago

I recently learned about the tagger included a fastapi, I didn;t know before and that was what I broke with my changes, but I believe I've fixed it. I also added a remote unload function. I don't know yet about script_callbacks.on_app_started, but I'm sure that I can also find out, thanks for all the information, it is very kind of you.

I will test it out, of course, I have the extension as well.

WSH032 commented 1 year ago

That's how A1111-WebUI script_callbacks.on_app_started work https://github.com/WSH032/sd-webui-fast-dataset-maker/blob/5bc34f3edd1d6f4040f77cd94db3919b60b10a92/webui.py#L138

May be useful for your understanding


I still think it would be better for users to install iib themselves

The duplicate check function only needs to provide users with a simple gallery, or mark images for independent iib to use

picobyte commented 1 year ago

Also I believe your repository would be useful: image-deduplicate-cluster-webui I also implemented something very simple myself, but it's just based on sorted tags + weights with a precision of one digit. That already was kind of working, though and allowing me to find duplicates slight crop, horizontal flip, file rename and rescaled image. It does also list some highly similar photos. But your implementation is more advanced, and why reinvent the wheel?

WSH032 commented 1 year ago

Thank you for your comment!

But your implementation is more advanced

I didn't write many algorithms. I just used the imagededup library to check the duplicate and display the results in the gallery


But it is better not to refer to it first. The code of version 1.0.0 is too bad. I am reconstructing it. I will release version 2.0.0 when I am free, probably the day after tomorrow


supplement:

that's alpha for reconstructing https://github.com/WSH032/image-deduplicate-cluster-webui/tree/dev-2.0.0-alpha.1

WSH032 commented 1 year ago

Hi, check this commit

I almost finished it. But this still conflicts with the original iib, and it may not work if the user has already installed iib. Don’t worry about this, in the last discussion, the author of iib said he would solve the elem_id problem.

F7O{$MDZVMD~`O`4)P)MH58

picobyte commented 1 year ago

Thanks. I'm currently debugging some other ui issues that can improve user experience, but I'll work on the gallery asap.

picobyte commented 1 year ago

It seems I'm still missing something, or due to the pending elem_id I still only see the error label and my basic gallery. I fetched your branch: the changes on top of my fast-dataset-maker-gallery, locally named WSH032-fast-dataset-maker-gallery. Or maybe some of my extensions interfere. I use the dark mode and lobe theme - disabling the lobe theme didn't resolve it. Inspect element shows a few errors. It could also be something that wasn't committed or there's another reason (Linux/cpu-only). But don't worry, I'll do some more debugging. or it is pycache, let's try that first..

WSH032 commented 1 year ago

It should not be a problem with other extensions or UI themes, unless another iib extension are runing. Can you check if extensions_ui.on_app_startd() and extensions_ui.on_ui_tabs() are working properly?

Another possible reason is: JavaScript may not work properly. What's bad is that, I have never studied JavaScript, so I don’t know how to check it. This JavaScript file comes from iib, iib needs it to work properly, and I don’t know if moving it will affect the normal working of this js code

picobyte commented 1 year ago

I can understand javascript, but it can be complex, in particular async and debugging. Both extensions_ui.on_app_startd() and extensions_ui.on_ui_tabs() print in the console, no other errors there, by the way. When I inspect element, in the console (where javascript errors are printed) there are some but they seem unrelated (I already had those). there's a warning:

Could not find "window.__TAURI_METADATA__". The "appWindow" value will reference the "main" window label.
Note that this is not an issue if running this frontend on a browser instead of a Tauri window.
(anonymous) @   index-23e5bc7c.js:180
index-23e5bc7c.js:186 
Object
index-23e5bc7c.js:190 undefined
index-23e5bc7c.js:190 Splitpanes: Could not resize panes correctly due to their constraints.
(anonymous) @   index-23e5bc7c.js:190

and I vaguely recall that tauri may be something related. EDit: actually no, Tauri is a different frontend, and I run it in a browser. Then, if I click on the gallery tab, I get 5 times in a row:

file=script.js?1688626290.013775:85 error running callback ƒ (){
    check_gallery(SP_GALLERY_LABEL)
} : ReferenceError: check_gallery is not defined
    at smart_process.js?1688934712.344647:31:5
    at executeCallbacks (file=script.js?1688626290.013775:83:13)
    at MutationObserver.<anonymous> (file=script.js?1688626290.013775:112:9)

That ReferenceError: check_gallery is not defined seems suspicious, but I cannot find it anywhere in the stable-diffusion-webui-wd14-tagger or addons/sd_webui_infinite_image_browsing code.

picobyte commented 1 year ago

I found something here which indicates the state extension might be the culprit, which I have. I'll try disabling that. Nope. that javascript fe-static is something also referenced in ‎scripts/iib/api.py, line 143. I have to call it a day; we'll get there.

WSH032 commented 1 year ago

OK, let’s take it slow This is a strange problem, I reinstalled the new branch of tagger in A1111-WebUI, and it still works normally. Even though I also have the same inspection element error QI50 MM)L5E~LCN6ME$A97W


This is my env 6M(4RANQJF3 (M9~}N1 BUQ Windows 10

WSH032 commented 1 year ago

Can you try this Colab? I borrow it from here It should work @TUB _~XF~O5N`8(D@K)AXW

picobyte commented 1 year ago

Edit: nevermind, this is for colab, not to run in a jupyter notebook on my pc Edit2: I can confirm that the gallery is working in colab.

I run webui on my own desktop PC and I have the sd-webui-infinite-image-browsing, which just works. Therefore I don't think this issue has to do with packages. This colab seems to install some packages, but my distribution is not ubuntu, so package names differ, but I've installed aria2, I believe I have most. Also, I run on cpu, I don't have a very powerful GPU, and it's AMD. The -xformers and packages are for nvidia. Why does the colab base64 encode all strings, obfuscation against crawlers/machine learning? Before executing anything I'll decode it anyway. It occurred to me that changes in the addons/sd_webui_infinite_image_browsing are not included in the changes that I picked up from your fork, so if there were edits there, then I might still need those.

Thank you for the information, I have some weekend time now so I'll figure it out, don't worry.

WSH032 commented 1 year ago

This colab seems to install some packages

These packages are irrelevant and do not affect the normal operation of iib. Similarly, GPU does not affect the work of iib.


Why does the colab base64 encode all strings, obfuscation against crawlers/machine learning? Before executing anything I'll decode it anyway.

Colab prohibits running any code with the substring “SD-Webui”, I have to use base64 to encrypt it to deceive colab.


It occurred to me that changes in the addons/sd_webui_infinite_image_browsing are not included in the changes that I picked up from your fork, so if there were edits there, then I might still need those.

I did not modify anything in the submodule. In Colab, I directly pulled the submodule from your fork.


I can confirm that the gallery is working in colab.

This is a strange problem, if it can run normally in Colab, it means the js file works well. You mentioned that you also installed sd-webui-infinite-image-browsing, have you tried disabling sd-webui-infinite-image-browsing extension on A1111-WebUI? Anyway, make sure it does not run with Tagger at the same time.

picobyte commented 1 year ago

I also just tried my branch where I already merged the master branch and that works as well in colab.

You mentioned that you also installed sd-webui-infinite-image-browsing, have you tried disabling sd-webui-infinite-image-browsing extension on A1111-WebUI? Anyway, make sure it does not run with Tagger at the same time.

Thanks, this seems to be related, though it is not working yet, locally I do not get the error message, but it is different. interesting!

currently I am seeing:

It seems to have failed to load. You can try refreshing the page.
If that doesn't work, click on FAQ for help

And that means it is at least loading the infinite browser.

Edit: I think I will have it now, I was still on your standalone branch. Awesome! it is working!! So an infinite_image_browsing extension currently does interfere.

WSH032 commented 1 year ago

currently I am seeing:

It seems to have failed to load. You can try refreshing the page.
If that doesn't work, click on FAQ for help

And that means it is at least loading the infinite browser.

You mean, you see this message in the gellery of Tagger on your PC? If so, that’s good news.

picobyte commented 1 year ago

Thanks for all the help !

WSH032 commented 1 year ago

You are welcome.

So an infinite_image_browsing extension currently does interfere.

You solve this problem after disabling iib? That’s good news. I will solve this conflict problem after the author of iib updates the isolation feature.

picobyte commented 1 year ago

Forgive me for not trying this before. I was expecting neither or both to work. I think there are some more things desireable though, like configuring what folder iib starts with, and drag and drop is not working, but I'll also work on this. iib needs to work in a special modus, if on a tab, I guess

WSH032 commented 1 year ago

That’s ok.

like configuring what folder iib starts with

Don’t worry, I can implement these.