Update app.py
Browse files
app.py
CHANGED
|
@@ -3,10 +3,8 @@ import streamlit as st
|
|
| 3 |
import json
|
| 4 |
|
| 5 |
def main():
|
| 6 |
-
st.title("FastAPI - Streamlit Integration")
|
| 7 |
|
| 8 |
-
|
| 9 |
-
base_url = st.experimental_get_query_params().get('base_url', [None])[0]
|
| 10 |
|
| 11 |
image = st.file_uploader("Choose an image", type=['jpg', 'jpeg'])
|
| 12 |
|
|
@@ -14,17 +12,13 @@ def main():
|
|
| 14 |
if image is not None:
|
| 15 |
st.image(image)
|
| 16 |
files = {"file": image.getvalue()}
|
| 17 |
-
#
|
| 18 |
-
url = f"{base_url}/classify"
|
| 19 |
-
res = requests.post(url, files=files)
|
| 20 |
st.write(json.loads(res.text)['prediction'])
|
| 21 |
|
| 22 |
# Эндпоинт для классификации текста
|
| 23 |
text_input = st.text_input("Enter text for classification:")
|
| 24 |
if st.button("Classify Text"):
|
| 25 |
-
#
|
| 26 |
-
url = f"{base_url}/clf_text"
|
| 27 |
-
response = requests.post(url, json={"text": text_input})
|
| 28 |
result = response.json()
|
| 29 |
st.success(f"Classification result: {result['prediction']}")
|
| 30 |
|
|
|
|
| 3 |
import json
|
| 4 |
|
| 5 |
def main():
|
|
|
|
| 6 |
|
| 7 |
+
st.title("FastAPI - Streamlit Integration")
|
|
|
|
| 8 |
|
| 9 |
image = st.file_uploader("Choose an image", type=['jpg', 'jpeg'])
|
| 10 |
|
|
|
|
| 12 |
if image is not None:
|
| 13 |
st.image(image)
|
| 14 |
files = {"file": image.getvalue()}
|
| 15 |
+
res = requests.post("http://127.0.0.1:8000/classify", files=files) # Замените это на актуальный URL вашего FastAPI-приложения
|
|
|
|
|
|
|
| 16 |
st.write(json.loads(res.text)['prediction'])
|
| 17 |
|
| 18 |
# Эндпоинт для классификации текста
|
| 19 |
text_input = st.text_input("Enter text for classification:")
|
| 20 |
if st.button("Classify Text"):
|
| 21 |
+
response = requests.post("http://127.0.0.1:8000/clf_text", json={"text": text_input}) # Замените это на актуальный URL вашего FastAPI-приложения
|
|
|
|
|
|
|
| 22 |
result = response.json()
|
| 23 |
st.success(f"Classification result: {result['prediction']}")
|
| 24 |
|