cxr_mm_demo.py / app.py
Amarsaish's picture
Update app.py
86a22a0 verified
raw
history blame contribute delete
978 Bytes
import streamlit as st
import requests
# Define API URL
API_URL = "http://34.58.49.157:5000/analyze" # Replace <server-ip> with your server's IP or localhost
st.title("CXR_Larkai")
st.write("Upload an chest xray and ask")
# File uploader for the image
uploaded_file = st.file_uploader("Choose an image", type=["jpg", "png", "jpeg"])
# Text area for instruction
instruction = st.text_area("Enter your instruction", "",height=70)
if st.button("Analyze"):
if uploaded_file and instruction:
files = {"image": uploaded_file.getvalue()}
data = {"instruction": instruction}
# Call the API
response = requests.post(API_URL, files={"image": uploaded_file}, data=data)
if response.status_code == 200:
result = response.json()
st.success(f"Response: {result['response']}")
else:
st.error(f"Error: {response.text}")
else:
st.warning("Please upload an image and enter instructions.")