bhuvaneshprasad commited on
Commit
65e13be
·
verified ·
1 Parent(s): 631d6c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -28
app.py CHANGED
@@ -1,28 +1,27 @@
1
- # streamlit_app/app.py
2
-
3
- import streamlit as st
4
- import requests
5
- from PIL import Image
6
-
7
- # Define FastAPI backend URL
8
- backend_url = "http://localhost:7384"
9
-
10
- def main():
11
- st.title("SETI Signals Classifier")
12
-
13
- # Example: Upload file and send POST request to FastAPI endpoint
14
- uploaded_file = st.file_uploader("Choose an image to predict...", type=["png"])
15
- st.markdown("You can get sample images from [here](https://github.com/bhuvaneshprasad/End-to-End-SETI-Classification-using-CNN-MLFlow-DVC/tree/main/assets/test_images) to predict.")
16
- if uploaded_file is not None:
17
- with st.spinner('Predicting...'):
18
- files = {"file": uploaded_file}
19
- response = requests.post(f"{backend_url}/predict", files=files)
20
- if response.status_code == 200:
21
- st.json(response.json())
22
- image = Image.open(uploaded_file)
23
- st.image(image, caption="Uploaded Image", use_column_width=True)
24
- else:
25
- st.error("Failed to predict")
26
-
27
- if __name__ == "__main__":
28
- main()
 
1
+ # streamlit_app/app.py
2
+ from prediction import PredictionPipeline
3
+ import streamlit as st
4
+ import requests
5
+ from PIL import Image
6
+
7
+ def main():
8
+ st.title("SETI Signals Classifier")
9
+
10
+ # Example: Upload file and send POST request to FastAPI endpoint
11
+ uploaded_file = st.file_uploader("Choose an image to predict...", type=["png"])
12
+ st.markdown("You can get sample images from [here](https://github.com/bhuvaneshprasad/End-to-End-SETI-Classification-using-CNN-MLFlow-DVC/tree/main/assets/test_images) to predict.")
13
+ if uploaded_file is not None:
14
+ with st.spinner('Predicting...'):
15
+ files = {"file": uploaded_file}
16
+ predictor = PredictionPipeline(files)
17
+ prediction = predictor.predict()
18
+ st.title(type(prediction))
19
+ if type(prediction) == str:
20
+ st.json({'prediction' : prediction})
21
+ image = Image.open(uploaded_file)
22
+ st.image(image, caption="Uploaded Image", use_column_width=True)
23
+ else:
24
+ st.error("Failed to predict")
25
+
26
+ if __name__ == "__main__":
27
+ main()