Solar-Iz commited on
Commit
acc4523
·
1 Parent(s): dbfc835

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import json
4
+
5
+ def main():
6
+
7
+ st.title("FastAPI - Streamlit Integration")
8
+
9
+ # Эндпоинт для классификации текста
10
+ text_input = st.text_input("Enter text for classification:")
11
+ if st.button("Classify Text"):
12
+ response = requests.post("http://127.0.0.1:8000/clf_text", json={"text": text_input})
13
+ result = response.json()
14
+ st.success(f"Classification result: {result['prediction']}")
15
+
16
+ # Эндпоинт для классификации изображений
17
+ image_path = st.file_uploader("Upload an image for classification:", type=["jpg", "png"])
18
+ if image_path is not None:
19
+ if st.button("Classify Image"):
20
+ files = {"file": image_path.read()}
21
+ response = requests.post("http://127.0.0.1:8000/classify", files=files)
22
+ result = response.json()
23
+ st.success(f"Classification result: {result['prediction']}")
24
+
25
+ if __name__ == '__main__':
26
+ main()