Spaces:
Running
Running
File size: 8,057 Bytes
1893ba9 9bc1376 df35a2f 1b2f5df 8004986 9bc1376 df35a2f cc5aa84 9bc1376 1893ba9 9bc1376 8004986 9bc1376 6b987c6 9bc1376 e493442 9bc1376 df35a2f 9bc1376 df35a2f 9bc1376 df35a2f 9bc1376 df35a2f e493442 9bc1376 1b2f5df 8004986 9bc1376 df35a2f 9bc1376 df35a2f 531428a 9bc1376 df35a2f 6b987c6 9bc1376 df35a2f 9bc1376 df35a2f 9bc1376 df35a2f 6b987c6 df35a2f 9bc1376 8004986 |
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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
import base64
from pathlib import Path
import streamlit as st
from dotenv import load_dotenv
from app_pages.script_library import render_script_library
from app_pages.video_analyser import render_video_analyser_page
from app_pages.image_analyser import render_image_analyser_page
from app_pages.image_analyser_library import render_image_analysis_library
from app_pages.video_hashid_generation import render_video_hashid
from app_pages.video_text_generation import render_video_to_text
from app_pages.video_translator import render_video_translator
from app_pages.video_caption import render_video_caption
from authen.authentication import login_gate, logout
from app_pages.text_image_generation import render_multimodel_ad_generator
from app_pages.image_generation import render_bulk_image_generator
from app_pages.video_library import render_video_library
from app_pages.image_generation_library import render_image_variations_library
from app_pages.text_image_generation_library import render_text_image_library
from app_pages.script_generator import generator_page
load_dotenv()
st.set_page_config(page_title="Gen AI + AI Library", page_icon="✨", layout="wide")
# ---------- Auth ----------
uid = login_gate()
with st.sidebar:
st.markdown(f"**Signed in as:** `{uid}`")
if st.button("Log out", key="btn_logout",width='content'):
logout()
st.rerun()
st.markdown(
"""
<style>
.private-mode-banner {
padding: 0.75rem 1rem;
margin-top: 0.5rem;
border-radius: 0.85rem;
background: linear-gradient(125deg, rgba(91, 33, 182, 0.85), rgba(132, 94, 247, 0.55));
border: 1px solid rgba(132, 94, 247, 0.35);
color: #fff;
font-weight: 500;
box-shadow: 0 10px 24px rgba(82, 46, 173, 0.28);
animation: privateBannerSlide 0.55s ease forwards, privateBannerFade 3.3s ease 1.75s forwards;
}
.private-mode-banner-content {
display: flex;
align-items: flex-start;
gap: 0.85rem;
}
.private-mode-banner-copy {
display: flex;
flex-direction: column;
gap: 0.15rem;
}
.private-mode-icon {
width: 64px;
min-width: 48px;
max-width: 20%;
filter: drop-shadow(0 6px 16px rgba(16, 13, 61, 0.45));
opacity: 0.95;
}
.private-mode-banner small {
display: block;
opacity: 0.85;
font-weight: 400;
margin-top: 0.25rem;
letter-spacing: 0.01em;
}
@media (max-width: 320px) {
.private-mode-icon {
display: none;
}
}
@keyframes privateBannerSlide {
0% { transform: translateY(-12px); opacity: 0; }
60% { transform: translateY(2px); opacity: 1; }
100% { transform: translateY(0); opacity: 1; }
}
@keyframes privateBannerFade {
to { opacity: 0; }
}
@keyframes privateToggleGlow {
0% { box-shadow: 0 0 0 rgba(132, 94, 247, 0.0); }
40% { box-shadow: 0 0 24px rgba(132, 94, 247, 0.55); }
100% { box-shadow: 0 0 0 rgba(132, 94, 247, 0.0); }
}
</style>
""",
unsafe_allow_html=True,
)
prev_private_mode = st.session_state.get("_private_mode_prev", st.session_state.get("private_mode_enabled", False))
banner_slot = st.empty()
private_mode_default = st.session_state.get("private_mode_enabled", False)
private_mode = st.toggle(
"Private mode",
value=private_mode_default,
key="private_mode_enabled",
help="Skip saving prompts, jobs, and generated media to shared libraries."
)
just_enabled_private_mode = private_mode and not prev_private_mode
just_disabled_private_mode = (not private_mode) and prev_private_mode
if just_enabled_private_mode:
st.markdown(
"""
<style>
div[data-testid="stSidebar"] div[data-testid="stToggle"] label {
animation: privateToggleGlow 2.45s ease-out 0s 1;
border-radius: 0.5rem;
}
</style>
""",
unsafe_allow_html=True,
)
icon_data_url = ""
try:
icon_path = Path(__file__).resolve().parent / "assets" / "private-mode.png"
icon_data_url = "data:image/png;base64," + base64.b64encode(icon_path.read_bytes()).decode("utf-8")
except Exception:
icon_data_url = ""
icon_html = f'<img src="{icon_data_url}" alt="Private mode icon" class="private-mode-icon" />' if icon_data_url else ""
banner_slot.markdown(
f"""
<div class="private-mode-banner">
<div class="private-mode-banner-content">
{icon_html}
<div class="private-mode-banner-copy">
Private mode is live for this session.
<small>We'll keep new generations off shared storage until you disable it.</small>
</div>
</div>
</div>
""",
unsafe_allow_html=True,
)
elif just_disabled_private_mode:
banner_slot.empty()
st.session_state["_private_mode_prev"] = private_mode
if private_mode:
st.caption("Private mode keeps this session's generations ephemeral—nothing is stored in the AI Library or external storage.")
section = st.radio(" ", ["Gen AI", "AI Library"], index=0, horizontal=True, key="main_section")
# ---------------------------- Gen AI ---------------------------------
def render_genai():
_, main = st.columns([0.1, 1], gap="small")
with main:
mod_tabs = st.tabs(["Image Gen","Image Analyser","Video Analyser", "Script Generator", "Video Hashid Gen", "Video to Text","Video Translator","Generate Caption"])
# -------- Image Generation --------
with mod_tabs[0]:
sub = st.tabs(["Text", "Img"])
with sub[0]:
render_multimodel_ad_generator()
with sub[1]:
render_bulk_image_generator(uid=uid)
with mod_tabs[1]:
render_image_analyser_page(uid=uid)
# -------- Video Analyser --------
with mod_tabs[2]:
render_video_analyser_page(uid=uid)
# -------- Script Generator --------
with mod_tabs[3]:
generator_page(uid=uid)
#-------- Video Hashid Generation --------
with mod_tabs[4]:
render_video_hashid(uid=uid)
#-------- Video to Text Generation --------
with mod_tabs[5]:
render_video_to_text(uid=uid)
#-------- Video Translator --------
with mod_tabs[6]:
render_video_translator(uid=uid)
#-------- Video caption --------
with mod_tabs[7]:
render_video_caption(uid=uid)
# ---------------------------- AI Library ---------------------------------
def render_ai_library():
_, main = st.columns([0.1, 1], gap="small")
with main:
st.subheader("Library")
lib_tabs = st.tabs(["Image","Analysed Image","Analysed Video", "Generated Scripts"])
# ---------- Image Tab ----------
with lib_tabs[0]:
sub = st.tabs(["New generated", "Variations"])
with sub[0]:
render_text_image_library(uid=uid)
with sub[1]:
render_image_variations_library(uid=uid)
with lib_tabs[1]:
render_image_analysis_library(uid=uid)
# ---------- Video Library Tab ----------
with lib_tabs[2]:
render_video_library(uid=uid)
# ---------- Generated Scripts Tab ----------
with lib_tabs[3]:
render_script_library(uid=uid)
if section == "Gen AI":
render_genai()
else:
render_ai_library() |