Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,29 @@
|
|
1 |
-
import
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
)
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
)
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import lightning as L
|
2 |
+
from lightning.app.components import ServeGradio
|
3 |
import gradio as gr
|
4 |
|
5 |
+
class LitGradio(ServeGradio):
|
6 |
+
|
7 |
+
inputs = gr.inputs.Textbox(default='lightning', label='name input')
|
8 |
+
outputs = gr.outputs.Textbox(label='output')
|
9 |
+
examples = [["hello lightning"]]
|
10 |
+
|
11 |
+
def predict(self, input_text):
|
12 |
+
return self.model(input_text)
|
13 |
+
|
14 |
+
def build_model(self):
|
15 |
+
fake_model = lambda x: f"hello {x}"
|
16 |
+
return fake_model
|
17 |
+
|
18 |
+
class RootFlow(L.LightningFlow):
|
19 |
+
def __init__(self):
|
20 |
+
super().__init__()
|
21 |
+
self.lit_gradio = LitGradio()
|
22 |
+
|
23 |
+
def run(self):
|
24 |
+
self.lit_gradio.run()
|
25 |
+
|
26 |
+
def configure_layout(self):
|
27 |
+
return [{"name": "home", "content": self.lit_gradio}]
|
28 |
+
|
29 |
+
app = L.LightningApp(RootFlow())
|