File size: 2,377 Bytes
2098428
bfeb2cf
2098428
bfeb2cf
 
 
 
 
c913ae8
bfeb2cf
 
 
 
 
 
 
 
c913ae8
bfeb2cf
 
 
 
 
 
c913ae8
bfeb2cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c913ae8
bfeb2cf
 
c913ae8
 
bfeb2cf
 
c913ae8
 
 
 
 
 
 
 
 
bfeb2cf
 
 
 
 
 
 
 
 
2098428
bfeb2cf
 
2098428
bfeb2cf
 
 
 
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
import streamlit as st
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
from PIL import Image
import base64

st.set_page_config(page_title="Menstrual Health Chatbot 💬", layout="centered")

# Load model
@st.cache_resource
def load_model():
    tokenizer = AutoTokenizer.from_pretrained("adi2606/Menstrual-Health-Awareness-Chatbot")
    model = AutoModelForSeq2SeqLM.from_pretrained("adi2606/Menstrual-Health-Awareness-Chatbot").to("cpu")
    return tokenizer, model

tokenizer, model = load_model()

# Generate response
def generate_response(input_text):
    inputs = tokenizer(input_text, return_tensors="pt")
    outputs = model.generate(**inputs, max_length=128)
    response = tokenizer.decode(outputs[0], skip_special_tokens=True)
    return response

# Background image
def set_background(image_path):
    with open(image_path, "rb") as f:
        encoded_string = base64.b64encode(f.read()).decode()
        st.markdown(
            f"""
            <style>
            .stApp {{
                background-image: url("data:image/png;base64,{encoded_string}");
                background-size: cover;
            }}
            </style>
            """,
            unsafe_allow_html=True
        )


set_background("background.jpg")  


banner = Image.open("banner.png")
st.image(banner, width=100)  


st.markdown("""
    <style>
    h1, h4, .stMarkdown p, .stTextInput label, .css-1d391kg {
        color: #111111 !important;
    }
    </style>
""", unsafe_allow_html=True)

# App content
st.markdown("<h1 style='text-align: center;'>🩸 Menstrual Health Awareness Chatbot 💬</h1>", unsafe_allow_html=True)
st.markdown("<h4 style='text-align: center;'>Ask anything about periods, PMS, hygiene, and more!</h4>", unsafe_allow_html=True)

st.markdown("### 🤔 Your Question")
user_input = st.text_input("", placeholder="E.g., What are the symptoms of PMS?")

if st.button("🚀 Ask"):
    if user_input.strip():
        with st.spinner("Generating a helpful response..."):
            response = generate_response(user_input)
        st.success("✅ Here's what I found:")
        st.markdown(f"**💬 Chatbot:** {response}")
    else:
        st.warning("⚠️ Please enter a question to get started.")

st.markdown("---")
st.markdown("<small style='color: gray;'>Made with ❤️ to spread awareness.</small>", unsafe_allow_html=True)