Deploy your TransPolymer model to Streamlit Cloud for interactive polymer property predictions!
- GitHub Repository: Your code needs to be in a public GitHub repository
- Streamlit Cloud Account: Sign up at share.streamlit.io
- Model Files: Ensure you have the TransPolymer model files
Make sure your repository contains these essential files:
TransPolymer/
├── app.py # Main Streamlit application
├── requirements.txt # Dependencies
├── PolymerSmilesTokenization.py # Custom tokenizer
├── dataset.py # Dataset utilities (if needed)
├── ckpt/ # Model checkpoints (optional)
│ └── pretrain.pt/
│ ├── config.json
│ └── pytorch_model.bin
├── .streamlit/
│ └── config.toml # Streamlit configuration
└── README_streamlit.md # This file
-
Go to Streamlit Cloud: Visit share.streamlit.io
-
Connect GitHub: Sign in with your GitHub account
-
Deploy New App:
- Click "New app"
- Select your repository
- Set branch to
mainormaster - Set main file path to
app.py - Click "Deploy!"
-
Wait for Deployment: The initial deployment may take 5-10 minutes
Create .streamlit/config.toml for better performance:
[theme]
primaryColor = "#FF6B6B"
backgroundColor = "#FFFFFF"
secondaryBackgroundColor = "#F0F2F6"
textColor = "#262730"
[server]
maxUploadSize = 200
maxMessageSize = 200
[browser]
gatherUsageStats = falseThe main Streamlit application with:
- Interactive web interface for polymer property prediction
- Model loading and caching
- SMILES validation
- Batch prediction capabilities
- Property selection and visualization
Essential dependencies including:
streamlit>=1.25.0- Web frameworktorch>=1.12.0- PyTorch for model inferencetransformers>=4.20.1- Hugging Face transformersrdkit-pypi>=2022.3.4- Chemistry library- Other supporting libraries
Custom tokenizer for chemical-aware SMILES processing.
1. Memory Errors
- Streamlit Cloud has memory limits (~1GB)
- Consider using CPU-only PyTorch:
torch>=1.12.0+cpu - Use model caching with
@st.cache_resource
2. Large Model Files
- Streamlit Cloud has file size limits
- Consider using Git LFS for large files
- Or download models at runtime from external storage
3. Dependency Conflicts
# Test locally first
pip install -r requirements.txt
streamlit run app.py4. RDKit Installation Issues
- Use
rdkit-pypiinstead ofrdkit - Ensure Python version compatibility
-
Model Caching:
@st.cache_resource def load_model(): # Model loading code
-
Lazy Loading:
- Load models only when needed
- Use session state for persistent data
-
Memory Management:
- Use CPU instead of GPU for inference
- Implement model quantization if needed
# Clone your repository
git clone <your-repo-url>
cd TransPolymer
# Install dependencies
pip install -r requirements.txt
# Run locally
streamlit run app.pyCC(C)(C)OC(=O)NC1=CC=CC=C1 # Polymer Electrolyte
c1ccc2c(c1)oc1ccccc12 # Band Gap
c1ccc(cc1)c2ccc(cc2)C3=CC=C(C=C3)c4ccccc4 # OPV
- Interactive Prediction: Real-time polymer property prediction
- Multiple Properties: Support for 10+ different polymer properties
- Batch Processing: Upload CSV files for multiple predictions
- Property Selection: Choose from conductivity, band gap, OPV efficiency, etc.
- Validation: SMILES string validation and error handling
- Results Download: Export predictions as CSV files
Once deployed, users can:
- Select Property: Choose from the sidebar (PE_I, OPV, Egc, etc.)
- Enter SMILES: Input polymer SMILES string
- Get Prediction: Click predict to get property value
- Batch Process: Upload CSV files for multiple predictions
- Download Results: Export predictions for further analysis
- Clean, intuitive design
- Real-time SMILES validation
- Property-specific examples
- Responsive layout
- CSV file upload
- Progress tracking
- Results preview
- Download functionality
- Property descriptions
- Units and context
- Model information
- Citation and references
- Connect your own domain
- SSL certificates included
- Custom branding options
- Monitor app performance
- Set resource limits
- Implement auto-scaling
- Store sensitive configuration
- Manage different environments
- API keys and secrets
If you encounter issues:
- Check the Streamlit Cloud logs
- Test locally with the same requirements
- Review the Streamlit forum
- Check GitHub issues for common problems
This deployment guide is provided as-is. Please ensure you comply with all relevant licenses for TransPolymer and its dependencies.
Happy Deploying! 🎉
Your TransPolymer model will be accessible at: https://your-app-name.streamlit.app