Giter VIP home page Giter VIP logo

sai-app's Introduction

StomaAI application

Installation (~10 minutes)

Windows Only Pre-Download Steps

Open command prompt as administrator and run wsl --install to enable Windows subsytem for linux. After this completes windows will need to restart. Visit the Microsoft Store and install Ubuntu 20.04 LTS. Once the store has downloaded the application launch Ubuntu 20.04 LTS from the start menu. The first time you run the Ubuntu app it will need sometime to setup and ask you to create a username and password to use in the application. Install the required pre-requisite packages by running the following commands:

sudo apt update
sudo apt install python3-pip

To ensure the python packages installed are accessible from the command line run:

echo -e "\nexport PATH=/home/$USER/.local/bin:\$PATH" >> ~/.bashrc
exec bash

Download SAI

To checkout the application to run locally on your machine run the commands:

git clone https://github.com/XDynames/SAI-app.git
cd SAI-app

Install

SAI can either use a computer's CPU to process samples or its GPU. The GPU will be significantly faster but requires some extra installation steps:

CPU mode
MacOS

Ensure you have Homebrew setup and install the following packages

brew install geos gdal libjpeg

If you have a Macbook that uses an Apple Silicone based CPU run

pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
Windows and Linux

Ensure you have libgeos installed:

sudo apt install libgeos-dev

Once the operation system specific steps are completed run:

bash setup.sh
GPU accelerated mode

Install the appropriate versions of Pytorch and Detectron2 to suit your GPU. Run bash setup_gpu.sh to install the remaining dependencies.

Docker

If you have docker and nvidia container runtime configured you can start SAI by running:

cd docker 
docker compose up

To make your data available to SAI inside the docker container modify the volume mount ../../stomata_data/:/code/data to suit your needs

Running SAI

Run ./SAI while inside the checked out folder. This will automatically open a webpage in your browser where you can view and use the application.

When using CPU only measurement time has been measured at 60-6 seconds per image, this is also dependant on image resolution. In GPU accelerated mode this time drops to 0.8-0.2 seconds per image.

Sample Images

If you want to test some samples the images we used for validation can be downloaded from here for Barley and Arabidopsis

Tested On

Windows: 10 & 11
Ubuntu: 20.04 & 18.04
MacOS: BigSur & Monterey

Referencing

If you use SAI as part of your work please cite us:

