import os, base64
import gradio as gr
PROJECT_NAME = "AIO2025M03 DEMO KMeans Clustering"
AIO_YEAR = "2025"
AIO_MODULE = "03"
def image_to_base64(image_path: str):
# Construct the absolute path to the image
current_dir = os.path.dirname(os.path.abspath(__file__))
full_image_path = os.path.join(current_dir, image_path)
with open(full_image_path, "rb") as f:
return base64.b64encode(f.read()).decode("utf-8")
def create_header():
with gr.Row():
with gr.Column(scale=2):
logo_base64 = image_to_base64("static/aivn_logo.png")
gr.HTML(
f"""
"""
)
with gr.Column(scale=2):
gr.HTML(f"""
{PROJECT_NAME}
AIO{AIO_YEAR}: Module {AIO_MODULE}
""")
def create_footer():
logo_base64_vlai = image_to_base64("static/vlai_logo.png")
footer_html = """
""" + f"""
"""
return gr.HTML(footer_html)
custom_css = """
.gradio-container {
min-height:64vh;
max-width: 100% !important;
width: 100% !important;
background: linear-gradient(135deg, #F5EFE6 0%, #E8DFCA 50%, #AEBDCA 100%);
background-size: 400% 400%;
animation: gradientBG 10s ease infinite;
}
@keyframes gradientBG {
0% {background-position: 0% 50%;}
50% {background-position: 100% 50%;}
100% {background-position: 0% 50%;}
}
.content-wrap {padding-bottom:8px;}
/* Make SVG plots responsive */
.plot-container svg {
width: 100% !important;
height: auto !important;
max-width: 100% !important;
}
/* Full width for main content */
.main {
max-width: 100% !important;
width: 100% !important;
}
"""