Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit_app_code = """
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import numpy as np
|
| 5 |
+
import keras
|
| 6 |
+
from huggingface_hub import from_pretrained_keras
|
| 7 |
+
|
| 8 |
+
# Load the pre-trained model for low light image enhancement
|
| 9 |
+
enhancement_model = from_pretrained_keras("ali444/VGG16_finetuned_79", compile=False)
|
| 10 |
+
enhancement_examples = ['examples/_0_1966.png', 'examples/_1_2118.png', 'examples/_1_5031.png']
|
| 11 |
+
|
| 12 |
+
# Load the pre-trained model for blood cell classification
|
| 13 |
+
classification_model = from_pretrained_keras("ali444/VGG16_finetuned_79", compile=False)
|
| 14 |
+
|
| 15 |
+
# Define class labels
|
| 16 |
+
class_names = ["EOSINOPHIL", "LYMPHOCYTE", "MONOCYTE", "NEUTROPHIL"]
|
| 17 |
+
|
| 18 |
+
# Create Streamlit app
|
| 19 |
+
st.title('Blood Cell Classification App')
|
| 20 |
+
|
| 21 |
+
# Upload an image through Streamlit
|
| 22 |
+
uploaded_file = st.file_uploader("Upload an image...", type="jpg")
|
| 23 |
+
|
| 24 |
+
if uploaded_file:
|
| 25 |
+
st.image(uploaded_file, caption="Uploaded Image.", use_column_width=True)
|
| 26 |
+
st.write("")
|
| 27 |
+
st.write("Classifying...")
|
| 28 |
+
|
| 29 |
+
# Preprocess the uploaded image
|
| 30 |
+
image = Image.open(uploaded_file)
|
| 31 |
+
image = image.resize((150, 150))
|
| 32 |
+
image_array = np.array(image) / 255.0
|
| 33 |
+
image_array = np.expand_dims(image_array, axis=0)
|
| 34 |
+
|
| 35 |
+
# Make predictions
|
| 36 |
+
classification_prediction = classification_model.predict(image_array)
|
| 37 |
+
predicted_class = class_names[np.argmax(classification_prediction)]
|
| 38 |
+
|
| 39 |
+
# Display the prediction result
|
| 40 |
+
st.success(f"Prediction: {predicted_class}")
|
| 41 |
+
|
| 42 |
+
# Add some additional information or instructions
|
| 43 |
+
st.write("")
|
| 44 |
+
st.write("Instructions:")
|
| 45 |
+
st.write("* Upload an image of a blood cell.")
|
| 46 |
+
st.write("* The app will predict the blood cell type.")
|
| 47 |
+
"""
|