-
Notifications
You must be signed in to change notification settings - Fork 2
/
model_app.py
224 lines (166 loc) · 5.13 KB
/
model_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
### Import packages
import os
from pathlib import Path
import base64
import numpy as np
import graphviz
from PIL import Image, ImageDraw, ImageFont
from htbuilder import HtmlElement, div, ul, li, br, hr, a, p, img, styles, classes, fonts
from htbuilder.units import percent, px
from htbuilder.funcs import rgba, rgb
import streamlit as st
from class_game import *
from back_end_CS import *
from front_end_CS import *
global page
st.set_page_config(
page_title="Agent Theory", layout="wide", page_icon="images/flask.png"
)
### methods used within streamlit - to organize later on
def img_to_bytes(img_path):
img_bytes = Path(img_path).read_bytes()
encoded = base64.b64encode(img_bytes).decode()
return encoded
###Cases Studies
def display_page(page):
if page==2:
display_MCMAS()
elif page==3:
display_MS()
else:
nlp_steps = st.selectbox(' ', ['01 - Initialization',
'02 - Strategy Example', '03 - ICGS','04 - Dining Cryptographers',
'05 - Buchi Automaton', '06 - Upload Configuration'])
display_case(nlp_steps)
### Main Front
def main():
def _max_width_():
max_width_str = f"max-width: 1000px;"
st.markdown(
f"""
<style>
.reportview-container .main .block-container{{
{max_width_str}
}}
</style>
""",
unsafe_allow_html=True,
)
# Hide the Streamlit header and footer
def hide_header_footer():
hide_streamlit_style = """
<style>
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
# increases the width of the text and tables/figures
_max_width_()
# hide the footer
hide_header_footer()
st.markdown("# VITAMIN 🔍 🖥")
st.subheader(
"""
VerIficaTion viA MultI ageNt system 🧪
"""
)
st.markdown(" ")
selected_indices = []
index_review = 0
st.markdown(
"""
[<img src='data:image/png;base64,{}' class='img-fluid' width=25 height=25>](https://github.com/hi-paris/agent-theory) <small> agent-theory 0.0.1 | September 2022</small>""".format(
img_to_bytes("./images/github.png")
),
unsafe_allow_html=True,
)
#Useful Session State
if 'info_model' not in st.session_state:
st.session_state.info_model=[]
if 'cmpt_model' not in st.session_state:
st.session_state.cmpt_model=0
if 'page' not in st.session_state:
st.session_state.page=1
st.sidebar.header("Dashboard")
st.sidebar.markdown("---")
if st.sidebar.button('Cases Studies'):
st.session_state.page=1
if st.sidebar.button('Part for Devlopement '):
st.session_state.page=2
st.session_state.cmpt_model=-1
st.session_state.info_model_test=[]
if st.sidebar.button('Model Cheking for MAS'):
st.session_state.cmpt_model=0
st.session_state.info_model=[]
st.session_state.mat_transi=[]
st.session_state.page=3
display_page(st.session_state.page)
if __name__=='__main__':
main()
st.markdown(" ")
st.markdown("### ** 👨🏼💻 Télécom Paris Researcher: **")
st.image(['images/1.png'], width=230,caption=["Vadim Malvone"])
st.markdown('### Made by Hi!Paris')
images = Image.open('./images/hi-paris.png')
st.image(images, width=250)
st.write(' ')
st.markdown('### Contributors:')
PA=Image.open('./images/PA.jpg')
Pierre=Image.open('./images/Pierre.jpg')
GAE=Image.open('./images/gaetan.png')
st.image([PA,GAE,Pierre],width=110)
st.markdown(f"#### Link to Project Website [here]({'https://github.com/hi-paris/agent-theory'}) 🚀 ")
def image(src_as_string, **style):
return img(src=src_as_string, style=styles(**style))
def link(link, text, **style):
return a(_href=link, _target="_blank", style=styles(**style))(text)
def layout(*args):
style = """
<style>
# MainMenu {visibility: hidden;}
footer {visibility: hidden;background - color: white}
.stApp { bottom: 80px; }
</style>
"""
style_div = styles(
position="fixed",
left=0,
bottom=0,
margin=px(0, 0, 0, 0),
width=percent(100),
color="black",
text_align="center",
height="auto",
opacity=1,
)
style_hr = styles(
display="block",
margin=px(8, 8, "auto", "auto"),
border_style="inset",
border_width=px(2)
)
body = p()
foot = div(
style=style_div
)(
hr(
style=style_hr
),
body
)
st.markdown(style, unsafe_allow_html=True)
for arg in args:
if isinstance(arg, str):
body(arg)
elif isinstance(arg, HtmlElement):
body(arg)
st.markdown(str(foot), unsafe_allow_html=True)
def footer2():
myargs = [
" Made by ",
link("https://engineeringteam.hi-paris.fr/", "Hi! PARIS Engineering Team"),
" 👩🏼💻 👨🏼💻"
]
layout(*myargs)
if __name__ == "__main__":
footer2()