Spaces:
Configuration error
Configuration error
LucaVivona
commited on
Commit
•
d809aeb
1
Parent(s):
bd75201
updates ⚒️
Browse files- README.md +50 -0
- backend/.gitignore +2 -1
- backend/src/demoC.py +4 -3
- backend/src/demoE.py +3 -0
- backend/src/demoF.py +2 -0
- backend/src/demoL.py +8 -0
- backend/src/example/data/labels.txt +100 -0
- backend/src/example/data/pytorch_model.bin +3 -0
- backend/src/example/examples.py +17 -26
- backend/src/resources/__pycache__/module.cpython-39.pyc +0 -0
- backend/src/resources/module.py +44 -5
- frontend/public/index.html +21 -1
- frontend/src/Components/Navagation/navbar.js +1 -1
- frontend/src/Components/Nodes/custom.js +5 -4
- frontend/src/Components/ReactFlow/ReactFlowEnv.js +2 -2
- frontend/src/css/dist/output.css +89 -29
- frontend/src/css/iframe.css +5 -0
- frontend/src/index.js +1 -1
README.md
CHANGED
@@ -41,6 +41,56 @@ stream both [gradio](https://gradio.app) ( and later [streamlit](https://streaml
|
|
41 |
- [**Run Gradio within Gradio-Flow**](#5-run-gradio-within-gradio-flow)
|
42 |
|
43 |
- [**Application**](#application-%EF%B8%8F)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
## App Architecture 🏗️
|
45 |
![architecture](https://github.com/commune-ai/Gradio-Flow/blob/gradio-flow/gradio-only/architecture.png)
|
46 |
|
|
|
41 |
- [**Run Gradio within Gradio-Flow**](#5-run-gradio-within-gradio-flow)
|
42 |
|
43 |
- [**Application**](#application-%EF%B8%8F)
|
44 |
+
|
45 |
+
## Updates ⚒️
|
46 |
+
### Backend 💽
|
47 |
+
- ``__init__`` function takes inputs within class wrapper
|
48 |
+
- better determine registered functions within classes
|
49 |
+
- more examples located in the ``backend/src/example``
|
50 |
+
- just import and launch or run them within the demoE.py file in ``backend/src``
|
51 |
+
- launch interface functions that takes the interface and appends it within the gradio-flow so if it's (load, from_pipline, Block, or any other prebuilt interface you have you can append them into Gradio-Flow)
|
52 |
+
|
53 |
+
### Frontend 🖥️
|
54 |
+
- no new updates
|
55 |
+
|
56 |
+
```python
|
57 |
+
def InterLauncher(name, interface, listen=2000, **kwargs):
|
58 |
+
port= kwargs["port"] if "port" in kwargs else DOCKER_PORT.determinePort()
|
59 |
+
print(listen)
|
60 |
+
try:
|
61 |
+
requests.post(f"http://{DOCKER_LOCAL_HOST}:{listen}/api/append/port", json={"port" : port, "host" : f'http://localhost:{port}', "file" : {name}, "name" : "Not Applicable", "kwargs" : kwargs})
|
62 |
+
except Exception as e:
|
63 |
+
print(f"**{bcolor.BOLD}{bcolor.FAIL}CONNECTION ERROR{bcolor.ENDC}** 🐛The listening api is either not up or you choose the wrong port.🐛 \n {e}")
|
64 |
+
return
|
65 |
+
|
66 |
+
interface.launch(server_port=port,
|
67 |
+
server_name=f"{DOCKER_LOCAL_HOST}",
|
68 |
+
inline= kwargs['inline'] if "inline" in kwargs else True,
|
69 |
+
share=kwargs['share'] if "share" in kwargs else None,
|
70 |
+
debug=kwargs['debug'] if "debug" in kwargs else False,
|
71 |
+
enable_queue=kwargs['enable_queue'] if "enable_queue" in kwargs else None,
|
72 |
+
max_threads=kwargs['max_threads'] if "max_threads" in kwargs else None,
|
73 |
+
auth=kwargs['auth'] if "auth" in kwargs else None,
|
74 |
+
auth_message=kwargs['auth_message'] if "auth_message" in kwargs else None,
|
75 |
+
prevent_thread_lock=kwargs['prevent_thread_lock'] if "prevent_thread_lock" in kwargs else False,
|
76 |
+
show_error=kwargs['show_error'] if "show_error" in kwargs else True,
|
77 |
+
show_tips=kwargs['show_tips'] if "show_tips" in kwargs else False,
|
78 |
+
height=kwargs['height'] if "height" in kwargs else 500,
|
79 |
+
width=kwargs['width'] if "width" in kwargs else 900,
|
80 |
+
encrypt=kwargs['encrypt'] if "encrypt" in kwargs else False,
|
81 |
+
favicon_path=kwargs['favicon_path'] if "favicon_path" in kwargs else None,
|
82 |
+
ssl_keyfile=kwargs['ssl_keyfile'] if "ssl_keyfile" in kwargs else None,
|
83 |
+
ssl_certfile=kwargs['ssl_certfile'] if "ssl_certfile" in kwargs else None,
|
84 |
+
ssl_keyfile_password=kwargs['ssl_keyfile_password'] if "ssl_keyfile_password" in kwargs else None,
|
85 |
+
quiet=kwargs['quiet'] if "quiet" in kwargs else False)
|
86 |
+
|
87 |
+
try:
|
88 |
+
requests.post(f"http://{DOCKER_LOCAL_HOST}:{ listen }/api/remove/port", json={"port" : port, "host" : f'http://localhost:{port}', "file" : 'Not Applicable', "name" : name, "kwargs" : kwargs})
|
89 |
+
except Exception as e:
|
90 |
+
print(f"**{bcolor.BOLD}{bcolor.FAIL}CONNECTION ERROR{bcolor.ENDC}** 🐛The api either lost connection or was turned off...🐛 \n {e}")
|
91 |
+
```
|
92 |
+
|
93 |
+
|
94 |
## App Architecture 🏗️
|
95 |
![architecture](https://github.com/commune-ai/Gradio-Flow/blob/gradio-flow/gradio-only/architecture.png)
|
96 |
|
backend/.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
./**/__pycache__
|
|
|
|
1 |
+
./**/__pycache__
|
2 |
+
__pycache__/
|
backend/src/demoC.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
-
from resources import GradioModule, register
|
|
|
2 |
|
3 |
@GradioModule
|
4 |
class Greeting:
|
@@ -14,8 +15,8 @@ class Greeting:
|
|
14 |
|
15 |
if __name__ == "__main__":
|
16 |
# run just gradio
|
17 |
-
Greeting().launch()
|
18 |
# run it within Gradio-flow
|
19 |
-
|
20 |
|
21 |
|
|
|
1 |
+
from resources import GradioModule, register, InterLauncher
|
2 |
+
import gradio as gr
|
3 |
|
4 |
@GradioModule
|
5 |
class Greeting:
|
|
|
15 |
|
16 |
if __name__ == "__main__":
|
17 |
# run just gradio
|
18 |
+
# Greeting().launch()
|
19 |
# run it within Gradio-flow
|
20 |
+
Greeting().launch(listen=2000)
|
21 |
|
22 |
|
backend/src/demoE.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
from example.examples import Pictionary, FSD, HelloWorld_2_0, stock_forecast
|
2 |
+
|
3 |
+
Pictionary("./example/data/labels.txt", "./example/data/pytorch_model.bin").launch(live=True, listen=2000, port=3002)
|
backend/src/demoF.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from resources import register, tabularGradio
|
|
|
3 |
|
4 |
@register(["text"], ["text"], examples=[["Luca Vivona"]])
|
5 |
def Hello_World(name):
|
@@ -11,6 +12,7 @@ def add(x, y):
|
|
11 |
|
12 |
if __name__ == "__main__":
|
13 |
# run single gradio
|
|
|
14 |
tabularGradio([Hello_World(), add()], ["Hello World", "Add"])
|
15 |
|
16 |
# run it within Gradio-Flow
|
|
|
1 |
import gradio as gr
|
2 |
from resources import register, tabularGradio
|
3 |
+
from example.examples import FSD, Pictionary
|
4 |
|
5 |
@register(["text"], ["text"], examples=[["Luca Vivona"]])
|
6 |
def Hello_World(name):
|
|
|
12 |
|
13 |
if __name__ == "__main__":
|
14 |
# run single gradio
|
15 |
+
|
16 |
tabularGradio([Hello_World(), add()], ["Hello World", "Add"])
|
17 |
|
18 |
# run it within Gradio-Flow
|
backend/src/demoL.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from resources import GradioModule, register, InterLauncher
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
if __name__ == "__main__":
|
5 |
+
description = "Story generation with GPT"
|
6 |
+
examples = [["An adventurer is approached by a mysterious stranger in the tavern for a new quest."]]
|
7 |
+
demo = gr.Interface.load("models/EleutherAI/gpt-neo-1.3B", description=description, examples=examples)
|
8 |
+
InterLauncher("Demo", demo, listen=2000)
|
backend/src/example/data/labels.txt
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
airplane
|
2 |
+
alarm_clock
|
3 |
+
anvil
|
4 |
+
apple
|
5 |
+
axe
|
6 |
+
baseball
|
7 |
+
baseball_bat
|
8 |
+
basketball
|
9 |
+
beard
|
10 |
+
bed
|
11 |
+
bench
|
12 |
+
bicycle
|
13 |
+
bird
|
14 |
+
book
|
15 |
+
bread
|
16 |
+
bridge
|
17 |
+
broom
|
18 |
+
butterfly
|
19 |
+
camera
|
20 |
+
candle
|
21 |
+
car
|
22 |
+
cat
|
23 |
+
ceiling_fan
|
24 |
+
cell_phone
|
25 |
+
chair
|
26 |
+
circle
|
27 |
+
clock
|
28 |
+
cloud
|
29 |
+
coffee_cup
|
30 |
+
cookie
|
31 |
+
cup
|
32 |
+
diving_board
|
33 |
+
donut
|
34 |
+
door
|
35 |
+
drums
|
36 |
+
dumbbell
|
37 |
+
envelope
|
38 |
+
eye
|
39 |
+
eyeglasses
|
40 |
+
face
|
41 |
+
fan
|
42 |
+
flower
|
43 |
+
frying_pan
|
44 |
+
grapes
|
45 |
+
hammer
|
46 |
+
hat
|
47 |
+
headphones
|
48 |
+
helmet
|
49 |
+
hot_dog
|
50 |
+
ice_cream
|
51 |
+
key
|
52 |
+
knife
|
53 |
+
ladder
|
54 |
+
laptop
|
55 |
+
light_bulb
|
56 |
+
lightning
|
57 |
+
line
|
58 |
+
lollipop
|
59 |
+
microphone
|
60 |
+
moon
|
61 |
+
mountain
|
62 |
+
moustache
|
63 |
+
mushroom
|
64 |
+
pants
|
65 |
+
paper_clip
|
66 |
+
pencil
|
67 |
+
pillow
|
68 |
+
pizza
|
69 |
+
power_outlet
|
70 |
+
radio
|
71 |
+
rainbow
|
72 |
+
rifle
|
73 |
+
saw
|
74 |
+
scissors
|
75 |
+
screwdriver
|
76 |
+
shorts
|
77 |
+
shovel
|
78 |
+
smiley_face
|
79 |
+
snake
|
80 |
+
sock
|
81 |
+
spider
|
82 |
+
spoon
|
83 |
+
square
|
84 |
+
star
|
85 |
+
stop_sign
|
86 |
+
suitcase
|
87 |
+
sun
|
88 |
+
sword
|
89 |
+
syringe
|
90 |
+
t-shirt
|
91 |
+
table
|
92 |
+
tennis_racquet
|
93 |
+
tent
|
94 |
+
tooth
|
95 |
+
traffic_light
|
96 |
+
tree
|
97 |
+
triangle
|
98 |
+
umbrella
|
99 |
+
wheel
|
100 |
+
wristwatch
|
backend/src/example/data/pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:effb6ea6f1593c09e8247944028ed9c309b5ff1cef82ba38b822bee2ca4d0f3c
|
3 |
+
size 1656903
|
backend/src/example/examples.py
CHANGED
@@ -1,19 +1,23 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import matplotlib
|
3 |
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
4 |
import numpy as np
|
5 |
import PIL
|
6 |
-
from helper.compiler import GradioCompiler, register
|
7 |
|
|
|
|
|
8 |
|
9 |
|
10 |
-
|
11 |
-
@gradio_compile
|
12 |
class Pictionary:
|
13 |
|
14 |
-
def __init__(self) -> None:
|
15 |
-
self.LABELS = Path(
|
16 |
-
|
17 |
self.model = nn.Sequential(
|
18 |
nn.Conv2d(1, 32, 3, padding='same'),
|
19 |
nn.ReLU(),
|
@@ -29,11 +33,11 @@ class Pictionary:
|
|
29 |
nn.ReLU(),
|
30 |
nn.Linear(256, len(self.LABELS)),
|
31 |
)
|
32 |
-
state_dict = torch.load(
|
33 |
self.model.load_state_dict(state_dict, strict=False)
|
34 |
self.model.eval()
|
35 |
|
36 |
-
@register(inputs="sketchpad", outputs=gr.Label())
|
37 |
def perdict(self, img) -> 'dict[str, float]':
|
38 |
if type(img) == type(None): return {}
|
39 |
x = torch.tensor(img, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.
|
@@ -43,9 +47,8 @@ class Pictionary:
|
|
43 |
values, indices = torch.topk(probabilities, 5)
|
44 |
confidences = {self.LABELS[i]: v.item() for i, v in zip(indices, values)}
|
45 |
return confidences
|
46 |
-
"""
|
47 |
|
48 |
-
@
|
49 |
class HelloWorld_2_0:
|
50 |
|
51 |
@register(inputs=["text", "text", gr.Radio(["morning", "evening", "night"])], outputs="text")
|
@@ -65,14 +68,14 @@ class HelloWorld_2_0:
|
|
65 |
|
66 |
|
67 |
|
68 |
-
@
|
69 |
class FSD:
|
70 |
|
71 |
def get_new_val(self, old_val, nc):
|
72 |
return np.round(old_val * (nc - 1)) / (nc - 1)
|
73 |
|
74 |
|
75 |
-
def palette_reduce(self, img : PIL.Image.Image, nc
|
76 |
pixels = np.array(img, dtype=float) / 255
|
77 |
pixels = self.get_new_val(pixels, nc)
|
78 |
|
@@ -80,7 +83,7 @@ class FSD:
|
|
80 |
return PIL.Image.fromarray(carr)
|
81 |
|
82 |
@register(inputs=[gr.Image(), gr.Slider(0.00, 16)], outputs=gr.Gallery())
|
83 |
-
def Floyd_Steinberg_dithering(self, img, nc
|
84 |
pixels = np.array(img, dtype=float) / 255
|
85 |
new_height, new_width, _ = img.shape
|
86 |
for row in range(new_height):
|
@@ -100,19 +103,7 @@ class FSD:
|
|
100 |
carr = np.array(pixels / np.max(pixels, axis=(0, 1)) * 255, dtype=np.uint8)
|
101 |
return [PIL.Image.fromarray(carr), self.palette_reduce(img, nc) ]
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
@GradioCompiler
|
106 |
-
class C:
|
107 |
-
|
108 |
-
def Hello(self):
|
109 |
-
return "Hello"
|
110 |
-
|
111 |
-
@register(inputs="text", outputs="text")
|
112 |
-
def Greeting(self, name):
|
113 |
-
return self.Hello() + " " + name
|
114 |
-
|
115 |
-
@GradioCompiler
|
116 |
class stock_forecast:
|
117 |
|
118 |
def __init__(self):
|
|
|
1 |
import gradio as gr
|
2 |
+
import sys
|
3 |
import matplotlib
|
4 |
import matplotlib.pyplot as plt
|
5 |
+
from pathlib import Path
|
6 |
+
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 |
|
18 |
+
def __init__(self, txt, model) -> None:
|
19 |
+
self.LABELS = Path(txt).read_text().splitlines()
|
20 |
+
print(txt, model)
|
21 |
self.model = nn.Sequential(
|
22 |
nn.Conv2d(1, 32, 3, padding='same'),
|
23 |
nn.ReLU(),
|
|
|
33 |
nn.ReLU(),
|
34 |
nn.Linear(256, len(self.LABELS)),
|
35 |
)
|
36 |
+
state_dict = torch.load(model, map_location='cpu')
|
37 |
self.model.load_state_dict(state_dict, strict=False)
|
38 |
self.model.eval()
|
39 |
|
40 |
+
@register(inputs="sketchpad", outputs=gr.Label(), examples=None, live=True)
|
41 |
def perdict(self, img) -> 'dict[str, float]':
|
42 |
if type(img) == type(None): return {}
|
43 |
x = torch.tensor(img, dtype=torch.float32).unsqueeze(0).unsqueeze(0) / 255.
|
|
|
47 |
values, indices = torch.topk(probabilities, 5)
|
48 |
confidences = {self.LABELS[i]: v.item() for i, v in zip(indices, values)}
|
49 |
return confidences
|
|
|
50 |
|
51 |
+
@GradioModule
|
52 |
class HelloWorld_2_0:
|
53 |
|
54 |
@register(inputs=["text", "text", gr.Radio(["morning", "evening", "night"])], outputs="text")
|
|
|
68 |
|
69 |
|
70 |
|
71 |
+
@GradioModule
|
72 |
class FSD:
|
73 |
|
74 |
def get_new_val(self, old_val, nc):
|
75 |
return np.round(old_val * (nc - 1)) / (nc - 1)
|
76 |
|
77 |
|
78 |
+
def palette_reduce(self, img : PIL.Image.Image, nc):
|
79 |
pixels = np.array(img, dtype=float) / 255
|
80 |
pixels = self.get_new_val(pixels, nc)
|
81 |
|
|
|
83 |
return PIL.Image.fromarray(carr)
|
84 |
|
85 |
@register(inputs=[gr.Image(), gr.Slider(0.00, 16)], outputs=gr.Gallery())
|
86 |
+
def Floyd_Steinberg_dithering(self, img, nc ):
|
87 |
pixels = np.array(img, dtype=float) / 255
|
88 |
new_height, new_width, _ = img.shape
|
89 |
for row in range(new_height):
|
|
|
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 |
|
109 |
def __init__(self):
|
backend/src/resources/__pycache__/module.cpython-39.pyc
CHANGED
Binary files a/backend/src/resources/__pycache__/module.cpython-39.pyc and b/backend/src/resources/__pycache__/module.cpython-39.pyc differ
|
|
backend/src/resources/module.py
CHANGED
@@ -9,7 +9,7 @@ class Dock:
|
|
9 |
|
10 |
def __init__(self) -> None:
|
11 |
self.num_ports = 20
|
12 |
-
self.port_range = (
|
13 |
|
14 |
def portConnection(self, port : int):
|
15 |
s = socket.socket(
|
@@ -18,10 +18,11 @@ class Dock:
|
|
18 |
if result == 0: return True
|
19 |
return False
|
20 |
|
21 |
-
def determinePort(self, max_trial_count=
|
22 |
trial_count = 0
|
23 |
while trial_count <= max_trial_count:
|
24 |
port=random.randint(*self.port_range)
|
|
|
25 |
if not self.portConnection(port):
|
26 |
return port
|
27 |
trial_count += 1
|
@@ -31,6 +32,41 @@ class Dock:
|
|
31 |
DOCKER_LOCAL_HOST = '0.0.0.0'
|
32 |
DOCKER_PORT = Dock()
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
def tabularGradio(funcs, names, name="Tabular Temp Name", **kwargs):
|
35 |
"""
|
36 |
takes all gradio Interfaces, and names
|
@@ -153,14 +189,15 @@ def register(inputs, outputs, examples=None, **kwargs):
|
|
153 |
allow_flagging=kwargs['allow_flagging'] if "allow_flagging" in kwargs else None,
|
154 |
theme='default',
|
155 |
)
|
|
|
156 |
return decorator
|
157 |
return register_gradio
|
158 |
|
159 |
def GradioModule(cls):
|
160 |
class Decorator:
|
161 |
|
162 |
-
def __init__(self) -> None:
|
163 |
-
self.__cls__ = cls()
|
164 |
self.__get_funcs_attr()
|
165 |
self.interface = self.__compile()
|
166 |
|
@@ -175,7 +212,9 @@ def GradioModule(cls):
|
|
175 |
def __get_funcs_attr(self):
|
176 |
for func in dir(self.__cls__):
|
177 |
fn = getattr(self.__cls__, func, None)
|
178 |
-
|
|
|
|
|
179 |
fn()
|
180 |
|
181 |
def __compile(self):
|
|
|
9 |
|
10 |
def __init__(self) -> None:
|
11 |
self.num_ports = 20
|
12 |
+
self.port_range = (3002, 8000)
|
13 |
|
14 |
def portConnection(self, port : int):
|
15 |
s = socket.socket(
|
|
|
18 |
if result == 0: return True
|
19 |
return False
|
20 |
|
21 |
+
def determinePort(self, max_trial_count=20):
|
22 |
trial_count = 0
|
23 |
while trial_count <= max_trial_count:
|
24 |
port=random.randint(*self.port_range)
|
25 |
+
print(port)
|
26 |
if not self.portConnection(port):
|
27 |
return port
|
28 |
trial_count += 1
|
|
|
32 |
DOCKER_LOCAL_HOST = '0.0.0.0'
|
33 |
DOCKER_PORT = Dock()
|
34 |
|
35 |
+
def InterLauncher(name, interface, listen=2000, **kwargs):
|
36 |
+
port= kwargs["port"] if "port" in kwargs else DOCKER_PORT.determinePort()
|
37 |
+
print(listen)
|
38 |
+
try:
|
39 |
+
requests.post(f"http://{DOCKER_LOCAL_HOST}:{listen}/api/append/port", json={"port" : port, "host" : f'http://localhost:{port}', "file" : "Not Applicable", "name" : {name}, "kwargs" : kwargs})
|
40 |
+
except Exception as e:
|
41 |
+
print(f"**{bcolor.BOLD}{bcolor.FAIL}CONNECTION ERROR{bcolor.ENDC}** 🐛The listening api is either not up or you choose the wrong port.🐛 \n {e}")
|
42 |
+
return
|
43 |
+
|
44 |
+
interface.launch(server_port=port,
|
45 |
+
server_name=f"{DOCKER_LOCAL_HOST}",
|
46 |
+
inline= kwargs['inline'] if "inline" in kwargs else True,
|
47 |
+
share=kwargs['share'] if "share" in kwargs else None,
|
48 |
+
debug=kwargs['debug'] if "debug" in kwargs else False,
|
49 |
+
enable_queue=kwargs['enable_queue'] if "enable_queue" in kwargs else None,
|
50 |
+
max_threads=kwargs['max_threads'] if "max_threads" in kwargs else None,
|
51 |
+
auth=kwargs['auth'] if "auth" in kwargs else None,
|
52 |
+
auth_message=kwargs['auth_message'] if "auth_message" in kwargs else None,
|
53 |
+
prevent_thread_lock=kwargs['prevent_thread_lock'] if "prevent_thread_lock" in kwargs else False,
|
54 |
+
show_error=kwargs['show_error'] if "show_error" in kwargs else True,
|
55 |
+
show_tips=kwargs['show_tips'] if "show_tips" in kwargs else False,
|
56 |
+
height=kwargs['height'] if "height" in kwargs else 500,
|
57 |
+
width=kwargs['width'] if "width" in kwargs else 900,
|
58 |
+
encrypt=kwargs['encrypt'] if "encrypt" in kwargs else False,
|
59 |
+
favicon_path=kwargs['favicon_path'] if "favicon_path" in kwargs else None,
|
60 |
+
ssl_keyfile=kwargs['ssl_keyfile'] if "ssl_keyfile" in kwargs else None,
|
61 |
+
ssl_certfile=kwargs['ssl_certfile'] if "ssl_certfile" in kwargs else None,
|
62 |
+
ssl_keyfile_password=kwargs['ssl_keyfile_password'] if "ssl_keyfile_password" in kwargs else None,
|
63 |
+
quiet=kwargs['quiet'] if "quiet" in kwargs else False)
|
64 |
+
|
65 |
+
try:
|
66 |
+
requests.post(f"http://{DOCKER_LOCAL_HOST}:{ listen }/api/remove/port", json={"port" : port, "host" : f'http://localhost:{port}', "file" : 'Not Applicable', "name" : name, "kwargs" : kwargs})
|
67 |
+
except Exception as e:
|
68 |
+
print(f"**{bcolor.BOLD}{bcolor.FAIL}CONNECTION ERROR{bcolor.ENDC}** 🐛The api either lost connection or was turned off...🐛 \n {e}")
|
69 |
+
|
70 |
def tabularGradio(funcs, names, name="Tabular Temp Name", **kwargs):
|
71 |
"""
|
72 |
takes all gradio Interfaces, and names
|
|
|
189 |
allow_flagging=kwargs['allow_flagging'] if "allow_flagging" in kwargs else None,
|
190 |
theme='default',
|
191 |
)
|
192 |
+
decorator.__decorator__ = "__gradio__"
|
193 |
return decorator
|
194 |
return register_gradio
|
195 |
|
196 |
def GradioModule(cls):
|
197 |
class Decorator:
|
198 |
|
199 |
+
def __init__(self, *args, **kwargs) -> None:
|
200 |
+
self.__cls__ = cls(*args, **kwargs)
|
201 |
self.__get_funcs_attr()
|
202 |
self.interface = self.__compile()
|
203 |
|
|
|
212 |
def __get_funcs_attr(self):
|
213 |
for func in dir(self.__cls__):
|
214 |
fn = getattr(self.__cls__, func, None)
|
215 |
+
|
216 |
+
if callable(fn) and not func.startswith("__") and "__decorator__" in dir(fn) and fn.__decorator__ == "__gradio__":
|
217 |
+
print(func, callable(fn))
|
218 |
fn()
|
219 |
|
220 |
def __compile(self):
|
frontend/public/index.html
CHANGED
@@ -35,7 +35,27 @@
|
|
35 |
</head>
|
36 |
<body>
|
37 |
<noscript>You need to enable JavaScript to run this app.</noscript>
|
38 |
-
<div id="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
<!--
|
40 |
This HTML file is a template.
|
41 |
If you open it directly in the browser, you will see an empty page.
|
|
|
35 |
</head>
|
36 |
<body>
|
37 |
<noscript>You need to enable JavaScript to run this app.</noscript>
|
38 |
+
<div id="Gradio-Flow"></div>
|
39 |
+
<script>
|
40 |
+
var frame = document.getElementById("Iframe");
|
41 |
+
|
42 |
+
frame.onload = function()
|
43 |
+
// function execute while load the iframe
|
44 |
+
|
45 |
+
{
|
46 |
+
// set the height of the iframe as
|
47 |
+
// the height of the iframe content
|
48 |
+
frame.style.height =
|
49 |
+
frame.contentWindow.document.body.scrollHeight + 'px';
|
50 |
+
console.log(frame.contentWindow.document.body.scrollHeight)
|
51 |
+
|
52 |
+
// set the width of the iframe as the
|
53 |
+
// width of the iframe content
|
54 |
+
frame.style.width =
|
55 |
+
frame.contentWindow.document.body.scrollWidth+'px';
|
56 |
+
|
57 |
+
}
|
58 |
+
</script>
|
59 |
<!--
|
60 |
This HTML file is a template.
|
61 |
If you open it directly in the browser, you will see an empty page.
|
frontend/src/Components/Navagation/navbar.js
CHANGED
@@ -202,7 +202,7 @@ export default class Navbar extends Component{
|
|
202 |
</div>
|
203 |
|
204 |
<div className={`rounded-md text-center ${this.state.open ? "" : "px-0"} py-3`} onClick={() => {this.handelModal(true)}}>
|
205 |
-
<div className={` text-center bg-transparent w-full h-10 border border-slate-300 hover:border-
|
206 |
<Icon className=" block mr-auto ml-auto" name="plus"/>
|
207 |
</div>
|
208 |
</div>
|
|
|
202 |
</div>
|
203 |
|
204 |
<div className={`rounded-md text-center ${this.state.open ? "" : "px-0"} py-3`} onClick={() => {this.handelModal(true)}}>
|
205 |
+
<div className={` text-center bg-transparent w-full h-10 border border-slate-300 hover:border-Retro-purple hover:animate-pulse border-dashed rounded-md py-2 pl-5 ${this.state.open ? "pr-3" : "hidden"} shadow-sm sm:text-sm`}>
|
206 |
<Icon className=" block mr-auto ml-auto" name="plus"/>
|
207 |
</div>
|
208 |
</div>
|
frontend/src/Components/Nodes/custom.js
CHANGED
@@ -22,14 +22,15 @@ import React from "react"
|
|
22 |
render(){
|
23 |
|
24 |
console.log(this.state.reachable)
|
|
|
25 |
|
26 |
return (
|
27 |
<>
|
28 |
{ this.state.selected && this.state.reachable ?
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
<>
|
34 |
<div className='break-words'>
|
35 |
<div className=' h-auto text-center pointer-events-none'>
|
|
|
22 |
render(){
|
23 |
|
24 |
console.log(this.state.reachable)
|
25 |
+
var frame = document.getElementById("Iframe");
|
26 |
|
27 |
return (
|
28 |
<>
|
29 |
{ this.state.selected && this.state.reachable ?
|
30 |
+
<div className='relative h-[540px] w-[600px] overflow-hidden m-0 p-0' onClick={()=>this.handelSelected()}>
|
31 |
+
<div className={`absolute h-full w-full ${this.state.data.colour} border-1shadow-2xl shadow-black rounded-xl -z-10`}></div>
|
32 |
+
<iframe src={this.state.data.host} title={this.state.data.label} frameBorder={0} allowFullScreen className=" h-full w-full p-2 overflow-y-scroll"></iframe>
|
33 |
+
</div>:
|
34 |
<>
|
35 |
<div className='break-words'>
|
36 |
<div className=' h-auto text-center pointer-events-none'>
|
frontend/src/Components/ReactFlow/ReactFlowEnv.js
CHANGED
@@ -71,8 +71,8 @@ export default function ReactEnviorment() {
|
|
71 |
|
72 |
return (
|
73 |
<>
|
74 |
-
<div className=' absolute top-4 right-5 z-50' >
|
75 |
-
<h1 className='text-
|
76 |
</div>
|
77 |
<div className={`flex h-screen w-screen ${theme} transition-all`}>
|
78 |
<Navbar/>
|
|
|
71 |
|
72 |
return (
|
73 |
<>
|
74 |
+
<div className=' absolute top-4 right-5 z-50' onClick={()=> setTheme(theme === "" ? "dark" : "")}>
|
75 |
+
<h1 className='text-4xl' >{theme === "dark" ? '🌙' : '☀️'}</h1>
|
76 |
</div>
|
77 |
<div className={`flex h-screen w-screen ${theme} transition-all`}>
|
78 |
<Navbar/>
|
frontend/src/css/dist/output.css
CHANGED
@@ -570,14 +570,6 @@ video {
|
|
570 |
bottom: 0px;
|
571 |
}
|
572 |
|
573 |
-
.top-4 {
|
574 |
-
top: 1rem;
|
575 |
-
}
|
576 |
-
|
577 |
-
.right-5 {
|
578 |
-
right: 1.25rem;
|
579 |
-
}
|
580 |
-
|
581 |
.-right-3 {
|
582 |
right: -0.75rem;
|
583 |
}
|
@@ -594,14 +586,26 @@ video {
|
|
594 |
bottom: 0px;
|
595 |
}
|
596 |
|
597 |
-
.
|
598 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
599 |
}
|
600 |
|
601 |
.z-10 {
|
602 |
z-index: 10;
|
603 |
}
|
604 |
|
|
|
|
|
|
|
|
|
605 |
.-z-10 {
|
606 |
z-index: -10;
|
607 |
}
|
@@ -666,14 +670,26 @@ video {
|
|
666 |
height: auto;
|
667 |
}
|
668 |
|
669 |
-
.h-\[540px\] {
|
670 |
-
height: 540px;
|
671 |
-
}
|
672 |
-
|
673 |
.h-full {
|
674 |
height: 100%;
|
675 |
}
|
676 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
677 |
.w-10 {
|
678 |
width: 2.5rem;
|
679 |
}
|
@@ -682,14 +698,30 @@ video {
|
|
682 |
width: 100%;
|
683 |
}
|
684 |
|
685 |
-
.w-\[
|
686 |
-
width:
|
|
|
|
|
|
|
|
|
687 |
}
|
688 |
|
689 |
.w-screen {
|
690 |
width: 100vw;
|
691 |
}
|
692 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
693 |
.flex-1 {
|
694 |
flex: 1 1 0%;
|
695 |
}
|
@@ -704,6 +736,10 @@ video {
|
|
704 |
cursor: pointer;
|
705 |
}
|
706 |
|
|
|
|
|
|
|
|
|
707 |
.items-center {
|
708 |
align-items: center;
|
709 |
}
|
@@ -748,6 +784,10 @@ video {
|
|
748 |
border-style: dashed;
|
749 |
}
|
750 |
|
|
|
|
|
|
|
|
|
751 |
.border-black {
|
752 |
--tw-border-opacity: 1;
|
753 |
border-color: rgb(0 0 0 / var(--tw-border-opacity));
|
@@ -900,6 +940,14 @@ video {
|
|
900 |
padding-top: 0.5rem;
|
901 |
}
|
902 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
903 |
.text-left {
|
904 |
text-align: left;
|
905 |
}
|
@@ -912,11 +960,6 @@ video {
|
|
912 |
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
913 |
}
|
914 |
|
915 |
-
.text-3xl {
|
916 |
-
font-size: 1.875rem;
|
917 |
-
line-height: 2.25rem;
|
918 |
-
}
|
919 |
-
|
920 |
.text-sm {
|
921 |
font-size: 0.875rem;
|
922 |
line-height: 1.25rem;
|
@@ -932,11 +975,26 @@ video {
|
|
932 |
line-height: 1.5rem;
|
933 |
}
|
934 |
|
|
|
|
|
|
|
|
|
|
|
935 |
.text-lg {
|
936 |
font-size: 1.125rem;
|
937 |
line-height: 1.75rem;
|
938 |
}
|
939 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
940 |
.font-medium {
|
941 |
font-weight: 500;
|
942 |
}
|
@@ -1026,6 +1084,16 @@ video {
|
|
1026 |
border-color: rgb(14 165 233 / var(--tw-border-opacity));
|
1027 |
}
|
1028 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1029 |
.focus\:border-sky-500:focus {
|
1030 |
--tw-border-opacity: 1;
|
1031 |
border-color: rgb(14 165 233 / var(--tw-border-opacity));
|
@@ -1077,14 +1145,6 @@ video {
|
|
1077 |
width: 15rem;
|
1078 |
}
|
1079 |
|
1080 |
-
.sm\:w-\[250pxs\] {
|
1081 |
-
width: 250pxs;
|
1082 |
-
}
|
1083 |
-
|
1084 |
-
.sm\:w-\[250px\] {
|
1085 |
-
width: 250px;
|
1086 |
-
}
|
1087 |
-
|
1088 |
.sm\:text-sm {
|
1089 |
font-size: 0.875rem;
|
1090 |
line-height: 1.25rem;
|
|
|
570 |
bottom: 0px;
|
571 |
}
|
572 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
.-right-3 {
|
574 |
right: -0.75rem;
|
575 |
}
|
|
|
586 |
bottom: 0px;
|
587 |
}
|
588 |
|
589 |
+
.top-0 {
|
590 |
+
top: 0px;
|
591 |
+
}
|
592 |
+
|
593 |
+
.top-4 {
|
594 |
+
top: 1rem;
|
595 |
+
}
|
596 |
+
|
597 |
+
.right-5 {
|
598 |
+
right: 1.25rem;
|
599 |
}
|
600 |
|
601 |
.z-10 {
|
602 |
z-index: 10;
|
603 |
}
|
604 |
|
605 |
+
.z-50 {
|
606 |
+
z-index: 50;
|
607 |
+
}
|
608 |
+
|
609 |
.-z-10 {
|
610 |
z-index: -10;
|
611 |
}
|
|
|
670 |
height: auto;
|
671 |
}
|
672 |
|
|
|
|
|
|
|
|
|
673 |
.h-full {
|
674 |
height: 100%;
|
675 |
}
|
676 |
|
677 |
+
.h-\[95\%\] {
|
678 |
+
height: 95%;
|
679 |
+
}
|
680 |
+
|
681 |
+
.h-\[500px\] {
|
682 |
+
height: 500px;
|
683 |
+
}
|
684 |
+
|
685 |
+
.h-\[300px\] {
|
686 |
+
height: 300px;
|
687 |
+
}
|
688 |
+
|
689 |
+
.h-\[540px\] {
|
690 |
+
height: 540px;
|
691 |
+
}
|
692 |
+
|
693 |
.w-10 {
|
694 |
width: 2.5rem;
|
695 |
}
|
|
|
698 |
width: 100%;
|
699 |
}
|
700 |
|
701 |
+
.w-\[1000px\] {
|
702 |
+
width: 1000px;
|
703 |
+
}
|
704 |
+
|
705 |
+
.w-\[95\%\] {
|
706 |
+
width: 95%;
|
707 |
}
|
708 |
|
709 |
.w-screen {
|
710 |
width: 100vw;
|
711 |
}
|
712 |
|
713 |
+
.w-\[900px\] {
|
714 |
+
width: 900px;
|
715 |
+
}
|
716 |
+
|
717 |
+
.w-\[800px\] {
|
718 |
+
width: 800px;
|
719 |
+
}
|
720 |
+
|
721 |
+
.w-\[600px\] {
|
722 |
+
width: 600px;
|
723 |
+
}
|
724 |
+
|
725 |
.flex-1 {
|
726 |
flex: 1 1 0%;
|
727 |
}
|
|
|
736 |
cursor: pointer;
|
737 |
}
|
738 |
|
739 |
+
.resize {
|
740 |
+
resize: both;
|
741 |
+
}
|
742 |
+
|
743 |
.items-center {
|
744 |
align-items: center;
|
745 |
}
|
|
|
784 |
border-style: dashed;
|
785 |
}
|
786 |
|
787 |
+
.border-none {
|
788 |
+
border-style: none;
|
789 |
+
}
|
790 |
+
|
791 |
.border-black {
|
792 |
--tw-border-opacity: 1;
|
793 |
border-color: rgb(0 0 0 / var(--tw-border-opacity));
|
|
|
940 |
padding-top: 0.5rem;
|
941 |
}
|
942 |
|
943 |
+
.pt-\[56\.25\%\] {
|
944 |
+
padding-top: 56.25%;
|
945 |
+
}
|
946 |
+
|
947 |
+
.pt-\[57\.25\%\] {
|
948 |
+
padding-top: 57.25%;
|
949 |
+
}
|
950 |
+
|
951 |
.text-left {
|
952 |
text-align: left;
|
953 |
}
|
|
|
960 |
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
961 |
}
|
962 |
|
|
|
|
|
|
|
|
|
|
|
963 |
.text-sm {
|
964 |
font-size: 0.875rem;
|
965 |
line-height: 1.25rem;
|
|
|
975 |
line-height: 1.5rem;
|
976 |
}
|
977 |
|
978 |
+
.text-3xl {
|
979 |
+
font-size: 1.875rem;
|
980 |
+
line-height: 2.25rem;
|
981 |
+
}
|
982 |
+
|
983 |
.text-lg {
|
984 |
font-size: 1.125rem;
|
985 |
line-height: 1.75rem;
|
986 |
}
|
987 |
|
988 |
+
.text-4xl {
|
989 |
+
font-size: 2.25rem;
|
990 |
+
line-height: 2.5rem;
|
991 |
+
}
|
992 |
+
|
993 |
+
.text-5xl {
|
994 |
+
font-size: 3rem;
|
995 |
+
line-height: 1;
|
996 |
+
}
|
997 |
+
|
998 |
.font-medium {
|
999 |
font-weight: 500;
|
1000 |
}
|
|
|
1084 |
border-color: rgb(14 165 233 / var(--tw-border-opacity));
|
1085 |
}
|
1086 |
|
1087 |
+
.hover\:border-Retro-purple:hover {
|
1088 |
+
--tw-border-opacity: 1;
|
1089 |
+
border-color: rgb(151 0 204 / var(--tw-border-opacity));
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
.hover\:border-l-Retro-purple:hover {
|
1093 |
+
--tw-border-opacity: 1;
|
1094 |
+
border-left-color: rgb(151 0 204 / var(--tw-border-opacity));
|
1095 |
+
}
|
1096 |
+
|
1097 |
.focus\:border-sky-500:focus {
|
1098 |
--tw-border-opacity: 1;
|
1099 |
border-color: rgb(14 165 233 / var(--tw-border-opacity));
|
|
|
1145 |
width: 15rem;
|
1146 |
}
|
1147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1148 |
.sm\:text-sm {
|
1149 |
font-size: 0.875rem;
|
1150 |
line-height: 1.25rem;
|
frontend/src/css/iframe.css
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.Iframe_class{
|
2 |
+
position: absolute;
|
3 |
+
width: 100%!important;
|
4 |
+
height: 100%!important;
|
5 |
+
}
|
frontend/src/index.js
CHANGED
@@ -5,7 +5,7 @@ import App from './App';
|
|
5 |
//import Navbar from './Components/Navagation/navbar';
|
6 |
import reportWebVitals from './reportWebVitals';
|
7 |
|
8 |
-
const root = ReactDOM.createRoot(document.getElementById('
|
9 |
root.render(
|
10 |
<React.StrictMode>
|
11 |
< App/>
|
|
|
5 |
//import Navbar from './Components/Navagation/navbar';
|
6 |
import reportWebVitals from './reportWebVitals';
|
7 |
|
8 |
+
const root = ReactDOM.createRoot(document.getElementById('Gradio-Flow'));
|
9 |
root.render(
|
10 |
<React.StrictMode>
|
11 |
< App/>
|