Spaces:
Running
Running
nathbotbol
commited on
Commit
•
d7aea57
1
Parent(s):
8fc7013
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +73 -0
- .gitignore +5 -0
- README.md +43 -7
- data/test_sample.png +3 -0
- download_model.sh +11 -0
- engie_pipeline/__init__.py +0 -0
- engie_pipeline/app.py +53 -0
- engie_pipeline/eval.py +85 -0
- engie_pipeline/models/__init__.py +6 -0
- engie_pipeline/models/detr.py +125 -0
- engie_pipeline/models/siglip.py +92 -0
- engie_pipeline/pipeline.py +145 -0
- engie_pipeline/utils.py +17 -0
- models/detr.ckpt +3 -0
- models/siglip.ckpt +3 -0
- requirements.txt +8 -0
- venv/bin/Activate.ps1 +247 -0
- venv/bin/activate +69 -0
- venv/bin/activate.csh +26 -0
- venv/bin/activate.fish +69 -0
- venv/bin/convert-caffe2-to-onnx +8 -0
- venv/bin/convert-onnx-to-caffe2 +8 -0
- venv/bin/cpuinfo +8 -0
- venv/bin/dotenv +8 -0
- venv/bin/email_validator +8 -0
- venv/bin/f2py +8 -0
- venv/bin/fastapi +8 -0
- venv/bin/fonttools +8 -0
- venv/bin/gradio +8 -0
- venv/bin/httpx +8 -0
- venv/bin/huggingface-cli +8 -0
- venv/bin/isympy +8 -0
- venv/bin/jsonschema +8 -0
- venv/bin/markdown-it +8 -0
- venv/bin/normalizer +8 -0
- venv/bin/pip +8 -0
- venv/bin/pip3 +8 -0
- venv/bin/pip3.11 +8 -0
- venv/bin/pyftmerge +8 -0
- venv/bin/pyftsubset +8 -0
- venv/bin/pygmentize +8 -0
- venv/bin/python +3 -0
- venv/bin/python3 +3 -0
- venv/bin/python3.11 +3 -0
- venv/bin/ruff +3 -0
- venv/bin/torchrun +8 -0
- venv/bin/tqdm +8 -0
- venv/bin/transformers-cli +8 -0
- venv/bin/ttx +8 -0
- venv/bin/typer +8 -0
.gitattributes
CHANGED
@@ -33,3 +33,76 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
data/test_sample.png filter=lfs diff=lfs merge=lfs -text
|
37 |
+
venv/bin/python filter=lfs diff=lfs merge=lfs -text
|
38 |
+
venv/bin/python3 filter=lfs diff=lfs merge=lfs -text
|
39 |
+
venv/bin/python3.11 filter=lfs diff=lfs merge=lfs -text
|
40 |
+
venv/bin/ruff filter=lfs diff=lfs merge=lfs -text
|
41 |
+
venv/lib/python3.11/site-packages/PIL/_imaging.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
42 |
+
venv/lib/python3.11/site-packages/aiohttp/_http_parser.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
43 |
+
venv/lib/python3.11/site-packages/fontTools/cu2qu/cu2qu.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
44 |
+
venv/lib/python3.11/site-packages/fontTools/feaLib/lexer.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
45 |
+
venv/lib/python3.11/site-packages/fontTools/misc/bezierTools.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
46 |
+
venv/lib/python3.11/site-packages/fontTools/pens/momentsPen.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
47 |
+
venv/lib/python3.11/site-packages/fontTools/qu2cu/qu2cu.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
48 |
+
venv/lib/python3.11/site-packages/fontTools/varLib/iup.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
49 |
+
venv/lib/python3.11/site-packages/gradio/frpc_linux_amd64_v0.2 filter=lfs diff=lfs merge=lfs -text
|
50 |
+
venv/lib/python3.11/site-packages/gradio/templates/frontend/assets/Index-CUTYDExL.js.map filter=lfs diff=lfs merge=lfs -text
|
51 |
+
venv/lib/python3.11/site-packages/kiwisolver/_cext.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
52 |
+
venv/lib/python3.11/site-packages/numpy/core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
53 |
+
venv/lib/python3.11/site-packages/numpy/core/_simd.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
54 |
+
venv/lib/python3.11/site-packages/numpy.libs/libgfortran-040039e1.so.5.0.0 filter=lfs diff=lfs merge=lfs -text
|
55 |
+
venv/lib/python3.11/site-packages/numpy.libs/libopenblas64_p-r0-0cf96a72.3.23.dev.so filter=lfs diff=lfs merge=lfs -text
|
56 |
+
venv/lib/python3.11/site-packages/nvidia/cublas/lib/libcublas.so.12 filter=lfs diff=lfs merge=lfs -text
|
57 |
+
venv/lib/python3.11/site-packages/nvidia/cublas/lib/libcublasLt.so.12 filter=lfs diff=lfs merge=lfs -text
|
58 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_cupti/lib/libcheckpoint.so filter=lfs diff=lfs merge=lfs -text
|
59 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_cupti/lib/libcupti.so.12 filter=lfs diff=lfs merge=lfs -text
|
60 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_cupti/lib/libnvperf_host.so filter=lfs diff=lfs merge=lfs -text
|
61 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_cupti/lib/libnvperf_target.so filter=lfs diff=lfs merge=lfs -text
|
62 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_nvrtc/lib/libnvrtc-builtins.so.12.1 filter=lfs diff=lfs merge=lfs -text
|
63 |
+
venv/lib/python3.11/site-packages/nvidia/cuda_nvrtc/lib/libnvrtc.so.12 filter=lfs diff=lfs merge=lfs -text
|
64 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_adv_infer.so.8 filter=lfs diff=lfs merge=lfs -text
|
65 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_adv_train.so.8 filter=lfs diff=lfs merge=lfs -text
|
66 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_cnn_infer.so.8 filter=lfs diff=lfs merge=lfs -text
|
67 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_cnn_train.so.8 filter=lfs diff=lfs merge=lfs -text
|
68 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_ops_infer.so.8 filter=lfs diff=lfs merge=lfs -text
|
69 |
+
venv/lib/python3.11/site-packages/nvidia/cudnn/lib/libcudnn_ops_train.so.8 filter=lfs diff=lfs merge=lfs -text
|
70 |
+
venv/lib/python3.11/site-packages/nvidia/cufft/lib/libcufft.so.11 filter=lfs diff=lfs merge=lfs -text
|
71 |
+
venv/lib/python3.11/site-packages/nvidia/cufft/lib/libcufftw.so.11 filter=lfs diff=lfs merge=lfs -text
|
72 |
+
venv/lib/python3.11/site-packages/nvidia/curand/lib/libcurand.so.10 filter=lfs diff=lfs merge=lfs -text
|
73 |
+
venv/lib/python3.11/site-packages/nvidia/cusolver/lib/libcusolver.so.11 filter=lfs diff=lfs merge=lfs -text
|
74 |
+
venv/lib/python3.11/site-packages/nvidia/cusolver/lib/libcusolverMg.so.11 filter=lfs diff=lfs merge=lfs -text
|
75 |
+
venv/lib/python3.11/site-packages/nvidia/cusparse/lib/libcusparse.so.12 filter=lfs diff=lfs merge=lfs -text
|
76 |
+
venv/lib/python3.11/site-packages/nvidia/nccl/lib/libnccl.so.2 filter=lfs diff=lfs merge=lfs -text
|
77 |
+
venv/lib/python3.11/site-packages/nvidia/nvjitlink/lib/libnvJitLink.so.12 filter=lfs diff=lfs merge=lfs -text
|
78 |
+
venv/lib/python3.11/site-packages/pandas/_libs/algos.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
79 |
+
venv/lib/python3.11/site-packages/pandas/_libs/groupby.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
80 |
+
venv/lib/python3.11/site-packages/pandas/_libs/hashtable.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
81 |
+
venv/lib/python3.11/site-packages/pandas/_libs/interval.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
82 |
+
venv/lib/python3.11/site-packages/pandas/_libs/join.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
83 |
+
venv/lib/python3.11/site-packages/pandas/_libs/tslibs/offsets.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
84 |
+
venv/lib/python3.11/site-packages/pillow.libs/libfreetype-1f2cdfbb.so.6.20.1 filter=lfs diff=lfs merge=lfs -text
|
85 |
+
venv/lib/python3.11/site-packages/pillow.libs/libharfbuzz-8b0b6641.so.0.60840.0 filter=lfs diff=lfs merge=lfs -text
|
86 |
+
venv/lib/python3.11/site-packages/pydantic_core/_pydantic_core.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
87 |
+
venv/lib/python3.11/site-packages/regex/_regex.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
88 |
+
venv/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
89 |
+
venv/lib/python3.11/site-packages/safetensors/_safetensors_rust.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
90 |
+
venv/lib/python3.11/site-packages/tokenizers/tokenizers.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
91 |
+
venv/lib/python3.11/site-packages/torch/bin/protoc filter=lfs diff=lfs merge=lfs -text
|
92 |
+
venv/lib/python3.11/site-packages/torch/bin/protoc-3.13.0.0 filter=lfs diff=lfs merge=lfs -text
|
93 |
+
venv/lib/python3.11/site-packages/torch/lib/libc10.so filter=lfs diff=lfs merge=lfs -text
|
94 |
+
venv/lib/python3.11/site-packages/torch/lib/libcusparseLt-f80c68d1.so.0 filter=lfs diff=lfs merge=lfs -text
|
95 |
+
venv/lib/python3.11/site-packages/torch/lib/libtorch_cpu.so filter=lfs diff=lfs merge=lfs -text
|
96 |
+
venv/lib/python3.11/site-packages/torch/lib/libtorch_cuda.so filter=lfs diff=lfs merge=lfs -text
|
97 |
+
venv/lib/python3.11/site-packages/torch/lib/libtorch_cuda_linalg.so filter=lfs diff=lfs merge=lfs -text
|
98 |
+
venv/lib/python3.11/site-packages/torch/lib/libtorch_python.so filter=lfs diff=lfs merge=lfs -text
|
99 |
+
venv/lib/python3.11/site-packages/torchvision/_C.so filter=lfs diff=lfs merge=lfs -text
|
100 |
+
venv/lib/python3.11/site-packages/torchvision.libs/libnvjpeg.f00ca762.so.12 filter=lfs diff=lfs merge=lfs -text
|
101 |
+
venv/lib/python3.11/site-packages/torchvision.libs/libpng16.7f72a3c5.so.16 filter=lfs diff=lfs merge=lfs -text
|
102 |
+
venv/lib/python3.11/site-packages/triton/_C/libtriton.so filter=lfs diff=lfs merge=lfs -text
|
103 |
+
venv/lib/python3.11/site-packages/triton/third_party/cuda/bin/nvdisasm filter=lfs diff=lfs merge=lfs -text
|
104 |
+
venv/lib/python3.11/site-packages/triton/third_party/cuda/bin/ptxas filter=lfs diff=lfs merge=lfs -text
|
105 |
+
venv/lib/python3.11/site-packages/uvloop/loop.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
106 |
+
venv/lib/python3.11/site-packages/watchfiles/_rust_notify.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
107 |
+
venv/lib/python3.11/site-packages/yaml/_yaml.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
108 |
+
venv/lib/python3.11/site-packages/yarl/_quoting_c.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.idea
|
2 |
+
*.DS_Store
|
3 |
+
|
4 |
+
*.pyc
|
5 |
+
|
README.md
CHANGED
@@ -1,12 +1,48 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
colorFrom: gray
|
5 |
-
colorTo: yellow
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.36.1
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
|
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: pipeline
|
3 |
+
app_file: engie_pipeline/app.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
sdk_version: 4.36.1
|
|
|
|
|
6 |
---
|
7 |
+
# Engie pipeline
|
8 |
|
9 |
+
---
|
10 |
+
|
11 |
+
### Installation
|
12 |
+
|
13 |
+
Python >=3.10 is required for the project. To install all the dependencies, simply run:
|
14 |
+
|
15 |
+
```shell
|
16 |
+
pip install -r requirements.txt
|
17 |
+
```
|
18 |
+
|
19 |
+
To download the needed model to run the pipeline, execute the following command:
|
20 |
+
|
21 |
+
```shell
|
22 |
+
bash download_model.sh
|
23 |
+
```
|
24 |
+
|
25 |
+
---
|
26 |
+
|
27 |
+
### Execution
|
28 |
+
|
29 |
+
To execute the pipeline, run the following command:
|
30 |
+
|
31 |
+
```shell
|
32 |
+
python -m engie_pipeline.pipeline
|
33 |
+
```
|
34 |
+
|
35 |
+
Change one or more parameter of the pipeline process with:
|
36 |
+
```shell
|
37 |
+
python -m engie_pipeline.pipeline with path="<path/to/file/or/folder>" output_path="<path/to/output/folder" conformity_threshold=0.8
|
38 |
+
```
|
39 |
+
|
40 |
+
if the `path` parameter is set to a folder, all the images found in the folder will be processed. The supported image types are ".jpg", ".jpeg", ".png"
|
41 |
+
|
42 |
+
### App
|
43 |
+
|
44 |
+
To launch the app, run:
|
45 |
+
|
46 |
+
```shell
|
47 |
+
python -m engie_pipeline.app
|
48 |
+
```
|
data/test_sample.png
ADDED
Git LFS Details
|
download_model.sh
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
if [ ! -f './models/detr.ckpt' ]
|
2 |
+
then
|
3 |
+
echo "Downloading DeTr detection model"
|
4 |
+
gsutil cp gs://illuin-engie-tableaux-sky-training/last-v6.ckpt ./models/detr.ckpt
|
5 |
+
fi
|
6 |
+
|
7 |
+
if [ ! -f './models/siglip.ckpt' ]
|
8 |
+
then
|
9 |
+
echo "Downloading siglip classification model"
|
10 |
+
gsutil cp gs://illuin-engie-tableaux-classification-training/last-v1.ckpt ./models/siglip.ckpt
|
11 |
+
fi
|
engie_pipeline/__init__.py
ADDED
File without changes
|
engie_pipeline/app.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
import pandas as pd
|
5 |
+
from PIL import ImageDraw
|
6 |
+
from PIL.Image import Image
|
7 |
+
from sacred import Experiment
|
8 |
+
|
9 |
+
from engie_pipeline.pipeline import pipeline_experiment, set_up_pipeline, pipeline
|
10 |
+
from engie_pipeline.utils import draw_boxes
|
11 |
+
|
12 |
+
ex = Experiment("app", ingredients=[pipeline_experiment])
|
13 |
+
|
14 |
+
|
15 |
+
def process_image(models, image: Image, comformity_threshold: float):
|
16 |
+
image = image.convert("RGB")
|
17 |
+
siglip_probs, boxes, labels, scores, comformity = pipeline(**models, image=image, conformity_threshold=comformity_threshold, force_detr=True)
|
18 |
+
|
19 |
+
image = draw_boxes(
|
20 |
+
image=image, boxes=boxes[labels == 0], probs=scores[labels == 0], color="gray"
|
21 |
+
)
|
22 |
+
|
23 |
+
image = draw_boxes(
|
24 |
+
image=image, boxes=boxes[labels == 1], probs=scores[labels == 1], color="orange"
|
25 |
+
)
|
26 |
+
image = draw_boxes(
|
27 |
+
image=image, boxes=boxes[labels == 2], probs=scores[labels == 2], color="purple"
|
28 |
+
)
|
29 |
+
|
30 |
+
siglip_probs = pd.DataFrame(
|
31 |
+
siglip_probs.detach().numpy(),
|
32 |
+
columns=["Admissible", "Hors-sujet", "Non-admissible"],
|
33 |
+
)
|
34 |
+
return siglip_probs, image, comformity
|
35 |
+
|
36 |
+
|
37 |
+
@ex.automain
|
38 |
+
def app():
|
39 |
+
models = set_up_pipeline()
|
40 |
+
|
41 |
+
image_input = gr.Image(label="Input image", type="pil")
|
42 |
+
comformity_threshold = gr.Slider(minimum=0, maximum=1, step=0.01, value=0.8)
|
43 |
+
prob_output = gr.DataFrame(label="Probabilities (%)")
|
44 |
+
image_output = gr.Image(label="Output image")
|
45 |
+
label = gr.Label(label="Is the image conform?")
|
46 |
+
|
47 |
+
demo = gr.Interface(
|
48 |
+
fn=lambda im, thresh: process_image(models=models, image=im, comformity_threshold=thresh),
|
49 |
+
inputs=[image_input, comformity_threshold],
|
50 |
+
outputs=[prob_output, image_output, label],
|
51 |
+
)
|
52 |
+
|
53 |
+
demo.launch(auth=(os.environ.get("GRADIO_USERNAME"), os.environ.get("GRADIO_PASSWORD")))
|
engie_pipeline/eval.py
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os.path
|
3 |
+
|
4 |
+
from PIL import Image
|
5 |
+
import tqdm
|
6 |
+
from sacred import Experiment
|
7 |
+
|
8 |
+
from engie_pipeline.pipeline import run, pipeline, set_up_pipeline, pipeline_experiment
|
9 |
+
|
10 |
+
eval_experiment = Experiment('eval', ingredients=[pipeline_experiment])
|
11 |
+
|
12 |
+
|
13 |
+
@eval_experiment.config
|
14 |
+
def config():
|
15 |
+
label_path = "/Users/benoit/Projects/EngieTableauElectrique/data/dataset/test.json"
|
16 |
+
image_folder = "data/test_data"
|
17 |
+
conformity_threshold = 0.9
|
18 |
+
|
19 |
+
|
20 |
+
def intersection_over_union(boxA, boxB):
|
21 |
+
# determine the (x, y)-coordinates of the intersection rectangle
|
22 |
+
xA = max(boxA[0], boxB[0])
|
23 |
+
yA = max(boxA[1], boxB[1])
|
24 |
+
xB = min(boxA[2], boxB[2])
|
25 |
+
yB = min(boxA[3], boxB[3])
|
26 |
+
# compute the area of intersection rectangle
|
27 |
+
interArea = max(0, xB - xA) * max(0, yB - yA)
|
28 |
+
# compute the area of both the prediction and ground-truth
|
29 |
+
# rectangles
|
30 |
+
boxAArea = (boxA[2] - boxA[0] + 1) * (boxA[3] - boxA[1] + 1)
|
31 |
+
boxBArea = (boxB[2] - boxB[0] + 1) * (boxB[3] - boxB[1] + 1)
|
32 |
+
# compute the intersection over union by taking the intersection
|
33 |
+
# area and dividing it by the sum of prediction + ground-truth
|
34 |
+
# areas - the interesection area
|
35 |
+
iou = interArea / float(boxAArea + boxBArea - interArea)
|
36 |
+
# return the intersection over union value
|
37 |
+
return iou
|
38 |
+
|
39 |
+
|
40 |
+
@eval_experiment.automain
|
41 |
+
def evaluate(label_path, image_folder, conformity_threshold):
|
42 |
+
models = set_up_pipeline()
|
43 |
+
confusion_matrix = {
|
44 |
+
"tp": 0,
|
45 |
+
"fp": 0,
|
46 |
+
"fn": 0,
|
47 |
+
}
|
48 |
+
with open(label_path) as file:
|
49 |
+
test_data = json.load(file)
|
50 |
+
|
51 |
+
for image in tqdm.tqdm(test_data['images']):
|
52 |
+
_, boxes, labels, scores, _ = pipeline(image=Image.open(os.path.join(image_folder, image['filename'])), **models, force_detr=True)
|
53 |
+
annotations = [annotation for annotation in test_data['annotations'] if annotation['image_id'] == image['id'] and annotation['category_id'] == 2]
|
54 |
+
|
55 |
+
boxes = boxes[labels == 2]
|
56 |
+
scores = scores[labels == 2]
|
57 |
+
boxes = boxes[scores >= conformity_threshold]
|
58 |
+
bbox_useful = [False for _ in boxes]
|
59 |
+
|
60 |
+
for annotation in annotations:
|
61 |
+
x, y, w, h = annotation['bbox']
|
62 |
+
is_detected = False
|
63 |
+
for bbox_id, box in enumerate(boxes):
|
64 |
+
if intersection_over_union(box, [x, y, x+w, y+h]) > 0:
|
65 |
+
confusion_matrix['tp'] += 1
|
66 |
+
is_detected = True
|
67 |
+
bbox_useful[bbox_id] = True
|
68 |
+
break
|
69 |
+
|
70 |
+
if not is_detected:
|
71 |
+
confusion_matrix['fn'] += 1
|
72 |
+
|
73 |
+
for bbox_id, box in enumerate(boxes):
|
74 |
+
is_useful = False
|
75 |
+
for annotation in annotations:
|
76 |
+
x, y, w, h = annotation['bbox']
|
77 |
+
if intersection_over_union(box, [x, y, x + w, y + h]) > 0:
|
78 |
+
|
79 |
+
is_useful = True
|
80 |
+
break
|
81 |
+
|
82 |
+
if not is_useful:
|
83 |
+
confusion_matrix['fp'] += 1
|
84 |
+
|
85 |
+
return confusion_matrix
|
engie_pipeline/models/__init__.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from .siglip import get_siglip, get_siglip_preprocessor, siglip_ingredient
|
2 |
+
from .detr import get_detr, get_detr_feature_extractor, detr_ingredient
|
3 |
+
|
4 |
+
from sacred import Ingredient
|
5 |
+
|
6 |
+
model_ingredient = Ingredient("model", ingredients=[siglip_ingredient, detr_ingredient])
|
engie_pipeline/models/detr.py
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List, Tuple
|
2 |
+
|
3 |
+
import pytorch_lightning as pl
|
4 |
+
import torch
|
5 |
+
from sacred import Ingredient
|
6 |
+
from torch import nn
|
7 |
+
from transformers import AdamW, DetrForObjectDetection, DetrImageProcessor
|
8 |
+
|
9 |
+
detr_ingredient = Ingredient("detr", save_git_info=False)
|
10 |
+
|
11 |
+
|
12 |
+
# pylint: disable=unused-variable
|
13 |
+
@detr_ingredient.config
|
14 |
+
def config():
|
15 |
+
hf_ckpt = "facebook/detr-resnet-50"
|
16 |
+
model_path = "./models/detr.ckpt"
|
17 |
+
|
18 |
+
num_label = 3
|
19 |
+
|
20 |
+
labels = ["Tableau Electrique", "Disjoncteur", "Bouton de test"]
|
21 |
+
|
22 |
+
learning_rate = 1e-5
|
23 |
+
|
24 |
+
|
25 |
+
class DeTrLightning(pl.LightningModule):
|
26 |
+
@detr_ingredient.capture
|
27 |
+
def __init__(self, hf_ckpt: str, labels: List[str]):
|
28 |
+
super().__init__()
|
29 |
+
|
30 |
+
self.model = DetrForObjectDetection.from_pretrained(
|
31 |
+
hf_ckpt,
|
32 |
+
num_labels=len(labels),
|
33 |
+
id2label=dict(enumerate(labels)),
|
34 |
+
label2id={label: i for i, label in enumerate(labels)},
|
35 |
+
ignore_mismatched_sizes=True,
|
36 |
+
)
|
37 |
+
|
38 |
+
def forward(self, *args, **kwargs):
|
39 |
+
return self.model(*args, **kwargs)
|
40 |
+
|
41 |
+
# pylint: disable=arguments-differ
|
42 |
+
def training_step(self, batch):
|
43 |
+
targets = batch["labels"]
|
44 |
+
|
45 |
+
output = self.model(**batch)
|
46 |
+
loss = output["loss"]
|
47 |
+
self.log("train_loss", loss)
|
48 |
+
|
49 |
+
return loss
|
50 |
+
|
51 |
+
# pylint: disable=unused-argument
|
52 |
+
def validation_step(self, batch, batch_id):
|
53 |
+
inputs, mask, targets = (
|
54 |
+
batch["pixel_values"],
|
55 |
+
batch["pixel_mask"],
|
56 |
+
batch["labels"],
|
57 |
+
)
|
58 |
+
|
59 |
+
output = self.model(inputs, pixel_mask=mask, labels=targets)
|
60 |
+
loss = output["loss"]
|
61 |
+
self.log("test_loss", loss)
|
62 |
+
|
63 |
+
return loss
|
64 |
+
|
65 |
+
# pylint: disable=unused-argument
|
66 |
+
def test_step(self, batch, batch_id):
|
67 |
+
inputs, mask, targets = (
|
68 |
+
batch["pixel_values"],
|
69 |
+
batch["pixel_mask"],
|
70 |
+
batch["labels"],
|
71 |
+
)
|
72 |
+
|
73 |
+
output = self.model(inputs, pixel_mask=mask, labels=targets)
|
74 |
+
loss = output["loss"]
|
75 |
+
self.log("test_loss", loss)
|
76 |
+
|
77 |
+
return loss
|
78 |
+
|
79 |
+
# pylint: disable=arguments-differ
|
80 |
+
@detr_ingredient.capture
|
81 |
+
def configure_optimizers(self, learning_rate):
|
82 |
+
optimizer = AdamW(self.parameters(), lr=learning_rate)
|
83 |
+
return optimizer
|
84 |
+
|
85 |
+
@staticmethod
|
86 |
+
def box_cxcywh_to_xyxy(boxes):
|
87 |
+
center_x, center_y, width, height = boxes.unbind(-1)
|
88 |
+
boxes = torch.stack(
|
89 |
+
# top left x, top left y, bottom right x, bottom right y
|
90 |
+
[
|
91 |
+
(center_x - 0.5 * width),
|
92 |
+
(center_y - 0.5 * height),
|
93 |
+
(center_x + 0.5 * width),
|
94 |
+
(center_y + 0.5 * height),
|
95 |
+
],
|
96 |
+
dim=-1,
|
97 |
+
)
|
98 |
+
return boxes
|
99 |
+
|
100 |
+
def process_output(self, model_output, image_size: Tuple[int, int]):
|
101 |
+
prob = model_output.logits.softmax(-1)
|
102 |
+
scores, labels = prob.max(-1)
|
103 |
+
|
104 |
+
boxes = self.box_cxcywh_to_xyxy(model_output.pred_boxes)
|
105 |
+
scale_fct = torch.Tensor(
|
106 |
+
[image_size[0], image_size[1], image_size[0], image_size[1]]
|
107 |
+
).unsqueeze(0)
|
108 |
+
boxes = boxes * scale_fct[:, None, :]
|
109 |
+
|
110 |
+
return boxes, labels, scores
|
111 |
+
|
112 |
+
|
113 |
+
@detr_ingredient.capture
|
114 |
+
def get_detr(model_path: str):
|
115 |
+
if model_path:
|
116 |
+
return DeTrLightning.load_from_checkpoint(model_path)
|
117 |
+
|
118 |
+
return DeTrLightning()
|
119 |
+
|
120 |
+
|
121 |
+
@detr_ingredient.capture
|
122 |
+
def get_detr_feature_extractor(hf_ckpt):
|
123 |
+
return DetrImageProcessor.from_pretrained(
|
124 |
+
hf_ckpt,
|
125 |
+
)
|
engie_pipeline/models/siglip.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List
|
2 |
+
|
3 |
+
import pytorch_lightning as pl
|
4 |
+
import torch
|
5 |
+
from sacred import Ingredient
|
6 |
+
from torch import nn
|
7 |
+
from torchvision import transforms
|
8 |
+
|
9 |
+
from transformers import AdamW, AutoImageProcessor, AutoModel, BitImageProcessor
|
10 |
+
|
11 |
+
siglip_ingredient = Ingredient("siglip", save_git_info=False)
|
12 |
+
|
13 |
+
|
14 |
+
# pylint: disable=unused-variable
|
15 |
+
@siglip_ingredient.config
|
16 |
+
def config():
|
17 |
+
hf_ckpt = "google/siglip-base-patch16-224"
|
18 |
+
model_path = "./models/siglip.ckpt"
|
19 |
+
ckpt = ""
|
20 |
+
|
21 |
+
learning_rate = 1e-5
|
22 |
+
|
23 |
+
|
24 |
+
class SiglipClassifier(pl.LightningModule):
|
25 |
+
@siglip_ingredient.capture
|
26 |
+
def __init__(self, hf_ckpt: str):
|
27 |
+
super().__init__()
|
28 |
+
|
29 |
+
self.vision_model = AutoModel.from_pretrained(hf_ckpt).base_model.vision_model
|
30 |
+
self.classifier = nn.Linear(768, 3)
|
31 |
+
self.criterion = nn.CrossEntropyLoss()
|
32 |
+
|
33 |
+
def forward(self, x):
|
34 |
+
features = self.vision_model(x).pooler_output
|
35 |
+
logits = self.classifier(features)
|
36 |
+
return logits
|
37 |
+
|
38 |
+
# pylint: disable=arguments-differ
|
39 |
+
def training_step(self, batch):
|
40 |
+
images, labels = batch
|
41 |
+
|
42 |
+
logits = self.forward(images)
|
43 |
+
loss = self.criterion(logits, labels)
|
44 |
+
|
45 |
+
self.log("loss", loss.item(), prog_bar=True)
|
46 |
+
|
47 |
+
return loss
|
48 |
+
|
49 |
+
# pylint: disable=unused-argument
|
50 |
+
def validation_step(self, batch, batch_id):
|
51 |
+
images, labels = batch
|
52 |
+
|
53 |
+
logits = self.forward(images)
|
54 |
+
loss = self.criterion(logits, labels)
|
55 |
+
self.log("test_loss", loss)
|
56 |
+
|
57 |
+
return loss
|
58 |
+
|
59 |
+
# pylint: disable=unused-argument
|
60 |
+
def test_step(self, batch, batch_id):
|
61 |
+
images, labels = batch
|
62 |
+
|
63 |
+
logits = self.forward(images)
|
64 |
+
loss = self.criterion(logits, labels)
|
65 |
+
self.log("val_loss", loss)
|
66 |
+
|
67 |
+
return loss
|
68 |
+
|
69 |
+
# pylint: disable=arguments-differ
|
70 |
+
@siglip_ingredient.capture
|
71 |
+
def configure_optimizers(self, learning_rate):
|
72 |
+
optimizer = torch.optim.AdamW(self.parameters(), lr=learning_rate)
|
73 |
+
return optimizer
|
74 |
+
|
75 |
+
|
76 |
+
@siglip_ingredient.capture
|
77 |
+
def get_siglip(model_path: str):
|
78 |
+
if model_path:
|
79 |
+
return SiglipClassifier.load_from_checkpoint(model_path)
|
80 |
+
|
81 |
+
return SiglipClassifier()
|
82 |
+
|
83 |
+
|
84 |
+
@siglip_ingredient.capture
|
85 |
+
def get_siglip_preprocessor(hf_ckpt: str):
|
86 |
+
return transforms.Compose(
|
87 |
+
[
|
88 |
+
transforms.Resize((224, 224)),
|
89 |
+
transforms.ToTensor(),
|
90 |
+
transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5]),
|
91 |
+
]
|
92 |
+
)
|
engie_pipeline/pipeline.py
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os.path
|
3 |
+
import uuid
|
4 |
+
|
5 |
+
from engie_pipeline.models import (
|
6 |
+
model_ingredient,
|
7 |
+
get_detr,
|
8 |
+
get_detr_feature_extractor,
|
9 |
+
get_siglip,
|
10 |
+
get_siglip_preprocessor,
|
11 |
+
)
|
12 |
+
|
13 |
+
from PIL import Image
|
14 |
+
from sacred import Experiment
|
15 |
+
from tqdm import tqdm
|
16 |
+
|
17 |
+
from engie_pipeline.utils import draw_boxes
|
18 |
+
|
19 |
+
pipeline_experiment = Experiment("pipeline", ingredients=[model_ingredient])
|
20 |
+
|
21 |
+
|
22 |
+
@pipeline_experiment.config
|
23 |
+
def config():
|
24 |
+
path = "data/"
|
25 |
+
output_path = "data/output"
|
26 |
+
|
27 |
+
conformity_threshold = .8
|
28 |
+
|
29 |
+
|
30 |
+
@pipeline_experiment.capture
|
31 |
+
def set_up_pipeline(output_path):
|
32 |
+
for labels in ["Conforme", "Non-conforme", "Hors-sujet", "Non-admissible"]:
|
33 |
+
if not os.path.isdir(os.path.join(output_path, labels)):
|
34 |
+
os.makedirs(os.path.join(output_path, labels), exist_ok=True)
|
35 |
+
|
36 |
+
detr = get_detr()
|
37 |
+
detr.eval()
|
38 |
+
detr_preprocessor = get_detr_feature_extractor()
|
39 |
+
|
40 |
+
siglip = get_siglip()
|
41 |
+
siglip.eval()
|
42 |
+
siglip_preprocessor = get_siglip_preprocessor()
|
43 |
+
|
44 |
+
return {
|
45 |
+
"detr": detr,
|
46 |
+
"detr_preprocessor": detr_preprocessor,
|
47 |
+
"siglip": siglip,
|
48 |
+
"siglip_preprocessor": siglip_preprocessor,
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
@pipeline_experiment.capture
|
53 |
+
def pipeline(
|
54 |
+
detr,
|
55 |
+
detr_preprocessor,
|
56 |
+
siglip,
|
57 |
+
siglip_preprocessor,
|
58 |
+
image: Image.Image,
|
59 |
+
output_path: str,
|
60 |
+
conformity_threshold: float,
|
61 |
+
force_detr: bool = False,
|
62 |
+
):
|
63 |
+
filename = (
|
64 |
+
".".join(os.path.basename(image.filename).split(".")[:-1])
|
65 |
+
if hasattr(image, "filename")
|
66 |
+
else str(uuid.uuid4())
|
67 |
+
)
|
68 |
+
|
69 |
+
if os.path.isfile(os.path.join(output_path, "Hors-sujet", filename + ".jpg")) or os.path.isfile(os.path.join(output_path, "Non-admissible", filename + ".jpg")) or os.path.isfile(os.path.join(output_path, "Conforme", filename + ".jpg")) or os.path.isfile(os.path.join(output_path, "Non-conforme", filename + ".jpg")):
|
70 |
+
return
|
71 |
+
|
72 |
+
|
73 |
+
|
74 |
+
siglip_image_input = siglip_preprocessor(image.copy())
|
75 |
+
siglip_probs = siglip(siglip_image_input.unsqueeze(0)).softmax(-1)
|
76 |
+
|
77 |
+
conformity = None
|
78 |
+
|
79 |
+
if siglip_probs.argmax() == 1:
|
80 |
+
conformity = "Hors-sujet"
|
81 |
+
image.save(os.path.join(output_path, "Hors-sujet", filename + ".jpg"))
|
82 |
+
if not force_detr:
|
83 |
+
with open(os.path.join(output_path, "Hors-sujet", filename + ".json"), "w") as file:
|
84 |
+
json.dump(
|
85 |
+
{"classification_probs": siglip_probs.tolist()}, file, indent=4
|
86 |
+
)
|
87 |
+
return
|
88 |
+
|
89 |
+
if siglip_probs.argmax() == 2:
|
90 |
+
conformity = "Non-admissible"
|
91 |
+
image.save(os.path.join(output_path, "Non-admissible", filename + ".jpg"))
|
92 |
+
if not force_detr:
|
93 |
+
with open(os.path.join(output_path, "Non-admissible", filename + ".json"), "w") as file:
|
94 |
+
json.dump(
|
95 |
+
{"classification_probs": siglip_probs.tolist()}, file, indent=4
|
96 |
+
)
|
97 |
+
return
|
98 |
+
|
99 |
+
detr_image_input = detr_preprocessor(image.copy(), return_tensors="pt")
|
100 |
+
detr_output = detr(detr_image_input["pixel_values"])
|
101 |
+
boxes, labels, scores = detr.process_output(detr_output, image.size)
|
102 |
+
|
103 |
+
if conformity is None:
|
104 |
+
conformity = "Conforme" if 2 in labels and scores[labels == 2].max() > conformity_threshold else "Non-conforme"
|
105 |
+
|
106 |
+
image = draw_boxes(
|
107 |
+
image=image, boxes=boxes[labels == 0], probs=scores[labels == 0], color="gray"
|
108 |
+
)
|
109 |
+
|
110 |
+
image = draw_boxes(
|
111 |
+
image=image, boxes=boxes[labels == 1], probs=scores[labels == 1], color="orange"
|
112 |
+
)
|
113 |
+
image = draw_boxes(
|
114 |
+
image=image, boxes=boxes[labels == 2], probs=scores[labels == 2], color="purple"
|
115 |
+
)
|
116 |
+
image.save(os.path.join(output_path, conformity, filename + ".jpg"))
|
117 |
+
with open(os.path.join(output_path, conformity, filename + ".json"), "w") as file:
|
118 |
+
json.dump(
|
119 |
+
{
|
120 |
+
"classification_probs": siglip_probs.tolist(),
|
121 |
+
"detection_statistics": {
|
122 |
+
label: {"scores": scores[labels == i].tolist(), "boxes": boxes[labels == i].tolist()}
|
123 |
+
for i, label in enumerate(
|
124 |
+
["tableau", "disjoncteur", "bouton de test"]
|
125 |
+
)
|
126 |
+
},
|
127 |
+
},
|
128 |
+
file,
|
129 |
+
indent=4,
|
130 |
+
)
|
131 |
+
|
132 |
+
return siglip_probs, boxes, labels, scores, conformity
|
133 |
+
|
134 |
+
|
135 |
+
@pipeline_experiment.automain
|
136 |
+
def run(path: str):
|
137 |
+
models = set_up_pipeline()
|
138 |
+
if os.path.isfile(path):
|
139 |
+
pipeline(**models, image=Image.open(path))
|
140 |
+
|
141 |
+
for file in tqdm(os.listdir(path)):
|
142 |
+
if not file.lower().endswith(("jpg", "jpeg", "png")):
|
143 |
+
continue
|
144 |
+
|
145 |
+
pipeline(**models, image=Image.open(os.path.join(path, file)).convert('RGB'), force_detr=False)
|
engie_pipeline/utils.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from PIL import ImageDraw
|
2 |
+
|
3 |
+
|
4 |
+
def draw_boxes(image, boxes, probs, color):
|
5 |
+
draw = ImageDraw.Draw(image)
|
6 |
+
|
7 |
+
for box, proba in zip(boxes, probs):
|
8 |
+
draw.rectangle(box.tolist(), outline=color, width=6)
|
9 |
+
|
10 |
+
draw.text(
|
11 |
+
(box[0], box[1] - 15),
|
12 |
+
text=str(round(proba.item(), 2)),
|
13 |
+
fill=color,
|
14 |
+
stroke_width=1,
|
15 |
+
)
|
16 |
+
|
17 |
+
return image
|
models/detr.ckpt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2ba36e47d2372b078e25d0c5a0d73fb474f71fbb08a00f02f0d93371550d7cba
|
3 |
+
size 497131777
|
models/siglip.ckpt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e893c153beb2da92464bdb058911c88fee9b72ca4cca391c3c13b3a7c4181f74
|
3 |
+
size 1114898848
|
requirements.txt
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
pytorch-lightning
|
3 |
+
sacred
|
4 |
+
timm
|
5 |
+
torch
|
6 |
+
torchvision
|
7 |
+
transformers
|
8 |
+
httpcore
|
venv/bin/Activate.ps1
ADDED
@@ -0,0 +1,247 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<#
|
2 |
+
.Synopsis
|
3 |
+
Activate a Python virtual environment for the current PowerShell session.
|
4 |
+
|
5 |
+
.Description
|
6 |
+
Pushes the python executable for a virtual environment to the front of the
|
7 |
+
$Env:PATH environment variable and sets the prompt to signify that you are
|
8 |
+
in a Python virtual environment. Makes use of the command line switches as
|
9 |
+
well as the `pyvenv.cfg` file values present in the virtual environment.
|
10 |
+
|
11 |
+
.Parameter VenvDir
|
12 |
+
Path to the directory that contains the virtual environment to activate. The
|
13 |
+
default value for this is the parent of the directory that the Activate.ps1
|
14 |
+
script is located within.
|
15 |
+
|
16 |
+
.Parameter Prompt
|
17 |
+
The prompt prefix to display when this virtual environment is activated. By
|
18 |
+
default, this prompt is the name of the virtual environment folder (VenvDir)
|
19 |
+
surrounded by parentheses and followed by a single space (ie. '(.venv) ').
|
20 |
+
|
21 |
+
.Example
|
22 |
+
Activate.ps1
|
23 |
+
Activates the Python virtual environment that contains the Activate.ps1 script.
|
24 |
+
|
25 |
+
.Example
|
26 |
+
Activate.ps1 -Verbose
|
27 |
+
Activates the Python virtual environment that contains the Activate.ps1 script,
|
28 |
+
and shows extra information about the activation as it executes.
|
29 |
+
|
30 |
+
.Example
|
31 |
+
Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
|
32 |
+
Activates the Python virtual environment located in the specified location.
|
33 |
+
|
34 |
+
.Example
|
35 |
+
Activate.ps1 -Prompt "MyPython"
|
36 |
+
Activates the Python virtual environment that contains the Activate.ps1 script,
|
37 |
+
and prefixes the current prompt with the specified string (surrounded in
|
38 |
+
parentheses) while the virtual environment is active.
|
39 |
+
|
40 |
+
.Notes
|
41 |
+
On Windows, it may be required to enable this Activate.ps1 script by setting the
|
42 |
+
execution policy for the user. You can do this by issuing the following PowerShell
|
43 |
+
command:
|
44 |
+
|
45 |
+
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
|
46 |
+
|
47 |
+
For more information on Execution Policies:
|
48 |
+
https://go.microsoft.com/fwlink/?LinkID=135170
|
49 |
+
|
50 |
+
#>
|
51 |
+
Param(
|
52 |
+
[Parameter(Mandatory = $false)]
|
53 |
+
[String]
|
54 |
+
$VenvDir,
|
55 |
+
[Parameter(Mandatory = $false)]
|
56 |
+
[String]
|
57 |
+
$Prompt
|
58 |
+
)
|
59 |
+
|
60 |
+
<# Function declarations --------------------------------------------------- #>
|
61 |
+
|
62 |
+
<#
|
63 |
+
.Synopsis
|
64 |
+
Remove all shell session elements added by the Activate script, including the
|
65 |
+
addition of the virtual environment's Python executable from the beginning of
|
66 |
+
the PATH variable.
|
67 |
+
|
68 |
+
.Parameter NonDestructive
|
69 |
+
If present, do not remove this function from the global namespace for the
|
70 |
+
session.
|
71 |
+
|
72 |
+
#>
|
73 |
+
function global:deactivate ([switch]$NonDestructive) {
|
74 |
+
# Revert to original values
|
75 |
+
|
76 |
+
# The prior prompt:
|
77 |
+
if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
|
78 |
+
Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
|
79 |
+
Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
|
80 |
+
}
|
81 |
+
|
82 |
+
# The prior PYTHONHOME:
|
83 |
+
if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
|
84 |
+
Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
|
85 |
+
Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
|
86 |
+
}
|
87 |
+
|
88 |
+
# The prior PATH:
|
89 |
+
if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
|
90 |
+
Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
|
91 |
+
Remove-Item -Path Env:_OLD_VIRTUAL_PATH
|
92 |
+
}
|
93 |
+
|
94 |
+
# Just remove the VIRTUAL_ENV altogether:
|
95 |
+
if (Test-Path -Path Env:VIRTUAL_ENV) {
|
96 |
+
Remove-Item -Path env:VIRTUAL_ENV
|
97 |
+
}
|
98 |
+
|
99 |
+
# Just remove VIRTUAL_ENV_PROMPT altogether.
|
100 |
+
if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
|
101 |
+
Remove-Item -Path env:VIRTUAL_ENV_PROMPT
|
102 |
+
}
|
103 |
+
|
104 |
+
# Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
|
105 |
+
if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
|
106 |
+
Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
|
107 |
+
}
|
108 |
+
|
109 |
+
# Leave deactivate function in the global namespace if requested:
|
110 |
+
if (-not $NonDestructive) {
|
111 |
+
Remove-Item -Path function:deactivate
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
<#
|
116 |
+
.Description
|
117 |
+
Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
|
118 |
+
given folder, and returns them in a map.
|
119 |
+
|
120 |
+
For each line in the pyvenv.cfg file, if that line can be parsed into exactly
|
121 |
+
two strings separated by `=` (with any amount of whitespace surrounding the =)
|
122 |
+
then it is considered a `key = value` line. The left hand string is the key,
|
123 |
+
the right hand is the value.
|
124 |
+
|
125 |
+
If the value starts with a `'` or a `"` then the first and last character is
|
126 |
+
stripped from the value before being captured.
|
127 |
+
|
128 |
+
.Parameter ConfigDir
|
129 |
+
Path to the directory that contains the `pyvenv.cfg` file.
|
130 |
+
#>
|
131 |
+
function Get-PyVenvConfig(
|
132 |
+
[String]
|
133 |
+
$ConfigDir
|
134 |
+
) {
|
135 |
+
Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
|
136 |
+
|
137 |
+
# Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
|
138 |
+
$pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
|
139 |
+
|
140 |
+
# An empty map will be returned if no config file is found.
|
141 |
+
$pyvenvConfig = @{ }
|
142 |
+
|
143 |
+
if ($pyvenvConfigPath) {
|
144 |
+
|
145 |
+
Write-Verbose "File exists, parse `key = value` lines"
|
146 |
+
$pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
|
147 |
+
|
148 |
+
$pyvenvConfigContent | ForEach-Object {
|
149 |
+
$keyval = $PSItem -split "\s*=\s*", 2
|
150 |
+
if ($keyval[0] -and $keyval[1]) {
|
151 |
+
$val = $keyval[1]
|
152 |
+
|
153 |
+
# Remove extraneous quotations around a string value.
|
154 |
+
if ("'""".Contains($val.Substring(0, 1))) {
|
155 |
+
$val = $val.Substring(1, $val.Length - 2)
|
156 |
+
}
|
157 |
+
|
158 |
+
$pyvenvConfig[$keyval[0]] = $val
|
159 |
+
Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
return $pyvenvConfig
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
<# Begin Activate script --------------------------------------------------- #>
|
168 |
+
|
169 |
+
# Determine the containing directory of this script
|
170 |
+
$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
|
171 |
+
$VenvExecDir = Get-Item -Path $VenvExecPath
|
172 |
+
|
173 |
+
Write-Verbose "Activation script is located in path: '$VenvExecPath'"
|
174 |
+
Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
|
175 |
+
Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
|
176 |
+
|
177 |
+
# Set values required in priority: CmdLine, ConfigFile, Default
|
178 |
+
# First, get the location of the virtual environment, it might not be
|
179 |
+
# VenvExecDir if specified on the command line.
|
180 |
+
if ($VenvDir) {
|
181 |
+
Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
|
182 |
+
}
|
183 |
+
else {
|
184 |
+
Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
|
185 |
+
$VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
|
186 |
+
Write-Verbose "VenvDir=$VenvDir"
|
187 |
+
}
|
188 |
+
|
189 |
+
# Next, read the `pyvenv.cfg` file to determine any required value such
|
190 |
+
# as `prompt`.
|
191 |
+
$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
|
192 |
+
|
193 |
+
# Next, set the prompt from the command line, or the config file, or
|
194 |
+
# just use the name of the virtual environment folder.
|
195 |
+
if ($Prompt) {
|
196 |
+
Write-Verbose "Prompt specified as argument, using '$Prompt'"
|
197 |
+
}
|
198 |
+
else {
|
199 |
+
Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
|
200 |
+
if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
|
201 |
+
Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
|
202 |
+
$Prompt = $pyvenvCfg['prompt'];
|
203 |
+
}
|
204 |
+
else {
|
205 |
+
Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
|
206 |
+
Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
|
207 |
+
$Prompt = Split-Path -Path $venvDir -Leaf
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
Write-Verbose "Prompt = '$Prompt'"
|
212 |
+
Write-Verbose "VenvDir='$VenvDir'"
|
213 |
+
|
214 |
+
# Deactivate any currently active virtual environment, but leave the
|
215 |
+
# deactivate function in place.
|
216 |
+
deactivate -nondestructive
|
217 |
+
|
218 |
+
# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
|
219 |
+
# that there is an activated venv.
|
220 |
+
$env:VIRTUAL_ENV = $VenvDir
|
221 |
+
|
222 |
+
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
|
223 |
+
|
224 |
+
Write-Verbose "Setting prompt to '$Prompt'"
|
225 |
+
|
226 |
+
# Set the prompt to include the env name
|
227 |
+
# Make sure _OLD_VIRTUAL_PROMPT is global
|
228 |
+
function global:_OLD_VIRTUAL_PROMPT { "" }
|
229 |
+
Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
|
230 |
+
New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
|
231 |
+
|
232 |
+
function global:prompt {
|
233 |
+
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
|
234 |
+
_OLD_VIRTUAL_PROMPT
|
235 |
+
}
|
236 |
+
$env:VIRTUAL_ENV_PROMPT = $Prompt
|
237 |
+
}
|
238 |
+
|
239 |
+
# Clear PYTHONHOME
|
240 |
+
if (Test-Path -Path Env:PYTHONHOME) {
|
241 |
+
Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
|
242 |
+
Remove-Item -Path Env:PYTHONHOME
|
243 |
+
}
|
244 |
+
|
245 |
+
# Add the venv to the PATH
|
246 |
+
Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
|
247 |
+
$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
|
venv/bin/activate
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file must be used with "source bin/activate" *from bash*
|
2 |
+
# you cannot run it directly
|
3 |
+
|
4 |
+
deactivate () {
|
5 |
+
# reset old environment variables
|
6 |
+
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
|
7 |
+
PATH="${_OLD_VIRTUAL_PATH:-}"
|
8 |
+
export PATH
|
9 |
+
unset _OLD_VIRTUAL_PATH
|
10 |
+
fi
|
11 |
+
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
|
12 |
+
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
|
13 |
+
export PYTHONHOME
|
14 |
+
unset _OLD_VIRTUAL_PYTHONHOME
|
15 |
+
fi
|
16 |
+
|
17 |
+
# This should detect bash and zsh, which have a hash command that must
|
18 |
+
# be called to get it to forget past commands. Without forgetting
|
19 |
+
# past commands the $PATH changes we made may not be respected
|
20 |
+
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
21 |
+
hash -r 2> /dev/null
|
22 |
+
fi
|
23 |
+
|
24 |
+
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
|
25 |
+
PS1="${_OLD_VIRTUAL_PS1:-}"
|
26 |
+
export PS1
|
27 |
+
unset _OLD_VIRTUAL_PS1
|
28 |
+
fi
|
29 |
+
|
30 |
+
unset VIRTUAL_ENV
|
31 |
+
unset VIRTUAL_ENV_PROMPT
|
32 |
+
if [ ! "${1:-}" = "nondestructive" ] ; then
|
33 |
+
# Self destruct!
|
34 |
+
unset -f deactivate
|
35 |
+
fi
|
36 |
+
}
|
37 |
+
|
38 |
+
# unset irrelevant variables
|
39 |
+
deactivate nondestructive
|
40 |
+
|
41 |
+
VIRTUAL_ENV="/home/nathan.botbol/pipeline/venv"
|
42 |
+
export VIRTUAL_ENV
|
43 |
+
|
44 |
+
_OLD_VIRTUAL_PATH="$PATH"
|
45 |
+
PATH="$VIRTUAL_ENV/bin:$PATH"
|
46 |
+
export PATH
|
47 |
+
|
48 |
+
# unset PYTHONHOME if set
|
49 |
+
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
|
50 |
+
# could use `if (set -u; : $PYTHONHOME) ;` in bash
|
51 |
+
if [ -n "${PYTHONHOME:-}" ] ; then
|
52 |
+
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
|
53 |
+
unset PYTHONHOME
|
54 |
+
fi
|
55 |
+
|
56 |
+
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
|
57 |
+
_OLD_VIRTUAL_PS1="${PS1:-}"
|
58 |
+
PS1="(venv) ${PS1:-}"
|
59 |
+
export PS1
|
60 |
+
VIRTUAL_ENV_PROMPT="(venv) "
|
61 |
+
export VIRTUAL_ENV_PROMPT
|
62 |
+
fi
|
63 |
+
|
64 |
+
# This should detect bash and zsh, which have a hash command that must
|
65 |
+
# be called to get it to forget past commands. Without forgetting
|
66 |
+
# past commands the $PATH changes we made may not be respected
|
67 |
+
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
|
68 |
+
hash -r 2> /dev/null
|
69 |
+
fi
|
venv/bin/activate.csh
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file must be used with "source bin/activate.csh" *from csh*.
|
2 |
+
# You cannot run it directly.
|
3 |
+
# Created by Davide Di Blasi <davidedb@gmail.com>.
|
4 |
+
# Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
|
5 |
+
|
6 |
+
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
|
7 |
+
|
8 |
+
# Unset irrelevant variables.
|
9 |
+
deactivate nondestructive
|
10 |
+
|
11 |
+
setenv VIRTUAL_ENV "/home/nathan.botbol/pipeline/venv"
|
12 |
+
|
13 |
+
set _OLD_VIRTUAL_PATH="$PATH"
|
14 |
+
setenv PATH "$VIRTUAL_ENV/bin:$PATH"
|
15 |
+
|
16 |
+
|
17 |
+
set _OLD_VIRTUAL_PROMPT="$prompt"
|
18 |
+
|
19 |
+
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
|
20 |
+
set prompt = "(venv) $prompt"
|
21 |
+
setenv VIRTUAL_ENV_PROMPT "(venv) "
|
22 |
+
endif
|
23 |
+
|
24 |
+
alias pydoc python -m pydoc
|
25 |
+
|
26 |
+
rehash
|
venv/bin/activate.fish
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This file must be used with "source <venv>/bin/activate.fish" *from fish*
|
2 |
+
# (https://fishshell.com/); you cannot run it directly.
|
3 |
+
|
4 |
+
function deactivate -d "Exit virtual environment and return to normal shell environment"
|
5 |
+
# reset old environment variables
|
6 |
+
if test -n "$_OLD_VIRTUAL_PATH"
|
7 |
+
set -gx PATH $_OLD_VIRTUAL_PATH
|
8 |
+
set -e _OLD_VIRTUAL_PATH
|
9 |
+
end
|
10 |
+
if test -n "$_OLD_VIRTUAL_PYTHONHOME"
|
11 |
+
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
|
12 |
+
set -e _OLD_VIRTUAL_PYTHONHOME
|
13 |
+
end
|
14 |
+
|
15 |
+
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
|
16 |
+
set -e _OLD_FISH_PROMPT_OVERRIDE
|
17 |
+
# prevents error when using nested fish instances (Issue #93858)
|
18 |
+
if functions -q _old_fish_prompt
|
19 |
+
functions -e fish_prompt
|
20 |
+
functions -c _old_fish_prompt fish_prompt
|
21 |
+
functions -e _old_fish_prompt
|
22 |
+
end
|
23 |
+
end
|
24 |
+
|
25 |
+
set -e VIRTUAL_ENV
|
26 |
+
set -e VIRTUAL_ENV_PROMPT
|
27 |
+
if test "$argv[1]" != "nondestructive"
|
28 |
+
# Self-destruct!
|
29 |
+
functions -e deactivate
|
30 |
+
end
|
31 |
+
end
|
32 |
+
|
33 |
+
# Unset irrelevant variables.
|
34 |
+
deactivate nondestructive
|
35 |
+
|
36 |
+
set -gx VIRTUAL_ENV "/home/nathan.botbol/pipeline/venv"
|
37 |
+
|
38 |
+
set -gx _OLD_VIRTUAL_PATH $PATH
|
39 |
+
set -gx PATH "$VIRTUAL_ENV/bin" $PATH
|
40 |
+
|
41 |
+
# Unset PYTHONHOME if set.
|
42 |
+
if set -q PYTHONHOME
|
43 |
+
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
|
44 |
+
set -e PYTHONHOME
|
45 |
+
end
|
46 |
+
|
47 |
+
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
|
48 |
+
# fish uses a function instead of an env var to generate the prompt.
|
49 |
+
|
50 |
+
# Save the current fish_prompt function as the function _old_fish_prompt.
|
51 |
+
functions -c fish_prompt _old_fish_prompt
|
52 |
+
|
53 |
+
# With the original prompt function renamed, we can override with our own.
|
54 |
+
function fish_prompt
|
55 |
+
# Save the return status of the last command.
|
56 |
+
set -l old_status $status
|
57 |
+
|
58 |
+
# Output the venv prompt; color taken from the blue of the Python logo.
|
59 |
+
printf "%s%s%s" (set_color 4B8BBE) "(venv) " (set_color normal)
|
60 |
+
|
61 |
+
# Restore the return status of the previous command.
|
62 |
+
echo "exit $old_status" | .
|
63 |
+
# Output the original/"old" prompt.
|
64 |
+
_old_fish_prompt
|
65 |
+
end
|
66 |
+
|
67 |
+
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
|
68 |
+
set -gx VIRTUAL_ENV_PROMPT "(venv) "
|
69 |
+
end
|
venv/bin/convert-caffe2-to-onnx
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from caffe2.python.onnx.bin.conversion import caffe2_to_onnx
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(caffe2_to_onnx())
|
venv/bin/convert-onnx-to-caffe2
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from caffe2.python.onnx.bin.conversion import onnx_to_caffe2
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(onnx_to_caffe2())
|
venv/bin/cpuinfo
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from cpuinfo import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/dotenv
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from dotenv.__main__ import cli
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(cli())
|
venv/bin/email_validator
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from email_validator.__main__ import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/f2py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from numpy.f2py.f2py2e import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/fastapi
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from fastapi_cli.cli import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/fonttools
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from fontTools.__main__ import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/gradio
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from gradio.cli import cli
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(cli())
|
venv/bin/httpx
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from httpx import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/huggingface-cli
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from huggingface_hub.commands.huggingface_cli import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/isympy
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from isympy import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/jsonschema
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from jsonschema.cli import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/markdown-it
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from markdown_it.cli.parse import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/normalizer
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from charset_normalizer.cli import cli_detect
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(cli_detect())
|
venv/bin/pip
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from pip._internal.cli.main import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/pip3
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from pip._internal.cli.main import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/pip3.11
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from pip._internal.cli.main import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/pyftmerge
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from fontTools.merge import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/pyftsubset
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from fontTools.subset import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/pygmentize
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from pygments.cmdline import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/python
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c09bdf51cb07702306021fa676cc735e58f2673fb516ecbd63bf87e978063f95
|
3 |
+
size 6831704
|
venv/bin/python3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c09bdf51cb07702306021fa676cc735e58f2673fb516ecbd63bf87e978063f95
|
3 |
+
size 6831704
|
venv/bin/python3.11
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c09bdf51cb07702306021fa676cc735e58f2673fb516ecbd63bf87e978063f95
|
3 |
+
size 6831704
|
venv/bin/ruff
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:909e158295812209eae0fdec2f8a55757bc1fb14982572b65b6e50ec48fa2169
|
3 |
+
size 23358480
|
venv/bin/torchrun
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from torch.distributed.run import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/tqdm
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from tqdm.cli import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/transformers-cli
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from transformers.commands.transformers_cli import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/ttx
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from fontTools.ttx import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|
venv/bin/typer
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/home/nathan.botbol/pipeline/venv/bin/python3.11
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
import re
|
4 |
+
import sys
|
5 |
+
from typer.cli import main
|
6 |
+
if __name__ == '__main__':
|
7 |
+
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
8 |
+
sys.exit(main())
|