Spaces:
Configuration error
Configuration error
Luca Vivona
commited on
Commit
Β·
e8007d5
1
Parent(s):
03143f3
README.md
Browse files
README.md
CHANGED
@@ -46,7 +46,7 @@ stream both gradio and streamlit interfaces, within a single application.**
|
|
46 |
|
47 |
## Prerequisites π
|
48 |
You will need:
|
49 |
-
(Docker build π³ Currently Only on: Linux)
|
50 |
- [π³ Docker](https://docs.docker.com/get-docker/)
|
51 |
- [π Docker Compose](https://docs.docker.com/compose/install/) (included with Docker Desktop on Windows and macOS)
|
52 |
|
@@ -105,42 +105,46 @@ python app.py -p 2000
|
|
105 |
//**NOTE** -p 2000 just assignes it localhost port 2000 anyother port will not work
|
106 |
```
|
107 |
#### **5.** Run Gradio within Gradio-Flow
|
108 |
-
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/
|
109 |
|
110 |
**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.
|
111 |
|
112 |
```python
|
113 |
#backend/src/demo.py (functional base)
|
114 |
##########
|
115 |
-
from
|
116 |
-
import gradio as gr
|
117 |
|
118 |
-
@
|
119 |
def Hello_World(name):
|
120 |
return f"Hello {name}, and welcome to Gradio Flow π€"
|
121 |
|
|
|
|
|
|
|
|
|
122 |
if __name__ == "__main__":
|
123 |
-
tabularGradio([Hello_World()], ["
|
124 |
```
|
125 |
|
126 |
```python
|
127 |
#backend/src/index.py (Class Base)
|
128 |
###########
|
129 |
-
from
|
130 |
-
import gradio as gr
|
131 |
|
132 |
-
@
|
133 |
class Greeting:
|
134 |
|
135 |
-
@register(
|
136 |
def Hello_World(self, name):
|
137 |
return f"Hello {name}, and welcome to Gradio Flow π€"
|
138 |
|
|
|
|
|
|
|
139 |
|
140 |
|
141 |
if __name__ == "__main__":
|
142 |
Greeting().run(listen=2000)
|
143 |
-
|
144 |
-
|
145 |
## Application ποΈ
|
146 |

|
|
|
46 |
|
47 |
## Prerequisites π
|
48 |
You will need:
|
49 |
+
(Docker build π³ Currently Only on: Linux/Windows/Mac)
|
50 |
- [π³ Docker](https://docs.docker.com/get-docker/)
|
51 |
- [π Docker Compose](https://docs.docker.com/compose/install/) (included with Docker Desktop on Windows and macOS)
|
52 |
|
|
|
105 |
//**NOTE** -p 2000 just assignes it localhost port 2000 anyother port will not work
|
106 |
```
|
107 |
#### **5.** Run Gradio within Gradio-Flow
|
108 |
+
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**](https://github.com/LVivona/GradioWrapper)).
|
109 |
|
110 |
**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.
|
111 |
|
112 |
```python
|
113 |
#backend/src/demo.py (functional base)
|
114 |
##########
|
115 |
+
from resources import register, tabularGradio
|
|
|
116 |
|
117 |
+
@register(["text"], ["text"], examples=[["Luca Vivona"]])
|
118 |
def Hello_World(name):
|
119 |
return f"Hello {name}, and welcome to Gradio Flow π€"
|
120 |
|
121 |
+
@register(["number", "number"], ["number"], examples=[[1,1]])
|
122 |
+
def add(x, y):
|
123 |
+
return x + y
|
124 |
+
|
125 |
if __name__ == "__main__":
|
126 |
+
tabularGradio([Hello_World(), add()], ["Hello World",])
|
127 |
```
|
128 |
|
129 |
```python
|
130 |
#backend/src/index.py (Class Base)
|
131 |
###########
|
132 |
+
from resources import GradioModule, register
|
|
|
133 |
|
134 |
+
@GradioModule
|
135 |
class Greeting:
|
136 |
|
137 |
+
@register(["text"], ["text"])
|
138 |
def Hello_World(self, name):
|
139 |
return f"Hello {name}, and welcome to Gradio Flow π€"
|
140 |
|
141 |
+
@register(["number", "number"], ["number"], examples=[[1,1]])
|
142 |
+
def add(self, x, y):
|
143 |
+
return x + y
|
144 |
|
145 |
|
146 |
if __name__ == "__main__":
|
147 |
Greeting().run(listen=2000)
|
148 |
+
````
|
|
|
149 |
## Application ποΈ
|
150 |

|