Skip to main content

Count corn kernels and rows from ear images — deep-learning desktop app and Python library

Project description

cornvision

Offline corn kernel detection and row counting from ear images.

CornVision demo

Installation

pip install -e .

Model weights are downloaded automatically from Hugging Face on first run and cached at ~/.cornvision/model.pth.

Usage

GUI

cornvision

The GUI supports both single and batch inference:

Control Description
Add Images… Add one or more images to the queue
Remove / Clear All Remove selected or all images from the queue
Device Select inference device (auto, cpu, cuda, mps)
Analyze All Run inference on all pending images in sequence
Stop Halt the batch after the current image finishes
Save Annotated… Save the annotated image for the selected result
Export CSV… Export all completed results to a CSV file

Queue items are colour-coded: pending, running, done, error.

Python API

from cornvision import CornAnalyzer

analyzer = CornAnalyzer()          # loads model, downloads weights if needed
result = analyzer.analyze("corn.jpg")

print(result.total_kernels)        # int
print(result.total_rows)           # int
print(result.kernels_per_row)      # list[int]
print(result.inference_time_sec)   # float

result.save_viz("annotated.png")   # save annotated image to disk

CornAnalyzer loads the model once and can analyze multiple images:

for path in image_paths:
    result = analyzer.analyze(path)

CornAnalyzer(device="auto")

Parameter Description
device "auto" (default) picks CUDA → MPS → CPU automatically

AnalysisResult fields

Field Type Description
total_kernels int Total detected kernels
total_rows int Number of kernel rows
kernels_per_row list[int] Kernel count per row
inference_time_sec float Wall-clock inference time
average_kernel_width_mm float Estimated mean kernel width
average_kernel_height_mm float Estimated mean kernel height
viz_image PIL.Image | None Annotated image (in-memory)

Dependencies

Package Purpose
torch / torchvision Model inference
Pillow Image I/O and visualization
numpy Array operations
requests Weight download

tkinter is used for the GUI and ships with the standard Python installer.

Project layout

src/cornvision/
├── __init__.py       # public API: CornAnalyzer, AnalysisResult
├── _gui.py           # tkinter GUI (entry point)
├── _analyzer.py      # CornAnalyzer — model load + analyze()
├── _inference.py     # end-to-end inference pipeline
├── _clustering.py    # kernel row clustering
├── _image_proc.py    # image pre/post-processing helpers
├── _model.py         # model architecture + weight loading
├── _download.py      # weight download + cache path
├── _config.py        # shared constants
└── _result.py        # AnalysisResult dataclass

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cornvision-0.1.0.tar.gz (3.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cornvision-0.1.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file cornvision-0.1.0.tar.gz.

File metadata

  • Download URL: cornvision-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cornvision-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0dfafd508acba74ef68946e6489f32f6650b33bc855e57deba867216397ed78
MD5 e134a038bbd8d71dc48494ff623c2a9d
BLAKE2b-256 c6b301192f633f3e4bc1290bffeb676a132ae9826605c1e75e3eb37ba4a599c9

See more details on using hashes here.

File details

Details for the file cornvision-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cornvision-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cornvision-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6186c6e703e35b54f015264ba606a1fcd33d4cca56ea65ef87b151f89fdfb511
MD5 c8f5cdc8de1f04a7b8e0c1bfa1b9e994
BLAKE2b-256 84f9ee717cf9ccca84e37a50dc62ee87b42b15ed0f1322072e064bf85b509cd4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page