Update app.py
Browse files
app.py
CHANGED
|
@@ -1208,4 +1208,49 @@ def reports_ui():
|
|
| 1208 |
ext_refs = [r.strip() for r in ext_refs_text.splitlines() if r.strip()]
|
| 1209 |
pdf_bytes = build_full_phase1_pdf_bytes(site_objs, ext_refs)
|
| 1210 |
st.download_button("Download Full Geotechnical Report", data=pdf_bytes, file_name=f"GeoMate_Full_Report_{datetime.now().strftime('%Y%m%d')}.pdf", mime="application/pdf")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1211 |
|
|
|
|
|
|
|
|
|
| 1208 |
ext_refs = [r.strip() for r in ext_refs_text.splitlines() if r.strip()]
|
| 1209 |
pdf_bytes = build_full_phase1_pdf_bytes(site_objs, ext_refs)
|
| 1210 |
st.download_button("Download Full Geotechnical Report", data=pdf_bytes, file_name=f"GeoMate_Full_Report_{datetime.now().strftime('%Y%m%d')}.pdf", mime="application/pdf")
|
| 1211 |
+
# -------------------------
|
| 1212 |
+
# Soil Recognizer (placeholder)
|
| 1213 |
+
# -------------------------
|
| 1214 |
+
def soil_recognizer_ui():
|
| 1215 |
+
st.header("🖼️ Soil Recognizer (image-based)")
|
| 1216 |
+
st.info("Upload a soil image (photo of sample or field). If an offline model 'soil_best_model.pth' exists in repo, it will be used. Otherwise this page acts as a placeholder for integrating your ML model or API.")
|
| 1217 |
+
uploaded = st.file_uploader("Upload soil image (jpg/png)", type=["jpg","jpeg","png"], key="sr_upload")
|
| 1218 |
+
if uploaded:
|
| 1219 |
+
st.image(uploaded, caption="Uploaded image", use_column_width=True)
|
| 1220 |
+
# Placeholder inference
|
| 1221 |
+
st.warning("Model inference not configured in this Space. To enable, upload 'soil_best_model.pth' and implement model loading code here.")
|
| 1222 |
+
if OCR_TESSERACT:
|
| 1223 |
+
st.info("Attempting OCR of image (to extract printed text)")
|
| 1224 |
+
try:
|
| 1225 |
+
img = Image.open(uploaded)
|
| 1226 |
+
text = pytesseract.image_to_string(img)
|
| 1227 |
+
st.text_area("Extracted text (OCR)", value=text, height=200)
|
| 1228 |
+
except Exception as e:
|
| 1229 |
+
st.error(f"OCR failed: {e}")
|
| 1230 |
+
|
| 1231 |
+
# -------------------------
|
| 1232 |
+
# Main UI runner
|
| 1233 |
+
# -------------------------
|
| 1234 |
+
def main():
|
| 1235 |
+
sidebar_ui()
|
| 1236 |
+
# Top-level content area routing
|
| 1237 |
+
page = ss.get("page", "Landing")
|
| 1238 |
+
if page == "Landing":
|
| 1239 |
+
landing_ui()
|
| 1240 |
+
elif page == "Soil Recognizer":
|
| 1241 |
+
soil_recognizer_ui()
|
| 1242 |
+
elif page == "Soil Classifier":
|
| 1243 |
+
soil_classifier_ui()
|
| 1244 |
+
elif page == "GSD Curve":
|
| 1245 |
+
gsd_curve_ui()
|
| 1246 |
+
elif page == "Locator":
|
| 1247 |
+
locator_ui()
|
| 1248 |
+
elif page == "GeoMate Ask":
|
| 1249 |
+
rag_ui()
|
| 1250 |
+
elif page == "Reports":
|
| 1251 |
+
reports_ui()
|
| 1252 |
+
else:
|
| 1253 |
+
st.write("Page not found.")
|
| 1254 |
|
| 1255 |
+
if __name__ == "__main__":
|
| 1256 |
+
main()
|