Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,46 +33,3 @@ if uploaded_file:
|
|
| 33 |
|
| 34 |
else:
|
| 35 |
st.write("Upload an image to start classification.")
|
| 36 |
-
|
| 37 |
-
from io import BytesIO
|
| 38 |
-
from fastai.vision.all import *
|
| 39 |
-
#from fastai.vision.all import load_learner
|
| 40 |
-
|
| 41 |
-
# Initialize Streamlit app
|
| 42 |
-
st.title("White Blood Cell Classifier")
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
# Load the FastAI model for WBC identification
|
| 46 |
-
fastai_model = load_learner('model1.pkl')
|
| 47 |
-
|
| 48 |
-
# File uploader for image input
|
| 49 |
-
uploaded_file = st.file_uploader("Upload an image for detection", type=["jpg", "png"])
|
| 50 |
-
|
| 51 |
-
if uploaded_file:
|
| 52 |
-
# Open the uploaded image
|
| 53 |
-
image = Image.open(uploaded_file)
|
| 54 |
-
|
| 55 |
-
# Perform inference
|
| 56 |
-
results = model.predict(np.array(image))
|
| 57 |
-
|
| 58 |
-
# Display results
|
| 59 |
-
st.image(image, caption="Uploaded Image", use_column_width=True)
|
| 60 |
-
|
| 61 |
-
# Render detection results
|
| 62 |
-
rendered_image = render_result(model=model, image=image, result=results[0])
|
| 63 |
-
|
| 64 |
-
# Show the rendered result
|
| 65 |
-
st.image(rendered_image, caption="Detection Results", use_column_width=True)
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
# Display the counts of each cell type
|
| 70 |
-
st.write("Cell Type :")
|
| 71 |
-
# Perform inference with the FastAI model
|
| 72 |
-
pred, idx, probs = fastai_model.predict(image)
|
| 73 |
-
st.write("White Blood Cell Classification:")
|
| 74 |
-
categories = ('EOSINOPHIL', 'LYMPHOCYTE', 'MONOCYTE', 'NEUTROPHIL')
|
| 75 |
-
results_dict = dict(zip(categories, map(float, probs)))
|
| 76 |
-
st.write(results_dict)
|
| 77 |
-
else:
|
| 78 |
-
st.write("Upload an image to start detection.")
|
|
|
|
| 33 |
|
| 34 |
else:
|
| 35 |
st.write("Upload an image to start classification.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|