{"id":21358154,"url":"https://github.com/boemer00/signet-ring-cv","last_synced_at":"2025-04-15T09:08:04.558Z","repository":{"id":212107864,"uuid":"730592696","full_name":"boemer00/signet-ring-cv","owner":"boemer00","description":"This project focuses on classifying pathological images of signet ring cells from the WSI of gastrointestinal tissues.","archived":false,"fork":false,"pushed_at":"2024-09-26T16:03:17.000Z","size":387705,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-22T05:14:28.723Z","etag":null,"topics":["classification","computer-vision","image-classification","keras","neural-networks","pathology","python","recall","vgg19"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boemer00.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-12T09:05:18.000Z","updated_at":"2024-11-03T09:04:42.000Z","dependencies_parsed_at":"2023-12-18T14:03:46.485Z","dependency_job_id":null,"html_url":"https://github.com/boemer00/signet-ring-cv","commit_stats":null,"previous_names":["boemer00/signet-ring-cv"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boemer00%2Fsignet-ring-cv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boemer00%2Fsignet-ring-cv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boemer00%2Fsignet-ring-cv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boemer00%2Fsignet-ring-cv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boemer00","download_url":"https://codeload.github.com/boemer00/signet-ring-cv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235163674,"owners_count":18945891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classification","computer-vision","image-classification","keras","neural-networks","pathology","python","recall","vgg19"],"created_at":"2024-11-22T05:14:40.176Z","updated_at":"2025-01-22T18:26:34.589Z","avatar_url":"https://github.com/boemer00.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Signet Ring Cell Classification Model\n\n## Introduction\nThis project presents a classification algorithm of signet ring cell carcinoma in histopathological images. Ultimately, the projects addresses the significant challenge of early detection of rare but aggressive carcinomas.\n\n## Background\nSignet ring cell carcinoma is a rare form of adenocarcinoma, known for its poor prognosis. So, accurate detection of these cells is key to improving patient survival rates. The project uses a unique dataset comprising both positive and negative samples to train a classification model.\n\n## Dataset Description\nThe dataset includes:\n- **Positive Samples**: 77 images from 20 Whole Slide Images (WSIs).\n- **Negative Samples**: 378 images from 79 WSIs, potentially containing other tumor cells but no signet ring cells.\n\nEach image is 2000x2000 pixels, sourced from gastric mucosa and intestine tissues, stained with hematoxylin and eosin, and scanned at X40 magnification. While the original dataset includes annotated information, this project does not require such information.\n\n![.](docs/signet_ring_computer_vision_model.png)\n\n## Installation\nTo set up the project environment:\n\n`git clone https://github.com/boemer00/signet-ring-cell-classification.git`\n\n`cd signet-ring-cell-classification`\n\n`pip install -r requirements.txt`\n\n## Usage\n\n### Training the Model\n\nTo train the model, execute the following command:\n\n`python src/trainer.py`\n\nThis script uses the model in `src/trainer.py` and saves the trained model for future use.\n\n### Making Predictions Using FastAPI\n\nThis project also includes a FastAPI application for deploying the trained model as a web service, which allows users to upload images and receive predictions.\n\n#### Starting the FastAPI Server\n\nTo start the FastAPI server, run:\n\n`uvicorn app.main:app --reload`\n\nThis command will launch the server, making the API accessible at `http://127.0.0.1:8000`. The `--reload` flag is useful during development as it automatically reloads the server when code changes are made.\n\n#### Using the Prediction Endpoint\n\nOnce the server is running, you can make predictions by sending image files to the `/predict/` endpoint. This can be done using the Swagger UI:\n\n1. Navigate to `http://127.0.0.1:8000/docs` in your web browser.\n2. Locate the `/predict/` endpoint and use the interactive UI to upload an image file.\n3. Submit the request, and the API will return the model's prediction for the uploaded image.\n\nThe FastAPI application uses the `SignetRingPredictor` class from `src/predictor.py` for processing the image and generating predictions.\n\n\n## Running Tests\nTo run tests for this project, navigate to the project directory and activate a virtual environment (recommended). Use the pytest command to execute tests. For detailed output, use `pytest -v`. If using *pytest-cov* for test coverage, view the report with `pytest --cov=src`\n\n## Model Architecture and Training\n\nThe classification model is built on the VGG19 architecture, with specific customizations for signet ring cell classification. The model includes a `SignetRingPredictor` class, which encapsulates the model's loading and prediction logic, making it seamlessly integrable with FastAPI for deployment.\n\n- **Base Model**: VGG19 pre-trained on ImageNet, without the top layer.\n- **Custom Layers**: Global Average Pooling, Dense, Dropout, and Output layers tailored for binary classification.\n- **Compilation**: Compiled with the Adam optimizer, binary cross-entropy loss, and includes accuracy and recall metrics.\n\nThe model's architecture and training details are elaborated in `src/trainer.py`. The `SignetRingPredictor` class, which you can use for predictions--for more details see `src/predictor.py`.\n\n## Results and Evaluation\n\nThe evaluation of the classification model focuses on the same three metrics established in the paper:\n\n- **Recall**: The model is designed to prioritise recall, ensuring that the rate of missed signet ring cells (false negatives). While the the minimum acceptable threshold of 20% in in the paper, this current model demonstrated a **recall rate of 75%**. Recall is crucial for medical applications where the cost of missing positive cases is high.\n\n- **Normal Region FP (FPNormal)**: This metric measures the average number of false positives per image in normal (non-cancerous) regions. This project achieved **FPNormal = 11.0** which indicates that, on average, the model incorrectly identifies 11 regions per image as cancerous when they are, in fact, normal. In a clinical setting, a low FPNormal is preferred, as it means fewer false alarms.\n\n- **Free-response ROC (FROC)**: The FROC curve is a plot of the true positive rate against the average number of false positives per image. This metric shows the model's ability to maintain a balance between sensitivity (*aka* recall) and the false positive rate across different thresholds. Below is a fixed levels of FPPI:\n  - Sensitivity at 1 FPPI: 0.45\n  - Sensitivity at 2 FPPI: 0.45\n  - Sensitivity at 4 FPPI: 0.75\n  - Sensitivity at 5 FPPI: 0.75\n\n  Sensitivity at 5 FPPI (75%) indicates that the model's threshold to a level where it is allowed to make, on average, 5 false positive detections per image, it will correctly identify 75% of the true positive cases (actual disease presence). However, in a clinical setting, determining an acceptable FPPI level depends on various factors.\n\n## Areas of Improvement\n\n- The current model would benefit from a larger training set to handle a wider staining variability. While hematoxylin and eosin staining aids the detection process, different lab protocals or the age of the chemical might affect colour intensity. Therefore, future versions should include more images from different labs as well as a more stain-specific tuning.\n\n- Creating a standard protocol on the handling of WSI for computer vision models could improve image quality due to factors like uneven lighting, artifacts, or blur. Improper handling of WSI can hinder the model's ability to accurately analyse the image.\n\nOverall, computer vision models in histopathology would benefit from quality and consistency of improved processes.\n\n## Citation\nDa Q, Huang X, Li Z, et al. [DigestPath: a Benchmark Dataset with Challenge Review for the\nPathological Detection and Segmentation of Digestive-System](https://doi.org/10.1016/j.media.2022.102485)[J].\nMedical Image Analysis, 2022: 102485.\n\n[GitHub repo for the original project](https://github.com/bupt-ai-cz/CAC-UNet-DigestPath2019/blob/main/papers/DigestPath-a-Benchmark-Dataset-with-Challenge-Review.pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboemer00%2Fsignet-ring-cv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboemer00%2Fsignet-ring-cv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboemer00%2Fsignet-ring-cv/lists"}