@article{https://doi.org/10.1111/nph.18765,
author = {Sai, Na and Bockman, James Paul and Chen, Hao and Watson-Haigh, Nathan and Xu, Bo and Feng, Xueying and Piechatzek, Adriane and Shen, Chunhua and Gilliham, Matthew},
title = {StomaAI: an efficient and user-friendly tool for measurement of stomatal pores and density using deep computer vision},
journal = {New Phytologist},
volume = {238},
number = {2},
pages = {904-915},
keywords = {applied deep learning, computer vision, convolutional neural network, phenotyping, stomata},
doi = {https://doi.org/10.1111/nph.18765},
url = {https://nph.onlinelibrary.wiley.com/doi/abs/10.1111/nph.18765},
eprint = {https://nph.onlinelibrary.wiley.com/doi/pdf/10.1111/nph.18765},
}

sai-app's People

Contributors

charlottesai avatar samhodge-aiml avatar xdynames avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sai-app's Issues

Empty intersections when uploading samples

I am using CPU mode. It calls an error when my uploading file to the app, as following:

2023-01-10 02:02:39.999 Uncaught app exception
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.dict)
File "/home/ubuntu/SAI-app/main.py", line 38, in
main()
File "/home/ubuntu/SAI-app/main.py", line 16, in main
maybe_do_inference()
File "/home/ubuntu/SAI-app/app/inference.py", line 58, in maybe_do_inference
maybe_do_single_image_inference()
File "/home/ubuntu/SAI-app/app/inference.py", line 71, in maybe_do_single_image_inference
predictions, valid_indices = predictions_to_list_of_dictionaries(
File "/home/ubuntu/SAI-app/app/inference.py", line 259, in predictions_to_list_of_dictionaries
predictions = [
File "/home/ubuntu/SAI-app/app/inference.py", line 260, in
predictions_to_dictionary(i, predictions, n_stoma, valid_indices)
File "/home/ubuntu/SAI-app/app/inference.py", line 281, in predictions_to_dictionary
pred_CD = find_CD(pred_polygon, pred_AB)
File "/home/ubuntu/SAI-app/app/inference.py", line 400, in find_CD
if len(intersections) > 2:
TypeError: object of type 'MultiPoint' has no len()

"MultiPoint" object not iterable

Hi

I am using the CPU mode. When I was trying out SAI on one of your example images from GitHub, I got this error:

2023-02-10 15:16:48.381 Uncaught app exception
Traceback (most recent call last):
File "/home/{user}/.local/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.dict)
File "/home/{user}/SAI-app/main.py", line 38, in
main()
File "/home/{user}/SAI-app/main.py", line 16, in main
maybe_do_inference()
File "/home/{user}/SAI-app/app/inference.py", line 58, in maybe_do_inference
maybe_do_single_image_inference()
File "/home/{user}/SAI-app/app/inference.py", line 71, in maybe_do_single_image_inference
predictions, valid_indices = predictions_to_list_of_dictionaries(
File "/home/{user}/SAI-app/app/inference.py", line 259, in predictions_to_list_of_dictionaries
predictions = [
File "/home/{user}/SAI-app/app/inference.py", line 260, in
predictions_to_dictionary(i, predictions, n_stoma, valid_indices)
File "/home/{user}/SAI-app/app/inference.py", line 281, in predictions_to_dictionary
pred_CD = find_CD(pred_polygon, pred_AB)
File "/home/{user}/SAI-app/app/inference.py", line 401, in find_CD
intersections = select_longest_line(intersections)
File "/home/{user}/SAI-app/app/inference.py", line 414, in select_longest_line
for i, point_1 in enumerate(multipoint):
TypeError: 'MultiPoint' object is not iterable

Cheers

Issue with Streamlit

Hi,

I installed SAI on my computer, following your recommandations. Everything seemed to work correctly but when I tried to access the streamlit I got an error message of this type:

"ImportError: libGL.so.1: cannot open shared object file: No such file or directory"

and the following lines of error:
"File "/home/rolehir/.local/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script
exec(code, module.dict)
File "/home/rolehir/SAI-app/main.py", line 3, in
from interface import ui
File "/home/rolehir/SAI-app/interface/ui.py", line 7, in
from .upload_single import display_upload_image
File "/home/rolehir/SAI-app/interface/upload_single.py", line 8, in
from tools.load import decode_downloaded_image
File "/home/rolehir/SAI-app/tools/load.py", line 10, in
import cv2
File "/home/rolehir/.local/lib/python3.10/site-packages/cv2/init.py", line 181, in
bootstrap()
File "/home/rolehir/.local/lib/python3.10/site-packages/cv2/init.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)"

I am not used to work with this kind of code. Could you help me with this issue?

Thanks in advance
Best,
Rozenn

HTTPError: HTTP Error 410: Gone

I get this error when attempting to run an example or process an image.
Does someone have an idea about it?

HTTPError: HTTP Error 410: Gone
Traceback:
File "/home/stomata/.local/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.dict)
File "/home/stomata/SAI-app/main.py", line 38, in
main()
File "/home/stomata/SAI-app/main.py", line 17, in main
maybe_draw_example()
File "/home/stomata/SAI-app/app/example_images.py", line 14, in maybe_draw_example
draw_example()
File "/home/stomata/SAI-app/app/example_images.py", line 24, in draw_example
image = get_selected_image()
File "/home/stomata/SAI-app/app/image_retrieval.py", line 12, in get_selected_image
image = get_example()
File "/home/stomata/SAI-app/app/image_retrieval.py", line 22, in get_example
image = download_example()
File "/home/stomata/SAI-app/app/image_retrieval.py", line 44, in download_example
return download_image(urls["image"] + "/download")
File "/home/stomata/.local/lib/python3.10/site-packages/streamlit/runtime/legacy_caching/caching.py", line 715, in wrapped_func
return get_or_create_cached_value()
File "/home/stomata/.local/lib/python3.10/site-packages/streamlit/runtime/legacy_caching/caching.py", line 696, in get_or_create_cached_value
return_value = non_optional_func(*args, **kwargs)
File "/home/stomata/SAI-app/tools/load.py", line 20, in download_image
with urllib.request.urlopen(url) as response:
File "/usr/lib/python3.10/urllib/request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.10/urllib/request.py", line 525, in open
response = meth(req, response)
File "/usr/lib/python3.10/urllib/request.py", line 634, in http_response
response = self.parent.error(
File "/usr/lib/python3.10/urllib/request.py", line 563, in error
return self._call_chain(*args)
File "/usr/lib/python3.10/urllib/request.py", line 496, in _call_chain
result = func(*args)
File "/usr/lib/python3.10/urllib/request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)

warning and error...

Dear Mr. James
I am a PC novice from Japan.
I would like to install StomaAI on my PC (Windows 11), but when I run "bash setup.sh" in the installation instructions, I get the following warning and error

"DEPRECATION: The HTML index page being used (https://download.pytorch.org/whl/torch_stable.html) is not a proper HTML 5 document. This is in violation of PEP 503 which requires these pages to be well-formed HTML 5 documents. Please reach out to the owners of this index page, and ask them Please reach out to the owners of this index page, and ask them to update this index page to a valid HTML 5 document. pip 22.2 will enforce this behaviour change. Discussion can be found at https://github.com/pypa/pip /issues/10825
ERROR: Could not find a version that satisfies the requirement torch==1.8.1+cpu (from versions: 1.11.0, 1.11.0+cpu, 1.11.0+cu102, 1.11.0+cu113, 1. 11.0+cu115, 1.11.0+rocm4.3.1, 1.11.0+rocm4.5.2, 1.12.0, 1.12.0+cpu, 1.12.0+cu102, 1.12.0+cu113, 1.12.0+cu116, 1.12.0+rocm5. 1.1, 1.12.1, 1.12.1+cpu, 1.12.1+cu102, 1.12.1+cu113, 1.12.1+cu116, 1.12.1+rocm5.0, 1.12.1+rocm5.1.1, 1.13.0, 1.13.0+cpu, 1.13.0+cu116, 1.13.0 +cu117, 1.13.0+cu117.with.pypi.cudnn, 1.13.0+rocm5.1.1, 1.13.0+rocm5.2, 1.13.1, 1.13.1+cpu, 1.13.1+cu116, 1.13.1+cu117, 1.13.1+cu117.with. pypi.cudnn, 1.13.1+rocm5.1.1, 1.13.1+rocm5.2, 2.0.0, 2.0.0+cpu, 2.0.0+cpu.cxx11.abi, 2.0.0+cu117, 2.0.0+cu117.with.pypi.cudnn, 2.0.0+cu118 2.0.0+rocm5.3, 2.0.0+rocm5.4.2)
ERROR: No matching distribution found for torch==1.8.1+cpu"

I have also checked the administrator of "https://download.pytorch.org/whl/torch_stable.html" but I can't figure it out.

If you know how I can install StomaAI, please let me know.

Best regards.

ZeroDivisionError: division by zero

Hi!
Im running the SAI app in Ubuntu 20.04.5 LTS (GNU/Linux 5.15.79.1-microsoft-standard-WSL2 x86_64).

When I analyze a group of images, at the end of the analysis it returns this error:

ZeroDivisionError: division by zero

Traceback:
File "/home/stomata/.local/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.dict)
File "/home/stomata/SAI-app/main.py", line 38, in
main()
File "/home/stomata/SAI-app/main.py", line 16, in main
maybe_do_inference()
File "/home/stomata/SAI-app/app/inference.py", line 63, in maybe_do_inference
maybe_do_inference_on_all_images_in_folder()
File "/home/stomata/SAI-app/app/inference.py", line 114, in maybe_do_inference_on_all_images_in_folder
do_inference_on_all_images_in_folder()
File "/home/stomata/SAI-app/app/inference.py", line 201, in do_inference_on_all_images_in_folder
remove_outliers_from_records()
File "/home/stomata/SAI-app/inference/post_processing.py", line 168, in remove_outliers_from_records
remove_outliers(record, filename)
File "/home/stomata/SAI-app/inference/post_processing.py", line 199, in remove_outliers
remove_bounding_box_outliers(record)
File "/home/stomata/SAI-app/inference/post_processing.py", line 211, in remove_bounding_box_outliers
remove_bounding_box_height_outliers(record, near_edge_indices)
File "/home/stomata/SAI-app/inference/post_processing.py", line 228, in remove_bounding_box_height_outliers
to_remove = find_outlier_bbox_indices(
File "/home/stomata/SAI-app/inference/post_processing.py", line 277, in find_outlier_bbox_indices
if is_less_than_half_of_average_size(
File "/home/stomata/SAI-app/inference/post_processing.py", line 291, in is_less_than_half_of_average_size
average_size = sum(valid_sizes) / len(valid_sizes)

What could be happening (im not an advance user)?

Lacks an .png

Apparently there is a .png lacking, which calls an error that does not allow the app to initialize.

<img class="logo-img" src="data:image/png;base64,{base64.b64encode(open('logos/sai.png', "rb").read()).decode()}">
FileNotFoundError: [Errno 2] No such file or directory: 'logos/sai.png'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.