Spaces:
Configuration error
Configuration error
| import os | |
| os.environ['TF_KERAS'] = '1' | |
| os.environ['CUDA_LAUNCH_BLOCKING'] = "1" | |
| import gradio as gr | |
| from prediction import predict | |
| import json | |
| def predict_properties(smiles_input): | |
| """Wrapper function for Gradio interface""" | |
| try: | |
| if not smiles_input.strip(): | |
| return "Please enter a SMILES string" | |
| result = predict(smiles_input) | |
| if "error" in result: | |
| return f"β Error: {result['error']}" | |
| # Format output for display | |
| output = f""" | |
| π§ͺ **Polymer Property Predictions** | |
| **Input SMILES:** `{result['smiles']}` | |
| **Predicted Properties:** | |
| β’ π‘οΈ **Glass Transition Temperature (Tg):** {result['properties']['Tg (Glass Transition Temperature)']} | |
| β’ π₯ **Crystallization Temperature (Tc):** {result['properties']['Tc (Crystallization Temperature)']} | |
| β’ β‘ **Fractional Free Volume (FFV):** {result['properties']['FFV (Fractional Free Volume)']} | |
| β’ ποΈ **Density:** {result['properties']['Density']} | |
| β’ π **Radius of Gyration (Rg):** {result['properties']['Rg (Radius of Gyration)']} | |
| --- | |
| *Predictions generated using Graph Neural Networks trained on NeurIPS 2025 competition data* | |
| """ | |
| return output | |
| except Exception as e: | |
| return f"β Prediction failed: {str(e)}" | |
| # Create Gradio interface | |
| def create_interface(): | |
| with gr.Blocks(title="π§ͺ Polymer Property Predictor", theme=gr.themes.Soft()) as demo: | |
| gr.Markdown(""" | |
| # π§ͺ Polymer Property Prediction Tool | |
| Enter a polymer SMILES string to predict five key polymer properties using advanced Graph Neural Networks. | |
| **Properties Predicted:** | |
| - **Tg**: Glass Transition Temperature (Β°C) | |
| - **Tc**: Crystallization Temperature (Β°C) | |
| - **FFV**: Fractional Free Volume | |
| - **Density**: Polymer Density (g/cmΒ³) | |
| - **Rg**: Radius of Gyration (Γ ) | |
| """) | |
| with gr.Row(): | |
| with gr.Column(): | |
| smiles_input = gr.Textbox( | |
| label="𧬠Polymer SMILES String", | |
| placeholder="Enter SMILES (e.g., *CC* for polyethylene)", | |
| lines=2 | |
| ) | |
| predict_btn = gr.Button("π¬ Predict Properties", variant="primary") | |
| gr.Markdown(""" | |
| **Example SMILES:** | |
| - `*/C=C/*` - Polyethylene | |
| - `*CC(C)*` - Polypropylene | |
| - `*C*` - Polymethylene | |
| """) | |
| with gr.Column(): | |
| output = gr.Markdown( | |
| label="π Prediction Results", | |
| value="Enter a SMILES string and click 'Predict Properties' to see results." | |
| ) | |
| predict_btn.click( | |
| fn=predict_properties, | |
| inputs=[smiles_input], | |
| outputs=[output] | |
| ) | |
| gr.Markdown(""" | |
| --- | |
| **About this Model:** | |
| This prediction model was developed using Graph Neural Networks for the NeurIPS 2025 Open Polymer Prediction competition. | |
| π [GitHub Repository](https://github.com/Gaurav-Kushwaha-1225/NeurIPS-Open-Polymer-Prediction-2025) | |
| """) | |
| return demo | |
| if __name__ == "__main__": | |
| demo = create_interface() | |
| demo.launch() | |