Spaces:
Running
Running
Update my_model/utilities/ui_manager.py
Browse files- my_model/utilities/ui_manager.py +16 -10
my_model/utilities/ui_manager.py
CHANGED
@@ -2,9 +2,11 @@ import pandas as pd
|
|
2 |
import streamlit as st
|
3 |
from my_model.tabs.run_inference import InferenceRunner
|
4 |
|
5 |
-
|
6 |
class UIManager:
|
|
|
|
|
7 |
def __init__(self):
|
|
|
8 |
self.tabs = {
|
9 |
"Home": self.display_home,
|
10 |
"Dataset Analysis": self.display_dataset_analysis,
|
@@ -16,42 +18,48 @@ class UIManager:
|
|
16 |
}
|
17 |
|
18 |
def add_tab(self, tab_name, display_function):
|
|
|
19 |
self.tabs[tab_name] = display_function
|
20 |
|
21 |
def display_sidebar(self):
|
|
|
22 |
st.sidebar.title("Navigation")
|
23 |
selection = st.sidebar.radio("Go to", list(self.tabs.keys()))
|
24 |
-
#st.sidebar.write("More Pages will follow .. ")
|
25 |
return selection
|
26 |
|
27 |
def display_selected_page(self, selection):
|
|
|
28 |
if selection in self.tabs:
|
29 |
self.tabs[selection]()
|
30 |
|
31 |
def display_home(self):
|
32 |
-
|
33 |
st.markdown("<h1 style='text-align: center;'>MultiModal Learning for Visual Question Answering using World Knowledge</h1>", unsafe_allow_html=True)
|
34 |
st.write(" ")
|
35 |
st.markdown("<h2 style='text-align: center;'>(Knowledge-Based Visual Question Answering)</h2>", unsafe_allow_html=True)
|
36 |
-
|
37 |
st.write("""\n\nThis application is an interactive element of the project prepared by [Mohammed H AlHaj](https://www.linkedin.com/in/m7mdal7aj) as part of the dissertation for Masters degree in Artificial Intelligence at the University of Bath under the supervision of [Mr. Andreas Theophilou](https://researchportal.bath.ac.uk/en/persons/andreas-theophilou).
|
38 |
\nFurther details will be updated later""")
|
39 |
|
40 |
def display_dataset_analysis(self):
|
|
|
41 |
st.title("OK-VQA Dataset Analysis")
|
42 |
st.write("This is a Place Holder until the contents are uploaded.")
|
43 |
|
44 |
def display_finetuning_evaluation(self):
|
|
|
45 |
st.title("Finetuning and Evaluation Results")
|
46 |
st.write("This is a Place Holder until the contents are uploaded.")
|
47 |
|
48 |
def display_run_inference(self):
|
|
|
49 |
inference_runner = InferenceRunner()
|
50 |
inference_runner.run_inference()
|
51 |
|
52 |
def display_dissertation_report(self):
|
|
|
53 |
st.title("Dissertation Report")
|
54 |
st.write("Click the link below to view the PDF.")
|
|
|
55 |
st.download_button(
|
56 |
label="Download PDF",
|
57 |
data=open("Files/Dissertation Report.pdf", "rb"),
|
@@ -60,15 +68,13 @@ class UIManager:
|
|
60 |
)
|
61 |
|
62 |
def display_code(self):
|
|
|
63 |
st.title("Code")
|
64 |
-
st.markdown("You can view the code for this project on the
|
|
|
65 |
st.markdown("[View Code](https://huggingface.co/spaces/m7mdal7aj/Mohammed_Alhaj_PlayGround/tree/main)", unsafe_allow_html=True)
|
66 |
|
67 |
def display_placeholder(self):
|
|
|
68 |
st.title("Stay Tuned")
|
69 |
st.write("This is a Place Holder until the contents are uploaded.")
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
2 |
import streamlit as st
|
3 |
from my_model.tabs.run_inference import InferenceRunner
|
4 |
|
|
|
5 |
class UIManager:
|
6 |
+
"""Manages the user interface for the Streamlit application."""
|
7 |
+
|
8 |
def __init__(self):
|
9 |
+
"""Initializes the UIManager with predefined tabs."""
|
10 |
self.tabs = {
|
11 |
"Home": self.display_home,
|
12 |
"Dataset Analysis": self.display_dataset_analysis,
|
|
|
18 |
}
|
19 |
|
20 |
def add_tab(self, tab_name, display_function):
|
21 |
+
"""Adds a new tab to the UI."""
|
22 |
self.tabs[tab_name] = display_function
|
23 |
|
24 |
def display_sidebar(self):
|
25 |
+
"""Displays the sidebar for navigation."""
|
26 |
st.sidebar.title("Navigation")
|
27 |
selection = st.sidebar.radio("Go to", list(self.tabs.keys()))
|
|
|
28 |
return selection
|
29 |
|
30 |
def display_selected_page(self, selection):
|
31 |
+
"""Displays the selected page based on user's choice."""
|
32 |
if selection in self.tabs:
|
33 |
self.tabs[selection]()
|
34 |
|
35 |
def display_home(self):
|
36 |
+
"""Displays the Home page of the application."""
|
37 |
st.markdown("<h1 style='text-align: center;'>MultiModal Learning for Visual Question Answering using World Knowledge</h1>", unsafe_allow_html=True)
|
38 |
st.write(" ")
|
39 |
st.markdown("<h2 style='text-align: center;'>(Knowledge-Based Visual Question Answering)</h2>", unsafe_allow_html=True)
|
|
|
40 |
st.write("""\n\nThis application is an interactive element of the project prepared by [Mohammed H AlHaj](https://www.linkedin.com/in/m7mdal7aj) as part of the dissertation for Masters degree in Artificial Intelligence at the University of Bath under the supervision of [Mr. Andreas Theophilou](https://researchportal.bath.ac.uk/en/persons/andreas-theophilou).
|
41 |
\nFurther details will be updated later""")
|
42 |
|
43 |
def display_dataset_analysis(self):
|
44 |
+
"""Displays the Dataset Analysis page."""
|
45 |
st.title("OK-VQA Dataset Analysis")
|
46 |
st.write("This is a Place Holder until the contents are uploaded.")
|
47 |
|
48 |
def display_finetuning_evaluation(self):
|
49 |
+
"""Displays the Finetuning and Evaluation Results page."""
|
50 |
st.title("Finetuning and Evaluation Results")
|
51 |
st.write("This is a Place Holder until the contents are uploaded.")
|
52 |
|
53 |
def display_run_inference(self):
|
54 |
+
"""Displays the Run Inference page."""
|
55 |
inference_runner = InferenceRunner()
|
56 |
inference_runner.run_inference()
|
57 |
|
58 |
def display_dissertation_report(self):
|
59 |
+
"""Displays the Dissertation Report page."""
|
60 |
st.title("Dissertation Report")
|
61 |
st.write("Click the link below to view the PDF.")
|
62 |
+
# Error handling for file access should be considered here
|
63 |
st.download_button(
|
64 |
label="Download PDF",
|
65 |
data=open("Files/Dissertation Report.pdf", "rb"),
|
|
|
68 |
)
|
69 |
|
70 |
def display_code(self):
|
71 |
+
"""Displays the Code page with a link to the project's code repository."""
|
72 |
st.title("Code")
|
73 |
+
st.markdown("You can view the code for this project on the HuggingFace Space file page.")
|
74 |
+
# Inform users they are leaving the app
|
75 |
st.markdown("[View Code](https://huggingface.co/spaces/m7mdal7aj/Mohammed_Alhaj_PlayGround/tree/main)", unsafe_allow_html=True)
|
76 |
|
77 |
def display_placeholder(self):
|
78 |
+
"""Displays a placeholder for future content."""
|
79 |
st.title("Stay Tuned")
|
80 |
st.write("This is a Place Holder until the contents are uploaded.")
|
|
|
|
|
|
|
|
|
|