Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vincentblot28/multiaccurate-cp
https://github.com/vincentblot28/multiaccurate-cp
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/vincentblot28/multiaccurate-cp
- Owner: vincentblot28
- Created: 2024-03-15T09:21:23.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2024-08-18T11:43:40.000Z (3 months ago)
- Last Synced: 2024-10-13T17:52:13.499Z (25 days ago)
- Language: Jupyter Notebook
- Size: 52.4 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Automatically Adaptive Conformal Prediction
===============This is the official repository of the paper ["Automatically Adaptive Conformal Prediction"](https://arxiv.org/abs/2406.17819).
![teaser](teaser.png)
๐ Datasets
===============We used two datasets for our experiments: Polyp Dataset ([train dataset](https://drive.google.com/file/d/1Y2z7FD5p5y31vkZwQQomXFRB0HutHyao/view?usp=sharing) and [test dataset](https://drive.google.com/file/d/1YiGHLw4iTvKdvbT6MgwO9zcCv8zJ_Bnb/view?usp=sharing)) and the [Fire segmentation dataset](https://www.kaggle.com/datasets/diversisai/fire-segmentation-image-dataset)
๐จโ๐ณ Prepare data
===============In order to run our different algorithms, data are expected to be stored as follow:
โโโ ...
โโโ data
โโโ polyp
โ โโโ train
| | โโโ images
| | โโโ labels
โ โโโ val
| | โโโ images
| | โโโ labels
โ โโโ res
| | โโโ images
| | โโโ labels
โ โโโ cal
| | โโโ images
| | โโโ labels
โ โโโ test
| โโโ images
| โโโ labels
โโโ fire
โโโ train
| โโโ images
| โโโ labels
โโโ ...
โโโ test
โโโ images
โโโ labels๐โโ๏ธTrain model
===============The architecture as well as the trained weights for the PraNet model can be found [here](https://github.com/DengPingFan/PraNet). So here we only need to train a UNet for the fire segmentation
```bash
$ python multiaccurate_cp/main.py train --ml-data-dir=data/fire/02_prepared_data --output-dir=data/fire/03_model_weights/unet
```๐ฎ Semantic segmentation inference
===============For each model, the inference has to be run on the residual, calibration and test datasets
### UNet inference
```bash
$ python multiaccurate_cp/main.py infer-unet --model-dir=data/fire/03_model_weights/unet --model-name=$MODEL_NAME --data-dir=data/fire/02_prepared_data --ml-set=$ML_SET --output-dir=data/fire/04_predictions/
```### PraNet inference
```bash
$ python multiaccurate_cp/main.py infer-polyp --data-dir=data/polyp/02_prepared_data --output-dir=data/polyp/04_predictions/ --model-dir=data/polyp/03_model_weights/pranet ml-set=$ML_SET
```๐ Train embedding model
===============```bash
$ python multiaccurate_cp/main.py train-residual --ml-data-dir=data/$DATASET/02_prepared_data --probas-dir=data/$DATASET/04_predictions --output-dir=data/$DATASET/03_model_weights/resnet --model.resnet=resnet50 --model.model-input=image_and_probas --model.embedding-size=1024
```๐ฅ Inference residual
===============
```bash
$ python multiaccurate_cp/main.py infer-residual --model-dir=data/$DATASET/03_model_weights/resnet --model-name=$MODEL_NAME --data-dir=data/$DATASET/02_prepared_data --pred-proba-dir=data/$DATASET/04_predictions --ml-set=$ML_SET
```โก Theta optimization quickstart
===============```python
from scipy.optimize import minimizefrom multiaccurate_cp.utils.multiaccurate import J, J_prime
ALPHA = .1
N = len(cal_labels)lambda_ridge = .01
optimal_theta = minimize(
J, np.random.uniform(0, 1, RESNET_EMBEDDING_SIZE),
method="SLSQP",
args=(
cal_labels,
cal_pred_probas,
cal_emb,
ALPHA,
N,
regularization="ridge",
lambda_ridge
), jac=J_prime,
options={"disp": True, "maxiter": 1000}, tol=1e-10
)
```