Spaces:
Sleeping
Sleeping
Download src/streamlit_app.py from harshitrk07/ml-deployment-platform: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/spaces/harshitrk07/ml-deployment-platform/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/harshitrk07/ml-deployment-platform/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/harshitrk07/ml-deployment-platform/resolve/main/src/streamlit_app.py
1.37 kB
| import streamlit as st | |
| import requests | |
| API_URL = "https://ml-deployment-platform.onrender.com/predict" | |
| st.set_page_config(page_title="ML Deployment Platform", page_icon="๐ธ") | |
| st.title("๐ธ Iris Flower Predictor") | |
| st.markdown("### Powered by FastAPI + Docker + Render") | |
| st.markdown("---") | |
| st.subheader("Enter Flower Measurements:") | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| sepal_length = st.slider("Sepal Length (cm)", 4.0, 8.0, 5.1) | |
| sepal_width = st.slider("Sepal Width (cm)", 2.0, 5.0, 3.5) | |
| with col2: | |
| petal_length = st.slider("Petal Length (cm)", 1.0, 7.0, 1.4) | |
| petal_width = st.slider("Petal Width (cm)", 0.1, 3.0, 0.2) | |
| st.markdown("---") | |
| if st.button("๐ Predict", use_container_width=True): | |
| with st.spinner("Calling ML API..."): | |
| try: | |
| response = requests.post(API_URL, json={ | |
| "sepal_length": sepal_length, | |
| "sepal_width": sepal_width, | |
| "petal_length": petal_length, | |
| "petal_width": petal_width | |
| }) | |
| result = response.json() | |
| st.success(f"๐บ Prediction: **{result['prediction']}**") | |
| st.info(f"๐ Confidence: **{result['confidence']}%**") | |
| except Exception as e: | |
| st.error(f"API Error: {e}") | |
| st.markdown("---") | |
| st.markdown("Built with โค๏ธ | FastAPI + Docker + Render + Hugging Face") | |