filipstrand / mflux

A MLX port of FLUX based on the Huggingface Diffusers implementation.
MIT License
834 stars 53 forks source link

Support for Gradio WebUI #15

Open 7enChan opened 2 months ago

7enChan commented 2 months ago

I would like to propose adding support for Gradio WebUI to this project. The current terminal input experience is not very user-friendly. Gradio could significantly enhance the usability and accessibility of our project. I have implemented a version using cursor, but as I'm not very familiar with coding, I'm unsure if this code is sufficiently concise and elegant. Therefore, I'm not submitting a pull request. Instead, I've attached the code to this issue for reference. To use this implementation, you need to install the following dependency

pip install gradio

SCR-20240821-mvnv

gradioui.py.zip

emilune commented 2 months ago

Hello. I'm a newbie. Can you explain how use it ? thanks in advance.

filipstrand commented 2 months ago

It would indeed be nice to have support for a frontend like Gradio or something similar. If I remember correctly, the original FLUX repo from Black Forest Labs had Streamlit as a frontend to interact with the model. Will put this on the todo list!

7enChan commented 2 months ago

Hello. I'm a newbie. Can you explain how use it ? thanks in advance.

This is just a demo. It's recommended to wait for @filipstrand's more complete version. If you insist on using it now, you can follow these steps:

  1. I assume you can already run mflux normally.
  2. In the window where you run mflux, enter pip install gradio to install gradio, as this interface is built using gradio.
  3. Download the gradiui.py file I provided in the attachment(need to unzip), place it in your mflux root directory, then at the terminal run: python gradiui.py
  4. After successful execution, your terminal will display an address, usually http://127.0.0.1:7860 Open it in your browser and enjoy.

My English is not very good, the above was translated with the help of AI, I hope it can be described clearly.

7enChan commented 2 months ago

It would indeed be nice to have support for a frontend like Gradio or something similar. If I remember correctly, the original FLUX repo from Black Forest Labs had Streamlit as a frontend to interact with the model. Will put this on the todo list!

I've looked into Streamlit and found that its interface is indeed more elegant, though it's also a bit more complex to implement. Black Forest Labs has provided two demos, conveniently based on Gradio and Streamlit. Whichever one is used, support for either would be exciting.

emilune commented 2 months ago

Thanks for your answer. I tried to add “import gradioui” in main.py file and it worked.

Hello. I'm a newbie. Can you explain how use it ? thanks in advance.

This is just a demo. It's recommended to wait for @filipstrand's more complete version. If you insist on using it now, you can follow these steps:

  1. I assume you can already run mflux normally.
  2. In the window where you run mflux, enter pip install gradio to install gradio, as this interface is built using gradio.
  3. Download the gradiui.py file I provided in the attachment(need to unzip), place it in your mflux root directory, then at the terminal run: python gradiui.py
  4. After successful execution, your terminal will display an address, usually http://127.0.0.1:7860 Open it in your browser and enjoy.

My English is not very good, the above was translated with the help of AI, I hope it can be described clearly.

Thanks for your answer. I tried to add “import gradioui” in main.py and it worked.

emilune commented 2 months ago

Thanks for your answer. I tried to add “import gradioui” in main.py file and it worked.

Hello. I'm a newbie. Can you explain how use it ? thanks in advance.

This is just a demo. It's recommended to wait for @filipstrand's more complete version. If you insist on using it now, you can follow these steps:

  1. I assume you can already run mflux normally.
  2. In the window where you run mflux, enter pip install gradio to install gradio, as this interface is built using gradio.
  3. Download the gradiui.py file I provided in the attachment(need to unzip), place it in your mflux root directory, then at the terminal run: python gradiui.py
  4. After successful execution, your terminal will display an address, usually http://127.0.0.1:7860 Open it in your browser and enjoy.

My English is not very good, the above was translated with the help of AI, I hope it can be described clearly.

Thanks for your answer. I tried to add “import gradioui” in main.py and it worked.

With python main.py

7enChan commented 2 months ago

I have implemented a WebUI using Streamlit. The design philosophy is to have an ultra-minimalist mode that focuses entirely on the Prompt. Since I added some other features to this version, it requires changes to multiple files, so I won't be sharing it. For example, it supports the dev&schnell merged model, as well as a magic prompt feature (implemented through Gemini or Groq API). Because my English isn't very good, the magic prompt can convert user prompts from almost any language into English and optimize them into prompts suitable for FLUX.

SCR-20240823-rgkp SCR-20240823-rggv

SCR-20240823-rhfa

raysers commented 1 month ago

非常好的工作。如果有可能,是否可以尝试实现COMFYUI的移植?