File size: 3,415 Bytes
c53d10d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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()