File size: 2,070 Bytes
7195b15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

import streamlit as st
import io
from PIL import Image
import os
from cnnClassifier.pipeline.predict import Prediction

st.set_page_config(page_title="Chicken Health Predictor", page_icon="πŸ”", layout="wide")

st.title("πŸ” Chicken Health Predictor")
st.markdown("### Upload an image to predict if the chicken is healthy or has coccidiosis")

uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])

col1, col2 = st.columns(2)

if uploaded_file is not None:
    image = Image.open(uploaded_file)
    col1.image(image, caption="Uploaded Image", use_column_width=True)
    
    # Save the uploaded file temporarily
    temp_file = "temp_image.jpg"
    image.save(temp_file)
    
    with st.spinner("Analyzing the image..."):
        predictor = Prediction(temp_file)
        prediction = predictor.predict()
    
    # Remove the temporary file
    os.remove(temp_file)
    
    col2.markdown("## Prediction Result")
    if prediction == "Normal":
        col2.success(f"The chicken appears to be **{prediction}**! πŸŽ‰")
        col2.markdown("Keep up the good care for your feathered friend!")
    else:
        col2.error(f"The kidney may have **{prediction}**. 😒")
        col2.markdown("Please consult with a veterinarian for proper treatment.")
    
    

st.sidebar.title("About")
st.sidebar.info(
    "This app uses a deep learning model to predict whether a chicken is healthy "
    "or has coccidiosis based on an uploaded image. Always consult with a "
    "veterinarian for accurate diagnosis and treatment."
)

st.sidebar.title("Instructions")
st.sidebar.markdown(
    """
    1. Upload a clear image of a chicken.
    2. Wait for the model to analyze the image.
    3. View the prediction result and additional information.
    """
)

st.markdown(
    """
    <style>
    .reportview-container {
        background: linear-gradient(to right, #FDFCFB, #E2D1C3);
    }
    .sidebar .sidebar-content {
        background: linear-gradient(to bottom, #FDFCFB, #E2D1C3);
    }
    </style>
    """,
    unsafe_allow_html=True,
)