WBCClassifier / app.py
elsoori's picture
Initial commit
a12a4a3 verified
raw
history blame
1.42 kB
import streamlit as st
import PIL.Image as Image
import numpy as np
import pandas as pd
import requests
from io import BytesIO
from fastai.vision.all import *
#from fastai.vision.all import load_learner
# Initialize Streamlit app
st.title("White Blood Cell Classifier")
# Load the FastAI model for WBC identification
fastai_model = load_learner('model1.pkl')
# File uploader for image input
uploaded_file = st.file_uploader("Upload an image for detection", type=["jpg", "png"])
if uploaded_file:
# Open the uploaded image
image = Image.open(uploaded_file)
# Perform inference
results = model.predict(np.array(image))
# Display results
st.image(image, caption="Uploaded Image", use_column_width=True)
# Render detection results
rendered_image = render_result(model=model, image=image, result=results[0])
# Show the rendered result
st.image(rendered_image, caption="Detection Results", use_column_width=True)
# Display the counts of each cell type
st.write("Cell Type :")
# Perform inference with the FastAI model
pred, idx, probs = fastai_model.predict(image)
st.write("White Blood Cell Classification:")
categories = ('EOSINOPHIL', 'LYMPHOCYTE', 'MONOCYTE', 'NEUTROPHIL')
results_dict = dict(zip(categories, map(float, probs)))
st.write(results_dict)
else:
st.write("Upload an image to start detection.")