Spaces:
Runtime error
Runtime error
Delete app
Browse files- app/Dockerfile +0 -29
- app/class_indices.json +0 -1
- app/config.toml +0 -58
- app/credentials.toml +0 -3
- app/main.py +0 -60
- app/requirements.txt +0 -3
- app/trained_model/trained_model_link.txt +0 -1
app/Dockerfile
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
# This sets up the container with Python 3.10 installed.
|
2 |
-
FROM python:3.10-slim
|
3 |
-
|
4 |
-
# This copies everything in your current directory to the /app directory in the container.
|
5 |
-
COPY . /app
|
6 |
-
|
7 |
-
# This sets the /app directory as the working directory for any RUN, CMD, ENTRYPOINT, or COPY instructions that follow.
|
8 |
-
WORKDIR /app
|
9 |
-
|
10 |
-
# This runs pip install for all the packages listed in your requirements.txt file.
|
11 |
-
RUN pip install -r requirements.txt
|
12 |
-
|
13 |
-
# This tells Docker to listen on port 80 at runtime. Port 80 is the standard port for HTTP.
|
14 |
-
EXPOSE 80
|
15 |
-
|
16 |
-
# This command creates a .streamlit directory in the home directory of the container.
|
17 |
-
RUN mkdir ~/.streamlit
|
18 |
-
|
19 |
-
# This copies your Streamlit configuration file into the .streamlit directory you just created.
|
20 |
-
RUN cp config.toml ~/.streamlit/config.toml
|
21 |
-
|
22 |
-
# Similar to the previous step, this copies your Streamlit credentials file into the .streamlit directory.
|
23 |
-
RUN cp credentials.toml ~/.streamlit/credentials.toml
|
24 |
-
|
25 |
-
# This sets the default command for the container to run the app with Streamlit.
|
26 |
-
ENTRYPOINT ["streamlit", "run"]
|
27 |
-
|
28 |
-
# This command tells Streamlit to run your app.py script when the container starts.
|
29 |
-
CMD ["main.py"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/class_indices.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{"0": "Apple___Apple_scab", "1": "Apple___Black_rot", "2": "Apple___Cedar_apple_rust", "3": "Apple___healthy", "4": "Blueberry___healthy", "5": "Cherry_(including_sour)___Powdery_mildew", "6": "Cherry_(including_sour)___healthy", "7": "Corn_(maize)___Cercospora_leaf_spot Gray_leaf_spot", "8": "Corn_(maize)___Common_rust_", "9": "Corn_(maize)___Northern_Leaf_Blight", "10": "Corn_(maize)___healthy", "11": "Grape___Black_rot", "12": "Grape___Esca_(Black_Measles)", "13": "Grape___Leaf_blight_(Isariopsis_Leaf_Spot)", "14": "Grape___healthy", "15": "Orange___Haunglongbing_(Citrus_greening)", "16": "Peach___Bacterial_spot", "17": "Peach___healthy", "18": "Pepper,_bell___Bacterial_spot", "19": "Pepper,_bell___healthy", "20": "Potato___Early_blight", "21": "Potato___Late_blight", "22": "Potato___healthy", "23": "Raspberry___healthy", "24": "Soybean___healthy", "25": "Squash___Powdery_mildew", "26": "Strawberry___Leaf_scorch", "27": "Strawberry___healthy", "28": "Tomato___Bacterial_spot", "29": "Tomato___Early_blight", "30": "Tomato___Late_blight", "31": "Tomato___Leaf_Mold", "32": "Tomato___Septoria_leaf_spot", "33": "Tomato___Spider_mites Two-spotted_spider_mite", "34": "Tomato___Target_Spot", "35": "Tomato___Tomato_Yellow_Leaf_Curl_Virus", "36": "Tomato___Tomato_mosaic_virus", "37": "Tomato___healthy"}
|
|
|
|
app/config.toml
DELETED
@@ -1,58 +0,0 @@
|
|
1 |
-
[global]
|
2 |
-
# If True, will show a warning when you run a Streamlit-enabled script via "python my_script.py".
|
3 |
-
# Default: true
|
4 |
-
showWarningOnDirectExecution = true
|
5 |
-
|
6 |
-
[logger]
|
7 |
-
# Level of logging: 'error', 'warning', 'info', or 'debug'.
|
8 |
-
# Default: 'info'
|
9 |
-
level = "debug"
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
[runner]
|
14 |
-
# Allows you to type a variable or string by itself in a single line of Python code to write it to the app.
|
15 |
-
# Default: true
|
16 |
-
magicEnabled = true
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
[server]
|
21 |
-
# List of folders that should not be watched for changes. Relative paths will be taken as relative to the current working directory.
|
22 |
-
# Example: ['/home/user1/env', 'relative/path/to/folder']
|
23 |
-
# Default: []
|
24 |
-
folderWatchBlacklist = ['']
|
25 |
-
|
26 |
-
# If false, will attempt to open a browser window on start.
|
27 |
-
# Default: false unless (1) we are on a Linux box where DISPLAY is unset, or (2) server.liveSave is set.
|
28 |
-
headless = true
|
29 |
-
|
30 |
-
# Immediately share the app in such a way that enables live monitoring, and post-run analysis.
|
31 |
-
# Default: false
|
32 |
-
liveSave = false
|
33 |
-
|
34 |
-
# Automatically rerun script when the file is modified on disk.
|
35 |
-
# Default: false
|
36 |
-
runOnSave = false
|
37 |
-
|
38 |
-
# The port where the server will listen for client and browser connections.
|
39 |
-
# Default: 8501
|
40 |
-
port = 80
|
41 |
-
|
42 |
-
# Enables support for Cross-Origin Request Sharing, for added security.
|
43 |
-
# Default: true
|
44 |
-
enableCORS = false
|
45 |
-
|
46 |
-
[browser]
|
47 |
-
# Internet address of the server server that the browser should connect to. Can be IP address or DNS name.
|
48 |
-
# Default: 'localhost'
|
49 |
-
serverAddress = "0.0.0.0"
|
50 |
-
|
51 |
-
# Whether to send usage statistics to Streamlit.
|
52 |
-
# Default: true
|
53 |
-
gatherUsageStats = true
|
54 |
-
|
55 |
-
# Port that the browser should use to connect to the server when in liveSave mode.
|
56 |
-
# Default: whatever value is set in server.port.
|
57 |
-
serverPort = 80
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/credentials.toml
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
[general]
|
2 |
-
email=""
|
3 |
-
|
|
|
|
|
|
|
|
app/main.py
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import json
|
3 |
-
from PIL import Image
|
4 |
-
|
5 |
-
import numpy as np
|
6 |
-
import tensorflow as tf
|
7 |
-
import streamlit as st
|
8 |
-
|
9 |
-
|
10 |
-
working_dir = os.path.dirname(os.path.abspath(__file__))
|
11 |
-
model_path = f"{working_dir}/trained_model/plant_disease_prediction_model.h5"
|
12 |
-
# Load the pre-trained model
|
13 |
-
model = tf.keras.models.load_model(model_path)
|
14 |
-
|
15 |
-
# loading the class names
|
16 |
-
class_indices = json.load(open(f"{working_dir}/class_indices.json"))
|
17 |
-
|
18 |
-
|
19 |
-
# Function to Load and Preprocess the Image using Pillow
|
20 |
-
def load_and_preprocess_image(image_path, target_size=(224, 224)):
|
21 |
-
# Load the image
|
22 |
-
img = Image.open(image_path)
|
23 |
-
# Resize the image
|
24 |
-
img = img.resize(target_size)
|
25 |
-
# Convert the image to a numpy array
|
26 |
-
img_array = np.array(img)
|
27 |
-
# Add batch dimension
|
28 |
-
img_array = np.expand_dims(img_array, axis=0)
|
29 |
-
# Scale the image values to [0, 1]
|
30 |
-
img_array = img_array.astype('float32') / 255.
|
31 |
-
return img_array
|
32 |
-
|
33 |
-
|
34 |
-
# Function to Predict the Class of an Image
|
35 |
-
def predict_image_class(model, image_path, class_indices):
|
36 |
-
preprocessed_img = load_and_preprocess_image(image_path)
|
37 |
-
predictions = model.predict(preprocessed_img)
|
38 |
-
predicted_class_index = np.argmax(predictions, axis=1)[0]
|
39 |
-
predicted_class_name = class_indices[str(predicted_class_index)]
|
40 |
-
return predicted_class_name
|
41 |
-
|
42 |
-
|
43 |
-
# Streamlit App
|
44 |
-
st.title('Plant Disease Classifier')
|
45 |
-
|
46 |
-
uploaded_image = st.file_uploader("Upload an image...", type=["jpg", "jpeg", "png"])
|
47 |
-
|
48 |
-
if uploaded_image is not None:
|
49 |
-
image = Image.open(uploaded_image)
|
50 |
-
col1, col2 = st.columns(2)
|
51 |
-
|
52 |
-
with col1:
|
53 |
-
resized_img = image.resize((150, 150))
|
54 |
-
st.image(resized_img)
|
55 |
-
|
56 |
-
with col2:
|
57 |
-
if st.button('Classify'):
|
58 |
-
# Preprocess the uploaded image and predict the class
|
59 |
-
prediction = predict_image_class(model, uploaded_image, class_indices)
|
60 |
-
st.success(f'Prediction: {str(prediction)}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/requirements.txt
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
numpy==1.26.3
|
2 |
-
streamlit==1.30.0
|
3 |
-
tensorflow==2.15.0.post1
|
|
|
|
|
|
|
|
app/trained_model/trained_model_link.txt
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
trained plant disease prediction model link: https://drive.google.com/file/d/1rKh-IElSdHTqax7XdfSdZTn-r8T_qWPf/view?usp=drive_link
|
|
|
|