Skip to content

emelpolaris/GradioFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Gradio Flow

๐Ÿ‘‹ Reach Me For Inquiry or Bugs

What Is Gradio Flow

A web application with a backend in Flask and frontend in React, and React flow node base environment to stream both Gradio ( and later Streamlit ) interfaces, within a single application.

Tabel Of Contents ๐Ÿ“š

Application ๐Ÿ›๏ธ

Dark-Application Light-Application

Features ๐ŸŒ

Light/Dark Mode ๐ŸŒ• โ˜€๏ธ

theme

Append Node โž•

Append

Resize Node ๐Ÿ“

Huggin

Delete Node ๐Ÿ—‘๏ธ

delete

Remove Node From Dashboard ๐Ÿšฎ

delete

Updates โš’๏ธ

Backend ๐Ÿ’ฝ

  • Bug fixes for max_thread when launching gradio

Frontend ๐Ÿ–ฅ๏ธ

image

In The Works ๐Ÿšง

  • Mutiple windows within the react-flow environment
  • Directory tree search that looks for files that contain classes and functions that are registered under the decorators that are in backend/src/resources allowing you to append all your registered functions with only using the frontend.
  • Convert Flask API to FastAPI to complement new feture that allow user so add gradio endpoints (In the works)

App Architecture ๐Ÿ—๏ธ

architecture

Prerequisites ๐Ÿ“

You will need: (Docker build ๐Ÿณ Currently Only on: Linux/Windows/Mac)

(Running Without docker)

  • ๐Ÿ Python 3.2+ (backend)
  • npm 8.5.0 (frontend)
  • node v16.14.2 (frontend)

Running The App ๐Ÿ–ฅ๏ธ

Starting up it's simple as every command is already within the Makefile.

Makefile Run (Docker ๐Ÿณ)

1. Running the docker container

make up
// command running: docker-compose up -d --remove-orphans;
// **Ubuntu** sudo make up

The React application will be running on http://localhost:3000 and the Flask will be running on http://localhost:2000

2. Entering the backend enviorment

make environment
// command running: docker exec -it backend bash;
// **Ubuntu** sudo make environment

Now that you're within the docker backend container environment you can start adding gradio/streamlit nodes within the frontend. (Extra Note) You do not need to be within the container environment to append nodes there is a feature to just run your own gradio application and then append it within the frontend by using the + button.

3. Appending Nodes To Frontend From The Backend

> cd ./src/demo
> python demo.py -l 2000
//run example gradio application

Non-Docker Build

1. Build Frontend (within the directory ./frontend)

npm install

2. Run Frontend (within the directory ./frontend)

npm start

3. Build Backend Dependency (within the directory ./backend)

pip install -r requirements.txt

4. Run Backend (within the directory backend)

python app.py -p 2000
//**NOTE** -p 2000 just assignes it localhost port 2000 anyother port will not work

5. Run Gradio within Gradio-Flow

It is quite simple, and similar within the docker build, the first way you can append your gradio to the Gradio flow is through running your application at a reachable url that is provided ed when you run Gradio and appending it via + button within the frontend, another way that is possible is that within the directory ./backend/src/resources there is a code that you can use to convert your own class or functional base code into basic gradio tabular interface by using decorators, these decorators will send the nesarry information to the backend flask api and update the frontend menu state in which you'll will be able to interact with it within the front end creating a hub for gradio build functions(read more here or look at the code here ).

NOTE If you use the gradio decorator compiler for gradio flow you need to set a listen port to 2000 or else the api will never get the key and will throw you an error, I'll also provided an example below if this isn't clear.

# (functional base)
##########
from resources import register, tabularGradio

@register(["text"], ["text"], examples=[["Luca Vivona"]])
def Hello_World(name):
        return f"๐Ÿ‘‹ Hello {name}, and welcome to Gradio Flow ๐Ÿค—" 

if __name__ == "__main__":
    # run single gradio
    tabularGradio([Hello_World])  # tabularGradio([Hello_World], ["Greeting"])

    # run it within Gradio-Flow
    # tabularGradio([Hello_World], listen=2000) # tabularGradio([Hello_World], ["Greeting"], listen=2000)
    
#(Class Base)
###########
from resources import GradioModule, register

@GradioModule
class Greeting:

    @register(["text"], ["text"], examples=[["Luca Vivona"]])
    def Hello_World(self, name):
        return f"๐Ÿ‘‹ Hello {name}, and welcome to Gradio Flow ๐Ÿค—" 

if __name__ == "__main__":
    # run just gradio
    Greeting().launch()
    # run it within Gradio-flow
    # Greeting().launch(listen=2000)

More Demos โž•

Within the backend/src/demo directory there are some demos

# type : class | function | load | None
# port : 2000 | None 
# python demo.py -e [type] -l [port]
(e.g)
> python demo.py -e class -l 2000
> python demo.py -e class

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published