Plant Health Prediction Using CNNConvolutional Neural Network
Guide

Configuration

Environment variables, config files, feature flags


Overview

This page explains how to configure the plant-disease-predictor application so it runs correctly in your environment. Configuration is split across two files — config.toml and credentials.toml — which control server behavior, logging, browser connectivity, and account credentials. Getting these settings right before you launch ensures the app is reachable, performs well, and behaves predictably when you upload leaf images for disease analysis.


Prerequisites

Before adjusting any configuration, make sure you have the following in place:

  • Python 3.8 or later installed on your system
  • pip (Python package manager) available in your terminal
  • The following Python packages at the exact versions used by this project:
    • numpy==1.26.3
    • streamlit==1.30.0
    • tensorflow==2.15.0.post1
  • Write access to the project directory so you can edit config.toml and credentials.toml
  • A terminal or command prompt open at the project root

Installation

Follow these steps to install all dependencies and place the configuration files correctly.

  1. Clone or download the project to your local machine and navigate into the project directory:

    cd plant-disease-predictor
    
  2. Install the required Python packages using the provided requirements.txt:

    pip install -r requirements.txt
    

    This installs numpy, streamlit, and tensorflow at the exact versions the application was tested with. Installing different versions may cause unexpected behavior.

  3. Verify the configuration files exist in the project root. You should see both:

    config.toml
    credentials.toml
    

    If either file is missing, create it manually using the examples in the Configuration section below.

  4. Confirm Streamlit is available by running:

    streamlit --version
    

    Expected output:

    Streamlit, version 1.30.0
    

Once installation is complete, you are ready to adjust configuration values before launching.


Configuration

All configuration lives in two TOML files at the project root. Edit these files with any text editor before starting the application.


config.toml

This file controls Streamlit's runtime, server, logging, and browser behavior.

[global]

KeyDefaultValid valuesEffect
showWarningOnDirectExecutiontruetrue, falseWhen true, Streamlit prints a warning if you run the script with python instead of streamlit run. Keep this enabled during development to avoid confusion.

[logger]

KeyDefaultValid valuesEffect
level"info""error", "warning", "info", "debug"Controls the verbosity of log output. The current setting is "debug", which prints detailed messages useful for diagnosing prediction or connectivity issues. Switch to "info" or "warning" in production to reduce noise.

[runner]

KeyDefaultValid valuesEffect
magicEnabledtruetrue, falseAllows bare Python expressions on a single line to be rendered in the app. Disabling this is rarely necessary unless you encounter unexpected output in the UI.

[server]

These settings control how the application server listens for and handles connections.

KeyDefaultValid valuesEffect
folderWatchBlacklist[]List of pathsFolders the server will not watch for file changes. Useful for excluding large virtual-environment directories from hot-reload scanning.
headlessfalse (platform-dependent)true, falseSet to true to prevent the server from opening a browser window automatically on startup. Required when running on a remote server or inside a container.
liveSavefalsetrue, falseWhen true, the app is immediately shared for live monitoring. Leave as false for standard local or self-hosted use.
runOnSavefalsetrue, falseWhen true, the app automatically reruns whenever the script file changes on disk. Convenient during development; keep false in production.
port8501Any valid port integerThe port the server listens on. The current value is 80 (standard HTTP), which means you can access the app without specifying a port in your browser URL. Ensure this port is open in your firewall or security group.
enableCORStruetrue, falseEnables Cross-Origin Resource Sharing protection. Currently set to falsere-enable this (true) in any internet-facing deployment to prevent unauthorized cross-origin requests.

[browser]

These settings tell the browser-side client where to connect.

KeyDefaultValid valuesEffect
serverAddress"localhost"IP address or DNS nameThe address the browser uses to reach the server. "0.0.0.0" means the server accepts connections on all network interfaces, making it reachable from other machines on the network.
gatherUsageStatstruetrue, falseWhen true, anonymous usage data is sent to Streamlit. Set to false if your deployment environment does not permit outbound telemetry.
serverPortSame as server.portAny valid port integerThe port the browser connects to. This must match server.port (both are set to 80 here).

credentials.toml

This file stores optional account credentials used by Streamlit's sharing features.

[general]

KeyDefaultEffect
email""Your Streamlit account email. Required only if you use Streamlit Cloud sharing or liveSave. Leave blank for self-hosted deployments.

