import streamlit as st import requests import json def main(): st.title("FastAPI - Streamlit Integration") # Эндпоинт для классификации текста text_input = st.text_input("Enter text for classification:") if st.button("Classify Text"): response = requests.post("http://127.0.0.1:8000/clf_text", json={"text": text_input}) result = response.json() st.success(f"Classification result: {result['prediction']}") # Эндпоинт для классификации изображений image_path = st.file_uploader("Upload an image for classification:", type=["jpg", "png"]) if image_path is not None: if st.button("Classify Image"): files = {"file": image_path.read()} response = requests.post("http://127.0.0.1:8000/classify", files=files) result = response.json() st.success(f"Classification result: {result['prediction']}") if __name__ == '__main__': main()