Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,82 +1,50 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import matplotlib.pyplot as plt
|
| 3 |
-
import pandas as pd
|
| 4 |
-
import numpy as np
|
| 5 |
from PIL import Image
|
| 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 |
-
st.
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
-
|
| 41 |
-
-
|
| 42 |
-
""
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
temp = df.iloc[:, 0]
|
| 56 |
-
fig, ax = plt.subplots()
|
| 57 |
-
|
| 58 |
-
for col in df.columns[1:]:
|
| 59 |
-
weight = df[col]
|
| 60 |
-
onset, peak, loss = analyze_curve(temp, weight)
|
| 61 |
-
|
| 62 |
-
ax.plot(temp, weight, label=col)
|
| 63 |
-
|
| 64 |
-
st.subheader(f"Results for {col}")
|
| 65 |
-
if onset:
|
| 66 |
-
st.write(f"- **Onset Temperature:** {onset:.2f} °C")
|
| 67 |
-
if peak:
|
| 68 |
-
st.write(f"- **Peak Degradation Temperature:** {peak:.2f} °C")
|
| 69 |
-
st.write(f"- **Weight Loss:** {loss:.2f} %")
|
| 70 |
-
|
| 71 |
-
ax.set_xlabel("Temperature (°C)")
|
| 72 |
-
ax.set_ylabel("Weight (%)")
|
| 73 |
-
ax.legend()
|
| 74 |
-
st.pyplot(fig)
|
| 75 |
-
|
| 76 |
-
st.write("---")
|
| 77 |
-
st.write("Alternatively, upload a TGA **image (PNG/JPG)** just for visualization (no extraction).")
|
| 78 |
-
|
| 79 |
-
img_file = st.file_uploader("Upload TGA Image", type=["png", "jpg", "jpeg"])
|
| 80 |
-
if img_file:
|
| 81 |
-
img = Image.open(img_file)
|
| 82 |
-
st.image(img, caption="Uploaded TGA Graph", use_column_width=True)
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 2 |
from PIL import Image
|
| 3 |
+
import io
|
| 4 |
+
|
| 5 |
+
st.set_page_config(page_title="TGA Graph Interpreter", layout="wide")
|
| 6 |
+
|
| 7 |
+
st.title("TGA Graph Interpreter")
|
| 8 |
+
st.write("Upload TGA thermograms and record degradation details. The app will generate a structured discussion.")
|
| 9 |
+
|
| 10 |
+
uploaded_files = st.file_uploader(
|
| 11 |
+
"Upload thermogram(s)",
|
| 12 |
+
type=["png", "jpg", "jpeg", "pdf"],
|
| 13 |
+
accept_multiple_files=True
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
all_discussions = []
|
| 17 |
+
|
| 18 |
+
if uploaded_files:
|
| 19 |
+
for i, uploaded_file in enumerate(uploaded_files):
|
| 20 |
+
st.subheader(f"Thermogram {i+1}: {uploaded_file.name}")
|
| 21 |
+
|
| 22 |
+
# Display thermogram
|
| 23 |
+
file_bytes = uploaded_file.read()
|
| 24 |
+
image = Image.open(io.BytesIO(file_bytes))
|
| 25 |
+
st.image(image, use_container_width=True)
|
| 26 |
+
|
| 27 |
+
st.markdown("**Enter analysis details:**")
|
| 28 |
+
onset_temp = st.number_input(f"Onset temperature (°C) for {uploaded_file.name}", min_value=0, step=1)
|
| 29 |
+
peak_temp = st.number_input(f"Peak degradation temperature (°C) for {uploaded_file.name}", min_value=0, step=1)
|
| 30 |
+
weight_loss = st.number_input(f"Total weight loss (%) for {uploaded_file.name}", min_value=0.0, step=0.1)
|
| 31 |
+
residue = st.number_input(f"Residue at 800 °C (%) for {uploaded_file.name}", min_value=0.0, step=0.1)
|
| 32 |
+
|
| 33 |
+
if st.button(f"Add Discussion for {uploaded_file.name}"):
|
| 34 |
+
discussion = (
|
| 35 |
+
f"**{uploaded_file.name}**:\n"
|
| 36 |
+
f"- Onset of degradation observed at ~{onset_temp} °C.\n"
|
| 37 |
+
f"- Major degradation peak at ~{peak_temp} °C.\n"
|
| 38 |
+
f"- The material shows a total weight loss of ~{weight_loss:.2f}%.\n"
|
| 39 |
+
f"- Residual mass at 800 °C is ~{residue:.2f}%.\n\n"
|
| 40 |
+
f"These results indicate thermal stability until {onset_temp} °C, "
|
| 41 |
+
f"with significant decomposition occurring around {peak_temp} °C. "
|
| 42 |
+
f"The remaining char (~{residue:.2f}%) suggests potential "
|
| 43 |
+
f"applications where high-temperature stability is desired."
|
| 44 |
+
)
|
| 45 |
+
all_discussions.append(discussion)
|
| 46 |
+
|
| 47 |
+
if all_discussions:
|
| 48 |
+
st.header("Discussion")
|
| 49 |
+
for d in all_discussions:
|
| 50 |
+
st.markdown(d)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|