24Sureshkumar's picture
Update app_ui.py
e9b17c9 verified
raw
history blame
1.8 kB
# app_ui.py
import streamlit as st
from app import translate_tamil_to_english, generate_image, generate_creative_text
from PIL import Image
st.set_page_config(page_title="Tamil → English + AI Art", layout="centered")
st.title("🧠 Tamil to English + AI Image + Text Generator")
tamil_input = st.text_area("✍️ Enter Tamil Text", height=150)
reference_translation = st.text_input("📘 (Optional) Reference English Translation for ROUGE", "")
if st.button("✨ Generate Everything"):
if not tamil_input.strip():
st.warning("Please enter Tamil text to proceed.")
else:
with st.spinner("Translating..."):
trans, t_time, rouge_l = translate_tamil_to_english(tamil_input, reference_translation.strip())
st.success(f"✅ Translation done in {t_time}s")
st.markdown(f"**Translated English:** `{trans}`")
if rouge_l is not None:
st.markdown(f"📊 **ROUGE-L Score:** `{rouge_l}`")
else:
st.info("ℹ️ No reference provided—ROUGE-L not calculated.")
with st.spinner("🎨 Generating AI image..."):
img_path, img_time = generate_image(trans)
if img_path:
st.success(f"✅ Image generated in {img_time}s")
st.image(Image.open(img_path), caption="🖼️ AI Generated", use_column_width=True)
else:
st.error(img_time)
with st.spinner("💡 Generating creative text..."):
craft, c_time, tokens, rpt = generate_creative_text(trans)
st.success(f"✅ Generated in {c_time}s")
st.markdown(f"**Creative Text:** `{craft}`")
st.markdown(f"ℹ️ Tokens: {tokens}, Repetition Rate: {rpt}")
st.markdown("---")
st.markdown("Made with ❤️ using Streamlit, MBart, GPT‑2 & Stable Diffusion 2.1")