Spaces:
Configuration error
Configuration error
LucaVivona
commited on
update ⚒️
Browse files- README.md +3 -3
- backend/src/example/examples.py +43 -0
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
# Gradio Flow 🤗
|
2 |
|
3 |
-
**A web application with a backend in Flask and frontend in
|
4 |
-
stream both [
|
5 |
|
6 |
|
7 |
## Tabel Of Contents 📚
|
@@ -205,4 +205,4 @@ if __name__ == "__main__":
|
|
205 |
# Greeting().launch(listen=2000)
|
206 |
````
|
207 |
## Application 🏛️
|
208 |
-
![Application](https://github.com/commune-ai/Gradio-Flow/blob/gradio-flow/gradio-only/app.png)
|
|
|
1 |
# Gradio Flow 🤗
|
2 |
|
3 |
+
**A web application with a backend in [Flask](https://flask.palletsprojects.com/en/2.2.x/) and frontend in [React](https://reactjs.org), and [React flow](https://reactflow.dev/) node base environment to
|
4 |
+
stream both [Gradio](https://gradio.app) ( and later [Streamlit](https://streamlit.io) ) interfaces, within a single application.**
|
5 |
|
6 |
|
7 |
## Tabel Of Contents 📚
|
|
|
205 |
# Greeting().launch(listen=2000)
|
206 |
````
|
207 |
## Application 🏛️
|
208 |
+
![Application](https://github.com/commune-ai/Gradio-Flow/blob/gradio-flow/gradio-only/app.png)
|
backend/src/example/examples.py
CHANGED
@@ -7,11 +7,19 @@ import torch
|
|
7 |
from torch import nn
|
8 |
import numpy as np
|
9 |
import PIL
|
|
|
10 |
|
11 |
sys.path.insert(0, "../resources")
|
12 |
from resources.module import GradioModule, register
|
13 |
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
@GradioModule
|
16 |
class Pictionary:
|
17 |
|
@@ -103,6 +111,41 @@ class FSD:
|
|
103 |
carr = np.array(pixels / np.max(pixels, axis=(0, 1)) * 255, dtype=np.uint8)
|
104 |
return [PIL.Image.fromarray(carr), self.palette_reduce(img, nc) ]
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
@GradioModule
|
107 |
class stock_forecast:
|
108 |
|
|
|
7 |
from torch import nn
|
8 |
import numpy as np
|
9 |
import PIL
|
10 |
+
<<<<<<< HEAD
|
11 |
|
12 |
sys.path.insert(0, "../resources")
|
13 |
from resources.module import GradioModule, register
|
14 |
|
15 |
|
16 |
+
=======
|
17 |
+
|
18 |
+
sys.path.insert(0, "../resources")
|
19 |
+
from resources.module import GradioModule, register
|
20 |
+
|
21 |
+
"""
|
22 |
+
>>>>>>> origin/main
|
23 |
@GradioModule
|
24 |
class Pictionary:
|
25 |
|
|
|
111 |
carr = np.array(pixels / np.max(pixels, axis=(0, 1)) * 255, dtype=np.uint8)
|
112 |
return [PIL.Image.fromarray(carr), self.palette_reduce(img, nc) ]
|
113 |
|
114 |
+
<<<<<<< HEAD
|
115 |
+
=======
|
116 |
+
@register(inputs=[gr.Image(), gr.Image(), gr.Slider(0.00, 16)], outputs=gr.Gallery())
|
117 |
+
def examples(self, img, img2, nc, ) -> 'list[PIL.Image.Image]':
|
118 |
+
pixels = np.array(img, dtype=float) / 255
|
119 |
+
new_height, new_width, _ = img.shape
|
120 |
+
for row in range(new_height):
|
121 |
+
for col in range(new_width):
|
122 |
+
old_val = pixels[row, col].copy()
|
123 |
+
new_val = self.get_new_val(old_val, nc)
|
124 |
+
pixels[row, col] = new_val
|
125 |
+
err = old_val - new_val
|
126 |
+
if col < new_width - 1:
|
127 |
+
pixels[row, col + 1] += err * 7 / 16
|
128 |
+
if row < new_height - 1:
|
129 |
+
if col > 0:
|
130 |
+
pixels[row + 1, col - 1] += err * 3 / 16
|
131 |
+
pixels[row + 1, col] += err * 5 / 16
|
132 |
+
if col < new_width - 1:
|
133 |
+
pixels[row + 1, col + 1] += err * 1 / 16
|
134 |
+
carr = np.array(pixels / np.max(pixels, axis=(0, 1)) * 255, dtype=np.uint8)
|
135 |
+
return [PIL.Image.fromarray(carr), self.palette_reduce(img, nc) ]
|
136 |
+
|
137 |
+
|
138 |
+
@GradioModule
|
139 |
+
class C:
|
140 |
+
|
141 |
+
def Hello(self):
|
142 |
+
return "Hello"
|
143 |
+
|
144 |
+
@register(inputs="text", outputs="text")
|
145 |
+
def Greeting(self, name):
|
146 |
+
return self.Hello() + " " + name
|
147 |
+
|
148 |
+
>>>>>>> origin/main
|
149 |
@GradioModule
|
150 |
class stock_forecast:
|
151 |
|