import streamlit as st from PIL import Image import os # Page Configuration st.set_page_config(page_title="Proposal Maker", layout="centered") # Function to Match Idea with Predefined Images def get_predefined_images(idea): # Simple keyword-based matching image_mapping = { "glucose": ["images/glucose_model.png", "images/glucose_block_diagram.png"], "ai": ["images/ai_model.png", "images/ai_block_diagram.png"], "healthcare": ["images/healthcare_model.png", "images/healthcare_block_diagram.png"], "monitoring": ["images/monitoring_model.png", "images/monitoring_block_diagram.png"], } # Match keywords to image list matched_images = [] for keyword, images in image_mapping.items(): if keyword in idea.lower(): matched_images.extend(images) return matched_images or ["images/default_block_diagram.png"] # Default image if no match # App Title st.title("Proposal Maker") st.write("Generate a complete engineering proposal with text and images!") # Step 1: Input Proposal Idea st.header("Step 1: Enter Your Proposal Idea") idea = st.text_input("Describe your proposal idea (e.g., AI-powered glucose monitoring system)", placeholder="Enter your project idea here") # Step 2: Generate Proposal st.header("Step 2: Generate Proposal") if st.button("Generate Proposal"): if not idea.strip(): st.warning("Please enter a proposal idea!") else: # Automatically generate content based on the idea introduction = f"This proposal focuses on {idea}. The aim is to address a significant problem by designing an innovative solution using state-of-the-art technologies." objectives = f"The primary objectives of this project are:\n- Develop a prototype for {idea}.\n- Ensure the solution is cost-effective and scalable.\n- Test and validate the system in real-world conditions." methodology = f"The project will involve:\n1. Research and analysis of existing technologies related to {idea}.\n2. Designing and developing the solution using appropriate hardware and software tools.\n3. Iterative testing to refine the functionality and ensure robustness." timeline = "The project is expected to be completed in the following phases:\n- Phase 1 (Month 1-2): Research and requirement gathering.\n- Phase 2 (Month 3-4): Prototype development.\n- Phase 3 (Month 5-6): Testing and validation.\n- Phase 4 (Month 7): Final deployment and reporting." budget = "The estimated budget for this project includes:\n- Hardware components: $500\n- Software tools: $300\n- Miscellaneous expenses: $200\n**Total: $1,000**" expected_outcomes = f"By implementing this project, we aim to achieve:\n- A functional prototype of {idea}.\n- A scalable and user-friendly solution.\n- Significant improvements in addressing the targeted problem." # Combine all sections proposal_content = f""" # Proposal: {idea} ## Introduction {introduction} ## Objectives {objectives} ## Methodology {methodology} ## Timeline {timeline} ## Budget {budget} ## Expected Outcomes {expected_outcomes} """ # Display the generated proposal st.subheader("Generated Proposal") st.text_area("Proposal", proposal_content, height=300) # Download Proposal st.download_button("Download Proposal", proposal_content, file_name="proposal.md", mime="text/markdown") # Display Predefined Images st.subheader("Relevant Images") matched_images = get_predefined_images(idea) for img_path in matched_images: if os.path.exists(img_path): img = Image.open(img_path) st.image(img, caption=os.path.basename(img_path), use_column_width=True) st.write("---") st.info("This app generates proposals automatically based on your input idea and adds relevant images!")