Usage

Once your configuration files are in place and dependencies are installed, you launch the application with a single command.

Starting the application:

streamlit run app.py --config config.toml

Because server.headless is set to true, no browser window opens automatically. Open your browser manually and navigate to:

http://localhost:80

or, if you are accessing from another machine on the network:

http://<your-server-ip>:80

During development, you may want to enable runOnSave so the app reloads whenever you modify the script:

[server]
runOnSave = true

In production, keep runOnSave = false and switch the log level to reduce output:

[logger]
level = "warning"

Restricting external access: If you only need local access, change serverAddress to "localhost" in [browser] and ensure server.port is set to a port not exposed publicly.

Tip: Always restart the application after editing config.toml for changes to take effect.


Examples

The examples below show common configuration scenarios you might encounter when deploying the plant-disease-predictor.


Example 1 — Local development setup (verbose logging, auto-reload)

Use this configuration when you are developing locally and want maximum feedback:

[logger]
level = "debug"

[server]
headless = false
runOnSave = true
port = 8501
enableCORS = true

[browser]
serverAddress = "localhost"
serverPort = 8501

Launch with:

streamlit run app.py

Expected behavior: Streamlit opens a browser tab at http://localhost:8501 automatically. Every time you save app.py, the app reruns. Debug messages appear in your terminal.


Example 2 — Production server deployment (headless, restricted logging)

Use this configuration when hosting on a remote server or VM:

[logger]
level = "warning"

[server]
headless = true
runOnSave = false
port = 80
enableCORS = true

[browser]
serverAddress = "0.0.0.0"
serverPort = 80

Launch with:

streamlit run app.py

Expected behavior: No browser opens on the server. The app is reachable at http://<your-server-ip> from any machine. Only warnings and errors appear in logs.


Example 3 — Disabling usage statistics

If your environment blocks outbound telemetry, add this to config.toml:

[browser]
gatherUsageStats = false

Expected behavior: No usage data is sent to Streamlit's servers. All other functionality remains unchanged.


Troubleshooting

Use the table below to diagnose and fix the most common configuration-related problems.


Problem: The app fails to start because port 80 is already in use

  • Symptom: Terminal shows OSError: [Errno 98] Address already in use or similar.
  • Likely cause: Another process (e.g., a web server like Apache or Nginx) is already listening on port 80.
  • Fix: Either stop the conflicting process, or change server.port and browser.serverPort in config.toml to an available port such as 8501, then restart.

Problem: Navigating to localhost:80 shows a blank page or connection refused

  • Symptom: Browser cannot load the app after running streamlit run app.py.
  • Likely cause: server.headless is false and the app tried to open a browser before fully initializing, or browser.serverAddress is set to "0.0.0.0" but you are connecting via localhost.
  • Fix: Confirm the terminal shows You can now view your Streamlit app in your browser. If serverAddress is "0.0.0.0", try navigating to http://127.0.0.1:80 instead.

Problem: Changes to config.toml have no effect

  • Symptom: After editing a setting, the app still behaves as before.
  • Likely cause: The application was not restarted after saving the file.
  • Fix: Stop the running process (Ctrl+C) and relaunch with streamlit run app.py. Configuration is only read at startup.

Problem: Excessive log output is cluttering the terminal

  • Symptom: The terminal is flooded with DEBUG messages during normal operation.
  • Likely cause: logger.level is set to "debug" in config.toml.
  • Fix: Change the level to "info" or "warning" for less verbose output, then restart the app.

Problem: The app is accessible from unintended external machines

  • Symptom: Users outside your network can reach the app, or security scans flag an open port.
  • Likely cause: browser.serverAddress is "0.0.0.0" and enableCORS is false, leaving the server open without cross-origin protection.
  • Fix: Set enableCORS = true in [server] immediately. If you only need local access, also change browser.serverAddress to "localhost" and restrict port 80 at your firewall level.

Problem: tensorflow or numpy import errors on startup

  • Symptom: Streamlit launches but shows an ImportError or ModuleNotFoundError in the browser or terminal.
  • Likely cause: Dependencies were not installed, or were installed at incompatible versions.
  • Fix: Run pip install -r requirements.txt again in the same Python environment you use to launch the app. Verify versions with pip show tensorflow numpy streamlit.