File size: 2,182 Bytes
7acb79c
 
1d2ebdf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from PIL import Image
import io

st.set_page_config(page_title="TGA Graph Interpreter", layout="wide")

st.title("TGA Graph Interpreter")
st.write("Upload TGA thermograms and record degradation details. The app will generate a structured discussion.")

uploaded_files = st.file_uploader(
    "Upload thermogram(s)", 
    type=["png", "jpg", "jpeg", "pdf"], 
    accept_multiple_files=True
)

all_discussions = []

if uploaded_files:
    for i, uploaded_file in enumerate(uploaded_files):
        st.subheader(f"Thermogram {i+1}: {uploaded_file.name}")

        # Display thermogram
        file_bytes = uploaded_file.read()
        image = Image.open(io.BytesIO(file_bytes))
        st.image(image, use_container_width=True)

        st.markdown("**Enter analysis details:**")
        onset_temp = st.number_input(f"Onset temperature (°C) for {uploaded_file.name}", min_value=0, step=1)
        peak_temp = st.number_input(f"Peak degradation temperature (°C) for {uploaded_file.name}", min_value=0, step=1)
        weight_loss = st.number_input(f"Total weight loss (%) for {uploaded_file.name}", min_value=0.0, step=0.1)
        residue = st.number_input(f"Residue at 800 °C (%) for {uploaded_file.name}", min_value=0.0, step=0.1)

        if st.button(f"Add Discussion for {uploaded_file.name}"):
            discussion = (
                f"**{uploaded_file.name}**:\n"
                f"- Onset of degradation observed at ~{onset_temp} °C.\n"
                f"- Major degradation peak at ~{peak_temp} °C.\n"
                f"- The material shows a total weight loss of ~{weight_loss:.2f}%.\n"
                f"- Residual mass at 800 °C is ~{residue:.2f}%.\n\n"
                f"These results indicate thermal stability until {onset_temp} °C, "
                f"with significant decomposition occurring around {peak_temp} °C. "
                f"The remaining char (~{residue:.2f}%) suggests potential "
                f"applications where high-temperature stability is desired."
            )
            all_discussions.append(discussion)

if all_discussions:
    st.header("Discussion")
    for d in all_discussions:
        st.markdown(d)