Spaces:
Sleeping
Sleeping
Update my_model/utilities/st_utils.py
Browse files- my_model/utilities/st_utils.py +56 -15
my_model/utilities/st_utils.py
CHANGED
@@ -1,30 +1,71 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
class UIManager:
|
4 |
-
def __init__(self
|
5 |
-
self.
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
st.sidebar.title("Navigation")
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
def
|
12 |
st.title("MultiModal Learning for Knowledge-Based Visual Question Answering")
|
13 |
-
st.write("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
def display_dissertation_report(self):
|
16 |
st.title("Dissertation Report")
|
17 |
st.write("Click the link below to view the PDF.")
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
st.write("This is a Place Holder until the contents are uploaded.")
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
28 |
|
29 |
|
30 |
|
|
|
1 |
import streamlit as st
|
2 |
+
from my model.
|
3 |
|
4 |
class UIManager:
|
5 |
+
def __init__(self):
|
6 |
+
self.tabs = {
|
7 |
+
"Home": self.display_home,
|
8 |
+
"Dataset Analysis": self.display_dataset_analysis,
|
9 |
+
"Finetuning and Evaluation Results": self.display_finetuning_evaluation,
|
10 |
+
"Run Inference": self.display_run_inference,
|
11 |
+
"Dissertation Report": self.display_dissertation_report,
|
12 |
+
"Code": self.display_code,
|
13 |
+
"More Pages will follow .. ": self.display_placeholder
|
14 |
+
}
|
15 |
+
|
16 |
+
def add_tab(self, tab_name, display_function):
|
17 |
+
self.tabs[tab_name] = display_function
|
18 |
+
|
19 |
+
def display_sidebar(self):
|
20 |
st.sidebar.title("Navigation")
|
21 |
+
selection = st.sidebar.radio("Go to", list(self.tabs.keys()))
|
22 |
+
st.sidebar.write("More Pages will follow .. ")
|
23 |
+
return selection
|
24 |
+
|
25 |
+
def display_selected_page(self, selection):
|
26 |
+
if selection in self.tabs:
|
27 |
+
self.tabs[selection]()
|
28 |
|
29 |
+
def display_home(self):
|
30 |
st.title("MultiModal Learning for Knowledge-Based Visual Question Answering")
|
31 |
+
st.write("""This application is an interactive element of the project and prepared by Mohammed Alhaj as part of the dissertation for Masters degree in Artificial Intelligence at the University of Bath.
|
32 |
+
Further details will be updated later""")
|
33 |
+
|
34 |
+
def display_dataset_analysis(self):
|
35 |
+
st.title("OK-VQA Dataset Analysis")
|
36 |
+
st.write("This is a Place Holder until the contents are uploaded.")
|
37 |
+
|
38 |
+
def display_finetuning_evaluation(self):
|
39 |
+
st.title("Finetuning and Evaluation Results")
|
40 |
+
st.write("This is a Place Holder until the contents are uploaded.")
|
41 |
+
|
42 |
+
def display_run_inference(self):
|
43 |
+
|
44 |
+
run_inference()
|
45 |
|
46 |
def display_dissertation_report(self):
|
47 |
st.title("Dissertation Report")
|
48 |
st.write("Click the link below to view the PDF.")
|
49 |
+
st.download_button(
|
50 |
+
label="Download PDF",
|
51 |
+
data=open("Files/Dissertation Report.pdf", "rb"),
|
52 |
+
file_name="example.pdf",
|
53 |
+
mime="application/octet-stream"
|
54 |
+
)
|
55 |
+
|
56 |
+
def display_code(self):
|
57 |
+
st.title("Code")
|
58 |
+
st.markdown("You can view the code for this project on the Hugging Face Space file page.")
|
59 |
+
st.markdown("[View Code](https://huggingface.co/spaces/m7mdal7aj/Mohammed_Alhaj_PlayGround/tree/main)", unsafe_allow_html=True)
|
60 |
+
|
61 |
+
def display_placeholder(self):
|
62 |
+
st.title("Stay Tuned")
|
63 |
st.write("This is a Place Holder until the contents are uploaded.")
|
64 |
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
+
|
69 |
|
70 |
|
71 |
|