e2145005 commited on
Commit
1e04a2b
·
verified ·
1 Parent(s): 3760289

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.gitattributes CHANGED
@@ -33,3 +33,93 @@ 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
+ src/.venv/bin/ruff filter=lfs diff=lfs merge=lfs -text
37
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libbrotlicommon.1.1.0.dylib filter=lfs diff=lfs merge=lfs -text
38
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libbrotlidec.1.1.0.dylib filter=lfs diff=lfs merge=lfs -text
39
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libfreetype.6.dylib filter=lfs diff=lfs merge=lfs -text
40
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libharfbuzz.0.dylib filter=lfs diff=lfs merge=lfs -text
41
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libjpeg.62.4.0.dylib filter=lfs diff=lfs merge=lfs -text
42
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/liblcms2.2.dylib filter=lfs diff=lfs merge=lfs -text
43
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/liblzma.5.dylib filter=lfs diff=lfs merge=lfs -text
44
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libopenjp2.2.5.3.dylib filter=lfs diff=lfs merge=lfs -text
45
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libpng16.16.dylib filter=lfs diff=lfs merge=lfs -text
46
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libtiff.6.dylib filter=lfs diff=lfs merge=lfs -text
47
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libwebp.7.dylib filter=lfs diff=lfs merge=lfs -text
48
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libwebpmux.3.dylib filter=lfs diff=lfs merge=lfs -text
49
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libxcb.1.1.0.dylib filter=lfs diff=lfs merge=lfs -text
50
+ src/.venv/lib/python3.11/site-packages/PIL/.dylibs/libz.1.3.1.zlib-ng.dylib filter=lfs diff=lfs merge=lfs -text
51
+ src/.venv/lib/python3.11/site-packages/PIL/_imaging.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
52
+ src/.venv/lib/python3.11/site-packages/PIL/_imagingft.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
53
+ src/.venv/lib/python3.11/site-packages/charset_normalizer/md.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
54
+ src/.venv/lib/python3.11/site-packages/charset_normalizer/md__mypyc.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
55
+ src/.venv/lib/python3.11/site-packages/gradio/templates/frontend/assets/PlotlyPlot-Bt7F3WwC.js.map filter=lfs diff=lfs merge=lfs -text
56
+ src/.venv/lib/python3.11/site-packages/gradio/templates/frontend/static/fonts/Source[[:space:]]Sans[[:space:]]Pro/SourceSansPro-Bold.woff2 filter=lfs diff=lfs merge=lfs -text
57
+ src/.venv/lib/python3.11/site-packages/gradio/templates/frontend/static/fonts/Source[[:space:]]Sans[[:space:]]Pro/SourceSansPro-Regular.woff2 filter=lfs diff=lfs merge=lfs -text
58
+ src/.venv/lib/python3.11/site-packages/gradio/templates/frontend/static/img/Duck.glb filter=lfs diff=lfs merge=lfs -text
59
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/2.BnWZeegF.js.br filter=lfs diff=lfs merge=lfs -text
60
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/AltairPlot.0-wxZmy5.js.br filter=lfs diff=lfs merge=lfs -text
61
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/Index.B6fpneeu.js.br filter=lfs diff=lfs merge=lfs -text
62
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/Index.Bgh4_blz.js.br filter=lfs diff=lfs merge=lfs -text
63
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/PlotlyPlot.MqbH2HVz.js.br filter=lfs diff=lfs merge=lfs -text
64
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/cytoscape.esm.C_mCjcvO.js.br filter=lfs diff=lfs merge=lfs -text
65
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/hls.CFPBCiRi.js.br filter=lfs diff=lfs merge=lfs -text
66
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/index.B4f7kVg_.js.br filter=lfs diff=lfs merge=lfs -text
67
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/mermaid.core.DGTMB5Ug.js.br filter=lfs diff=lfs merge=lfs -text
68
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/vega-embed.module.CHA6RNIt.js.br filter=lfs diff=lfs merge=lfs -text
69
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/client/_app/immutable/chunks/vega-tooltip.module.CJsyC3E5.js.br filter=lfs diff=lfs merge=lfs -text
70
+ src/.venv/lib/python3.11/site-packages/gradio/templates/node/build/server/chunks/PlotlyPlot-Dj_i3J5T.js.map filter=lfs diff=lfs merge=lfs -text
71
+ src/.venv/lib/python3.11/site-packages/nh3/nh3.abi3.so filter=lfs diff=lfs merge=lfs -text
72
+ src/.venv/lib/python3.11/site-packages/numpy/_core/_multiarray_tests.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
73
+ src/.venv/lib/python3.11/site-packages/numpy/_core/_multiarray_umath.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
74
+ src/.venv/lib/python3.11/site-packages/numpy/_core/_simd.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
75
+ src/.venv/lib/python3.11/site-packages/numpy/fft/_pocketfft_umath.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
76
+ src/.venv/lib/python3.11/site-packages/numpy/linalg/_umath_linalg.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
77
+ src/.venv/lib/python3.11/site-packages/numpy/random/_bounded_integers.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
78
+ src/.venv/lib/python3.11/site-packages/numpy/random/_common.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
79
+ src/.venv/lib/python3.11/site-packages/numpy/random/_generator.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
80
+ src/.venv/lib/python3.11/site-packages/numpy/random/_mt19937.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
81
+ src/.venv/lib/python3.11/site-packages/numpy/random/_pcg64.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
82
+ src/.venv/lib/python3.11/site-packages/numpy/random/_philox.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
83
+ src/.venv/lib/python3.11/site-packages/numpy/random/bit_generator.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
84
+ src/.venv/lib/python3.11/site-packages/numpy/random/mtrand.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
85
+ src/.venv/lib/python3.11/site-packages/orjson/orjson.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
86
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/algos.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
87
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/arrays.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
88
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/groupby.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
89
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/hashing.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
90
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/hashtable.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
91
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/index.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
92
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/internals.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
93
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/interval.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
94
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/join.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
95
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/lib.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
96
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/missing.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
97
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/ops.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
98
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/parsers.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
99
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/properties.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
100
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/reshape.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
101
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/sas.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
102
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/sparse.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
103
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/testing.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
104
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslib.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
105
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/ccalendar.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
106
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/conversion.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
107
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/dtypes.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
108
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/fields.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
109
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/nattype.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
110
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/np_datetime.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
111
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/offsets.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
112
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/parsing.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
113
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/period.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
114
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/strptime.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
115
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/timedeltas.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
116
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/timestamps.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
117
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/timezones.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
118
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/tzconversion.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
119
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/tslibs/vectorized.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
120
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/window/aggregations.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
121
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/window/indexers.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
122
+ src/.venv/lib/python3.11/site-packages/pandas/_libs/writers.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
123
+ src/.venv/lib/python3.11/site-packages/pydantic_core/_pydantic_core.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
124
+ src/.venv/lib/python3.11/site-packages/yaml/_yaml.cpython-311-darwin.so filter=lfs diff=lfs merge=lfs -text
125
+ src/images/demo.png filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ .eggs/
2
+ dist/
3
+ *.pyc
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+ __tmp/*
8
+ *.pyi
9
+ node_modules
README.md CHANGED
@@ -1,12 +1,533 @@
1
- ---
2
- title: Gradio Patch Selection
3
- emoji: 🐢
4
- colorFrom: gray
5
- colorTo: purple
6
- sdk: gradio
7
- sdk_version: 5.25.2
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # `gradio_patch_selection`
3
+ <a href="https://pypi.org/project/gradio_patch_selection/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_patch_selection"></a>
4
+
5
+ A Gradio component that allows users to select patches from images by overlaying a customizable grid.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install gradio_patch_selection
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```python
16
+ # filepath: /Users/dgcnz/development/playground/gradio_image_annotator/demo/app_dynamic_inputs.py
17
+ import gradio as gr
18
+ from gradio_patch_selection import PatchSelector
19
+
20
+
21
+ # Default values for image size and patch size
22
+ DEFAULT_IMG_SIZE = 224
23
+ DEFAULT_PATCH_SIZE = 16
24
+
25
+ example_annotation = {
26
+ "image": "https://gradio-builds.s3.amazonaws.com/demo-files/base.png",
27
+ "patch_index": 42, # Example patch index
28
+ "img_size": DEFAULT_IMG_SIZE,
29
+ "patch_size": DEFAULT_PATCH_SIZE
30
+ }
31
+
32
+ examples = [
33
+ {
34
+ "image": "https://raw.githubusercontent.com/gradio-app/gradio/main/guides/assets/logo.png",
35
+ "patch_index": 10, # Example patch index
36
+ "img_size": DEFAULT_IMG_SIZE,
37
+ "patch_size": DEFAULT_PATCH_SIZE
38
+ },
39
+ {
40
+ "image": "https://gradio-builds.s3.amazonaws.com/demo-files/base.png",
41
+ "patch_index": 42, # Example patch index
42
+ "img_size": DEFAULT_IMG_SIZE,
43
+ "patch_size": DEFAULT_PATCH_SIZE
44
+ },
45
+ ]
46
+
47
+
48
+ def get_patch_index(annotations):
49
+ """Get the selected patch index from annotations"""
50
+ if annotations and annotations.get("patch_index") is not None:
51
+ return f"Selected Patch Index: {annotations['patch_index']}"
52
+ return "No patch selected"
53
+
54
+
55
+ def update_params(img_size, patch_size, current_annotation):
56
+ """Update patch_size and img_size based on user inputs"""
57
+ if not current_annotation:
58
+ current_annotation = {"image": None, "patch_index": None}
59
+
60
+ # Ensure values are integers and within reasonable bounds
61
+ img_size = max(32, min(1024, int(img_size)))
62
+ patch_size = max(1, min(128, int(patch_size)))
63
+
64
+ # Preserve the existing image and patch_index if they exist
65
+ current_annotation["img_size"] = img_size
66
+ current_annotation["patch_size"] = patch_size
67
+
68
+ # Return updated annotation and parameter info string
69
+ param_info = f"Image Size: {img_size}x{img_size}\nPatch Size: {patch_size}x{patch_size}"
70
+
71
+ # Calculate grid dimensions
72
+ grid_width = img_size // patch_size
73
+ grid_height = img_size // patch_size
74
+ grid_info = f"Grid Dimensions: {grid_width}x{grid_height} ({grid_width * grid_height} patches)"
75
+
76
+ return current_annotation, param_info, grid_info
77
+
78
+
79
+ with gr.Blocks() as demo:
80
+ with gr.Tab("Dynamic Patch Selector", id="tab_dynamic_patch_selector"):
81
+ gr.Markdown("# Dynamic Patch Selector Demo")
82
+ gr.Markdown("This demo shows how to dynamically update the patch size and image size using number inputs.")
83
+
84
+ with gr.Row():
85
+ with gr.Column(scale=1):
86
+ img_size_input = gr.Number(
87
+ value=DEFAULT_IMG_SIZE,
88
+ label="Image Size",
89
+ minimum=32,
90
+ maximum=1024,
91
+ step=16,
92
+ precision=0
93
+ )
94
+ patch_size_input = gr.Number(
95
+ value=DEFAULT_PATCH_SIZE,
96
+ label="Patch Size",
97
+ minimum=1,
98
+ maximum=128,
99
+ step=1,
100
+ precision=0
101
+ )
102
+ param_info = gr.Textbox(
103
+ value=f"Image Size: {DEFAULT_IMG_SIZE}x{DEFAULT_IMG_SIZE}\nPatch Size: {DEFAULT_PATCH_SIZE}x{DEFAULT_PATCH_SIZE}",
104
+ label="Parameters",
105
+ interactive=False
106
+ )
107
+ grid_info = gr.Textbox(
108
+ value=f"Grid Dimensions: {DEFAULT_IMG_SIZE//DEFAULT_PATCH_SIZE}x{DEFAULT_IMG_SIZE//DEFAULT_PATCH_SIZE} ({(DEFAULT_IMG_SIZE//DEFAULT_PATCH_SIZE)**2} patches)",
109
+ label="Grid Information",
110
+ interactive=False
111
+ )
112
+
113
+ with gr.Row():
114
+ with gr.Column(scale=2):
115
+ annotator = PatchSelector(
116
+ example_annotation,
117
+ img_size=DEFAULT_IMG_SIZE, # Default image size
118
+ patch_size=DEFAULT_PATCH_SIZE, # Default patch size
119
+ show_grid=True,
120
+ grid_color="rgba(200, 200, 200, 0.5)"
121
+ )
122
+
123
+ with gr.Column(scale=1):
124
+ output = gr.Textbox(label="Selected Patch", value="No patch selected")
125
+ gr.Markdown("### How it works")
126
+ gr.Markdown("1. Adjust the image size and patch size using the number inputs")
127
+ gr.Markdown("2. The grid will update automatically based on your inputs")
128
+ gr.Markdown("3. Click on any patch to select it and get its index")
129
+
130
+ # Handle the parameter change events
131
+ img_size_input.change(
132
+ update_params,
133
+ inputs=[img_size_input, patch_size_input, annotator],
134
+ outputs=[annotator, param_info, grid_info]
135
+ )
136
+
137
+ patch_size_input.change(
138
+ update_params,
139
+ inputs=[img_size_input, patch_size_input, annotator],
140
+ outputs=[annotator, param_info, grid_info]
141
+ )
142
+
143
+ # Handle the patch selection event
144
+ annotator.patch_select(get_patch_index, annotator, output)
145
+
146
+ gr.Examples(examples, annotator)
147
+
148
+ if __name__ == "__main__":
149
+ demo.launch()
150
+
151
+ ```
152
+
153
+ ## `PatchSelector`
154
+
155
+ ### Initialization
156
+
157
+ <table>
158
+ <thead>
159
+ <tr>
160
+ <th align="left">name</th>
161
+ <th align="left" style="width: 25%;">type</th>
162
+ <th align="left">default</th>
163
+ <th align="left">description</th>
164
+ </tr>
165
+ </thead>
166
+ <tbody>
167
+ <tr>
168
+ <td align="left"><code>value</code></td>
169
+ <td align="left" style="width: 25%;">
170
+
171
+ ```python
172
+ dict | None
173
+ ```
174
+
175
+ </td>
176
+ <td align="left"><code>None</code></td>
177
+ <td align="left">A dict or None. The dictionary must contain a key 'image' with either an URL to an image, a numpy image or a PIL image. It may also contain a key 'patchIndex' with the index of the selected patch.</td>
178
+ </tr>
179
+
180
+ <tr>
181
+ <td align="left"><code>height</code></td>
182
+ <td align="left" style="width: 25%;">
183
+
184
+ ```python
185
+ int | str | None
186
+ ```
187
+
188
+ </td>
189
+ <td align="left"><code>None</code></td>
190
+ <td align="left">The height of the displayed image, specified in pixels if a number is passed, or in CSS units if a string is passed.</td>
191
+ </tr>
192
+
193
+ <tr>
194
+ <td align="left"><code>width</code></td>
195
+ <td align="left" style="width: 25%;">
196
+
197
+ ```python
198
+ int | str | None
199
+ ```
200
+
201
+ </td>
202
+ <td align="left"><code>None</code></td>
203
+ <td align="left">The width of the displayed image, specified in pixels if a number is passed, or in CSS units if a string is passed.</td>
204
+ </tr>
205
+
206
+ <tr>
207
+ <td align="left"><code>img_size</code></td>
208
+ <td align="left" style="width: 25%;">
209
+
210
+ ```python
211
+ int | None
212
+ ```
213
+
214
+ </td>
215
+ <td align="left"><code>None</code></td>
216
+ <td align="left">If provided, will resize the displayed image to this fixed dimension (img_size × img_size). This takes precedence over height and width parameters. Recommended for ViT models, which typically use square images of fixed dimensions (e.g., 224x224).</td>
217
+ </tr>
218
+
219
+ <tr>
220
+ <td align="left"><code>patch_size</code></td>
221
+ <td align="left" style="width: 25%;">
222
+
223
+ ```python
224
+ int
225
+ ```
226
+
227
+ </td>
228
+ <td align="left"><code>16</code></td>
229
+ <td align="left">The size of each patch in pixels. For a 224x224 image with patch_size=16, there will be a 14x14 grid (196 patches).</td>
230
+ </tr>
231
+
232
+ <tr>
233
+ <td align="left"><code>show_grid</code></td>
234
+ <td align="left" style="width: 25%;">
235
+
236
+ ```python
237
+ bool
238
+ ```
239
+
240
+ </td>
241
+ <td align="left"><code>True</code></td>
242
+ <td align="left">If True, will display the grid overlay on the image.</td>
243
+ </tr>
244
+
245
+ <tr>
246
+ <td align="left"><code>grid_color</code></td>
247
+ <td align="left" style="width: 25%;">
248
+
249
+ ```python
250
+ str
251
+ ```
252
+
253
+ </td>
254
+ <td align="left"><code>"rgba(200, 200, 200, 0.5)"</code></td>
255
+ <td align="left">The color of the grid overlay lines, specified as a CSS color string.</td>
256
+ </tr>
257
+
258
+ <tr>
259
+ <td align="left"><code>image_mode</code></td>
260
+ <td align="left" style="width: 25%;">
261
+
262
+ ```python
263
+ "1"
264
+ | "L"
265
+ | "P"
266
+ | "RGB"
267
+ | "RGBA"
268
+ | "CMYK"
269
+ | "YCbCr"
270
+ | "LAB"
271
+ | "HSV"
272
+ | "I"
273
+ | "F"
274
+ ```
275
+
276
+ </td>
277
+ <td align="left"><code>"RGB"</code></td>
278
+ <td align="left">"RGB" if color, or "L" if black and white. See https://pillow.readthedocs.io/en/stable/handbook/concepts.html for other supported image modes and their meaning.</td>
279
+ </tr>
280
+
281
+ <tr>
282
+ <td align="left"><code>sources</code></td>
283
+ <td align="left" style="width: 25%;">
284
+
285
+ ```python
286
+ list["upload" | "webcam" | "clipboard"] | None
287
+ ```
288
+
289
+ </td>
290
+ <td align="left"><code>["upload", "webcam", "clipboard"]</code></td>
291
+ <td align="left">List of sources for the image. "upload" creates a box where user can drop an image file, "webcam" allows user to take snapshot from their webcam, "clipboard" allows users to paste an image from the clipboard. If None, defaults to ["upload", "webcam", "clipboard"].</td>
292
+ </tr>
293
+
294
+ <tr>
295
+ <td align="left"><code>image_type</code></td>
296
+ <td align="left" style="width: 25%;">
297
+
298
+ ```python
299
+ "numpy" | "pil" | "filepath"
300
+ ```
301
+
302
+ </td>
303
+ <td align="left"><code>"numpy"</code></td>
304
+ <td align="left">The format the image is converted before being passed into the prediction function. "numpy" converts the image to a numpy array with shape (height, width, 3) and values from 0 to 255, "pil" converts the image to a PIL image object, "filepath" passes a str path to a temporary file containing the image. If the image is SVG, the `type` is ignored and the filepath of the SVG is returned.</td>
305
+ </tr>
306
+
307
+ <tr>
308
+ <td align="left"><code>label</code></td>
309
+ <td align="left" style="width: 25%;">
310
+
311
+ ```python
312
+ str | None
313
+ ```
314
+
315
+ </td>
316
+ <td align="left"><code>None</code></td>
317
+ <td align="left">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>
318
+ </tr>
319
+
320
+ <tr>
321
+ <td align="left"><code>container</code></td>
322
+ <td align="left" style="width: 25%;">
323
+
324
+ ```python
325
+ bool
326
+ ```
327
+
328
+ </td>
329
+ <td align="left"><code>True</code></td>
330
+ <td align="left">If True, will place the component in a container - providing some extra padding around the border.</td>
331
+ </tr>
332
+
333
+ <tr>
334
+ <td align="left"><code>scale</code></td>
335
+ <td align="left" style="width: 25%;">
336
+
337
+ ```python
338
+ int | None
339
+ ```
340
+
341
+ </td>
342
+ <td align="left"><code>None</code></td>
343
+ <td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
344
+ </tr>
345
+
346
+ <tr>
347
+ <td align="left"><code>min_width</code></td>
348
+ <td align="left" style="width: 25%;">
349
+
350
+ ```python
351
+ int
352
+ ```
353
+
354
+ </td>
355
+ <td align="left"><code>160</code></td>
356
+ <td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
357
+ </tr>
358
+
359
+ <tr>
360
+ <td align="left"><code>interactive</code></td>
361
+ <td align="left" style="width: 25%;">
362
+
363
+ ```python
364
+ bool | None
365
+ ```
366
+
367
+ </td>
368
+ <td align="left"><code>True</code></td>
369
+ <td align="left">if True, will allow users to upload and annotate an image; if False, can only be used to display annotated images.</td>
370
+ </tr>
371
+
372
+ <tr>
373
+ <td align="left"><code>visible</code></td>
374
+ <td align="left" style="width: 25%;">
375
+
376
+ ```python
377
+ bool
378
+ ```
379
+
380
+ </td>
381
+ <td align="left"><code>True</code></td>
382
+ <td align="left">If False, component will be hidden.</td>
383
+ </tr>
384
+
385
+ <tr>
386
+ <td align="left"><code>elem_id</code></td>
387
+ <td align="left" style="width: 25%;">
388
+
389
+ ```python
390
+ str | None
391
+ ```
392
+
393
+ </td>
394
+ <td align="left"><code>None</code></td>
395
+ <td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
396
+ </tr>
397
+
398
+ <tr>
399
+ <td align="left"><code>elem_classes</code></td>
400
+ <td align="left" style="width: 25%;">
401
+
402
+ ```python
403
+ list[str] | str | None
404
+ ```
405
+
406
+ </td>
407
+ <td align="left"><code>None</code></td>
408
+ <td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
409
+ </tr>
410
+
411
+ <tr>
412
+ <td align="left"><code>render</code></td>
413
+ <td align="left" style="width: 25%;">
414
+
415
+ ```python
416
+ bool
417
+ ```
418
+
419
+ </td>
420
+ <td align="left"><code>True</code></td>
421
+ <td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
422
+ </tr>
423
+
424
+ <tr>
425
+ <td align="left"><code>show_label</code></td>
426
+ <td align="left" style="width: 25%;">
427
+
428
+ ```python
429
+ bool | None
430
+ ```
431
+
432
+ </td>
433
+ <td align="left"><code>None</code></td>
434
+ <td align="left">if True, will display label.</td>
435
+ </tr>
436
+
437
+ <tr>
438
+ <td align="left"><code>show_download_button</code></td>
439
+ <td align="left" style="width: 25%;">
440
+
441
+ ```python
442
+ bool
443
+ ```
444
+
445
+ </td>
446
+ <td align="left"><code>True</code></td>
447
+ <td align="left">If True, will show a button to download the image.</td>
448
+ </tr>
449
+
450
+ <tr>
451
+ <td align="left"><code>show_share_button</code></td>
452
+ <td align="left" style="width: 25%;">
453
+
454
+ ```python
455
+ bool | None
456
+ ```
457
+
458
+ </td>
459
+ <td align="left"><code>None</code></td>
460
+ <td align="left">If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.</td>
461
+ </tr>
462
+
463
+ <tr>
464
+ <td align="left"><code>show_clear_button</code></td>
465
+ <td align="left" style="width: 25%;">
466
+
467
+ ```python
468
+ bool | None
469
+ ```
470
+
471
+ </td>
472
+ <td align="left"><code>True</code></td>
473
+ <td align="left">If True, will show a button to clear the current image.</td>
474
+ </tr>
475
+
476
+ <tr>
477
+ <td align="left"><code>show_remove_button</code></td>
478
+ <td align="left" style="width: 25%;">
479
+
480
+ ```python
481
+ bool | None
482
+ ```
483
+
484
+ </td>
485
+ <td align="left"><code>None</code></td>
486
+ <td align="left">If True, will show a button to remove the selected bounding box.</td>
487
+ </tr>
488
+
489
+ <tr>
490
+ <td align="left"><code>handles_cursor</code></td>
491
+ <td align="left" style="width: 25%;">
492
+
493
+ ```python
494
+ bool | None
495
+ ```
496
+
497
+ </td>
498
+ <td align="left"><code>True</code></td>
499
+ <td align="left">If True, the cursor will change when hovering over box handles in drag mode. Can be CPU-intensive.</td>
500
+ </tr>
501
+ </tbody></table>
502
+
503
+
504
+ ### Events
505
+
506
+ | name | description |
507
+ |:-----|:------------|
508
+ | `clear` | This listener is triggered when the user clears the PatchSelector using the clear button for the component. |
509
+ | `change` | Triggered when the value of the PatchSelector changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
510
+ | `upload` | This listener is triggered when the user uploads a file into the PatchSelector. |
511
+ | `patch_select` | Triggered when a patch is selected by the user. Returns the patch index. |
512
+
513
+
514
+
515
+ ### User function
516
+
517
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
518
+
519
+ - When used as an Input, the component only impacts the input signature of the user function.
520
+ - When used as an output, the component only impacts the return signature of the user function.
521
+
522
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
523
+
524
+ - **As output:** Is passed, a dict with the image, patchIndex, imgSize, and patchSize or None.
525
+ - **As input:** Should return, a dict with an image and an optional patchIndex or None.
526
+
527
+ ```python
528
+ def predict(
529
+ value: dict | None
530
+ ) -> dict | None:
531
+ return value
532
+ ```
533
+
__init__.py ADDED
File without changes
app.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filepath: /Users/dgcnz/development/playground/gradio_image_annotator/demo/app_dynamic_inputs.py
2
+ import gradio as gr
3
+ from gradio_patch_selection import PatchSelector
4
+
5
+
6
+ # Default values for image size and patch size
7
+ DEFAULT_IMG_SIZE = 224
8
+ DEFAULT_PATCH_SIZE = 16
9
+
10
+ example_annotation = {
11
+ "image": "https://gradio-builds.s3.amazonaws.com/demo-files/base.png",
12
+ "patch_index": 42, # Example patch index
13
+ "img_size": DEFAULT_IMG_SIZE,
14
+ "patch_size": DEFAULT_PATCH_SIZE
15
+ }
16
+
17
+ examples = [
18
+ {
19
+ "image": "https://raw.githubusercontent.com/gradio-app/gradio/main/guides/assets/logo.png",
20
+ "patch_index": 10, # Example patch index
21
+ "img_size": DEFAULT_IMG_SIZE,
22
+ "patch_size": DEFAULT_PATCH_SIZE
23
+ },
24
+ {
25
+ "image": "https://gradio-builds.s3.amazonaws.com/demo-files/base.png",
26
+ "patch_index": 42, # Example patch index
27
+ "img_size": DEFAULT_IMG_SIZE,
28
+ "patch_size": DEFAULT_PATCH_SIZE
29
+ },
30
+ ]
31
+
32
+
33
+ def get_patch_index(annotations):
34
+ """Get the selected patch index from annotations"""
35
+ if annotations and annotations.get("patch_index") is not None:
36
+ return f"Selected Patch Index: {annotations['patch_index']}"
37
+ return "No patch selected"
38
+
39
+
40
+ def update_params(img_size, patch_size, current_annotation):
41
+ """Update patch_size and img_size based on user inputs"""
42
+ if not current_annotation:
43
+ current_annotation = {"image": None, "patch_index": None}
44
+
45
+ # Ensure values are integers and within reasonable bounds
46
+ img_size = max(32, min(1024, int(img_size)))
47
+ patch_size = max(1, min(128, int(patch_size)))
48
+
49
+ # Preserve the existing image and patch_index if they exist
50
+ current_annotation["img_size"] = img_size
51
+ current_annotation["patch_size"] = patch_size
52
+
53
+ # Return updated annotation and parameter info string
54
+ param_info = f"Image Size: {img_size}x{img_size}\nPatch Size: {patch_size}x{patch_size}"
55
+
56
+ # Calculate grid dimensions
57
+ grid_width = img_size // patch_size
58
+ grid_height = img_size // patch_size
59
+ grid_info = f"Grid Dimensions: {grid_width}x{grid_height} ({grid_width * grid_height} patches)"
60
+
61
+ return current_annotation, param_info, grid_info
62
+
63
+
64
+ with gr.Blocks() as demo:
65
+ with gr.Tab("Dynamic Patch Selector", id="tab_dynamic_patch_selector"):
66
+ gr.Markdown("# Dynamic Patch Selector Demo")
67
+ gr.Markdown("This demo shows how to dynamically update the patch size and image size using number inputs.")
68
+
69
+ with gr.Row():
70
+ with gr.Column(scale=1):
71
+ img_size_input = gr.Number(
72
+ value=DEFAULT_IMG_SIZE,
73
+ label="Image Size",
74
+ minimum=32,
75
+ maximum=1024,
76
+ step=16,
77
+ precision=0
78
+ )
79
+ patch_size_input = gr.Number(
80
+ value=DEFAULT_PATCH_SIZE,
81
+ label="Patch Size",
82
+ minimum=1,
83
+ maximum=128,
84
+ step=1,
85
+ precision=0
86
+ )
87
+ param_info = gr.Textbox(
88
+ value=f"Image Size: {DEFAULT_IMG_SIZE}x{DEFAULT_IMG_SIZE}\nPatch Size: {DEFAULT_PATCH_SIZE}x{DEFAULT_PATCH_SIZE}",
89
+ label="Parameters",
90
+ interactive=False
91
+ )
92
+ grid_info = gr.Textbox(
93
+ value=f"Grid Dimensions: {DEFAULT_IMG_SIZE//DEFAULT_PATCH_SIZE}x{DEFAULT_IMG_SIZE//DEFAULT_PATCH_SIZE} ({(DEFAULT_IMG_SIZE//DEFAULT_PATCH_SIZE)**2} patches)",
94
+ label="Grid Information",
95
+ interactive=False
96
+ )
97
+
98
+ with gr.Row():
99
+ with gr.Column(scale=2):
100
+ annotator = PatchSelector(
101
+ example_annotation,
102
+ img_size=DEFAULT_IMG_SIZE, # Default image size
103
+ patch_size=DEFAULT_PATCH_SIZE, # Default patch size
104
+ show_grid=True,
105
+ grid_color="rgba(200, 200, 200, 0.5)"
106
+ )
107
+
108
+ with gr.Column(scale=1):
109
+ output = gr.Textbox(label="Selected Patch", value="No patch selected")
110
+ gr.Markdown("### How it works")
111
+ gr.Markdown("1. Adjust the image size and patch size using the number inputs")
112
+ gr.Markdown("2. The grid will update automatically based on your inputs")
113
+ gr.Markdown("3. Click on any patch to select it and get its index")
114
+
115
+ # Handle the parameter change events
116
+ img_size_input.change(
117
+ update_params,
118
+ inputs=[img_size_input, patch_size_input, annotator],
119
+ outputs=[annotator, param_info, grid_info]
120
+ )
121
+
122
+ patch_size_input.change(
123
+ update_params,
124
+ inputs=[img_size_input, patch_size_input, annotator],
125
+ outputs=[annotator, param_info, grid_info]
126
+ )
127
+
128
+ # Handle the patch selection event
129
+ annotator.patch_select(get_patch_index, annotator, output)
130
+
131
+ gr.Examples(examples, annotator)
132
+
133
+ if __name__ == "__main__":
134
+ demo.launch()
css.css ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ html {
2
+ font-family: Inter;
3
+ font-size: 16px;
4
+ font-weight: 400;
5
+ line-height: 1.5;
6
+ -webkit-text-size-adjust: 100%;
7
+ background: #fff;
8
+ color: #323232;
9
+ -webkit-font-smoothing: antialiased;
10
+ -moz-osx-font-smoothing: grayscale;
11
+ text-rendering: optimizeLegibility;
12
+ }
13
+
14
+ :root {
15
+ --space: 1;
16
+ --vspace: calc(var(--space) * 1rem);
17
+ --vspace-0: calc(3 * var(--space) * 1rem);
18
+ --vspace-1: calc(2 * var(--space) * 1rem);
19
+ --vspace-2: calc(1.5 * var(--space) * 1rem);
20
+ --vspace-3: calc(0.5 * var(--space) * 1rem);
21
+ }
22
+
23
+ .app {
24
+ max-width: 748px !important;
25
+ }
26
+
27
+ .prose p {
28
+ margin: var(--vspace) 0;
29
+ line-height: var(--vspace * 2);
30
+ font-size: 1rem;
31
+ }
32
+
33
+ code {
34
+ font-family: "Inconsolata", sans-serif;
35
+ font-size: 16px;
36
+ }
37
+
38
+ h1,
39
+ h1 code {
40
+ font-weight: 400;
41
+ line-height: calc(2.5 / var(--space) * var(--vspace));
42
+ }
43
+
44
+ h1 code {
45
+ background: none;
46
+ border: none;
47
+ letter-spacing: 0.05em;
48
+ padding-bottom: 5px;
49
+ position: relative;
50
+ padding: 0;
51
+ }
52
+
53
+ h2 {
54
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
55
+ line-height: 1em;
56
+ }
57
+
58
+ h3,
59
+ h3 code {
60
+ margin: var(--vspace-1) 0 var(--vspace-2) 0;
61
+ line-height: 1em;
62
+ }
63
+
64
+ h4,
65
+ h5,
66
+ h6 {
67
+ margin: var(--vspace-3) 0 var(--vspace-3) 0;
68
+ line-height: var(--vspace);
69
+ }
70
+
71
+ .bigtitle,
72
+ h1,
73
+ h1 code {
74
+ font-size: calc(8px * 4.5);
75
+ word-break: break-word;
76
+ }
77
+
78
+ .title,
79
+ h2,
80
+ h2 code {
81
+ font-size: calc(8px * 3.375);
82
+ font-weight: lighter;
83
+ word-break: break-word;
84
+ border: none;
85
+ background: none;
86
+ }
87
+
88
+ .subheading1,
89
+ h3,
90
+ h3 code {
91
+ font-size: calc(8px * 1.8);
92
+ font-weight: 600;
93
+ border: none;
94
+ background: none;
95
+ letter-spacing: 0.1em;
96
+ text-transform: uppercase;
97
+ }
98
+
99
+ h2 code {
100
+ padding: 0;
101
+ position: relative;
102
+ letter-spacing: 0.05em;
103
+ }
104
+
105
+ blockquote {
106
+ font-size: calc(8px * 1.1667);
107
+ font-style: italic;
108
+ line-height: calc(1.1667 * var(--vspace));
109
+ margin: var(--vspace-2) var(--vspace-2);
110
+ }
111
+
112
+ .subheading2,
113
+ h4 {
114
+ font-size: calc(8px * 1.4292);
115
+ text-transform: uppercase;
116
+ font-weight: 600;
117
+ }
118
+
119
+ .subheading3,
120
+ h5 {
121
+ font-size: calc(8px * 1.2917);
122
+ line-height: calc(1.2917 * var(--vspace));
123
+
124
+ font-weight: lighter;
125
+ text-transform: uppercase;
126
+ letter-spacing: 0.15em;
127
+ }
128
+
129
+ h6 {
130
+ font-size: calc(8px * 1.1667);
131
+ font-size: 1.1667em;
132
+ font-weight: normal;
133
+ font-style: italic;
134
+ font-family: "le-monde-livre-classic-byol", serif !important;
135
+ letter-spacing: 0px !important;
136
+ }
137
+
138
+ #start .md > *:first-child {
139
+ margin-top: 0;
140
+ }
141
+
142
+ h2 + h3 {
143
+ margin-top: 0;
144
+ }
145
+
146
+ .md hr {
147
+ border: none;
148
+ border-top: 1px solid var(--block-border-color);
149
+ margin: var(--vspace-2) 0 var(--vspace-2) 0;
150
+ }
151
+ .prose ul {
152
+ margin: var(--vspace-2) 0 var(--vspace-1) 0;
153
+ }
154
+
155
+ .gap {
156
+ gap: 0;
157
+ }
space.py ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from app import demo as app
4
+ import os
5
+
6
+ _docs = {'PatchSelector': {'description': 'Creates a component that allows the user to select a patch from an image. \nThe image is divided into a grid based on the patch_size parameter, and the user can click on a patch to select it.\nThis is useful for visualizing attention maps in Vision Transformer models.', 'members': {'__init__': {'value': {'type': 'dict | None', 'default': 'None', 'description': "A dict or None. The dictionary must contain a key 'image' with either an URL to an image, a numpy image or a PIL image. It may also contain a key 'patchIndex' with the index of the selected patch."}, 'height': {'type': 'int | str | None', 'default': 'None', 'description': 'The height of the displayed image, specified in pixels if a number is passed, or in CSS units if a string is passed.'}, 'width': {'type': 'int | str | None', 'default': 'None', 'description': 'The width of the displayed image, specified in pixels if a number is passed, or in CSS units if a string is passed.'}, 'img_size': {'type': 'int | None', 'default': 'None', 'description': 'If provided, will resize the displayed image to this fixed dimension (img_size × img_size). This takes precedence over height and width parameters. Recommended for ViT models, which typically use square images of fixed dimensions (e.g., 224x224).'}, 'patch_size': {'type': 'int', 'default': '16', 'description': 'The size of each patch in pixels. For a 224x224 image with patch_size=16, there will be a 14x14 grid (196 patches).'}, 'show_grid': {'type': 'bool', 'default': 'True', 'description': 'If True, will display the grid overlay on the image.'}, 'grid_color': {'type': 'str', 'default': '"rgba(200, 200, 200, 0.5)"', 'description': 'The color of the grid overlay lines, specified as a CSS color string.'}, 'image_mode': {'type': '"1"\n | "L"\n | "P"\n | "RGB"\n | "RGBA"\n | "CMYK"\n | "YCbCr"\n | "LAB"\n | "HSV"\n | "I"\n | "F"', 'default': '"RGB"', 'description': '"RGB" if color, or "L" if black and white. See https://pillow.readthedocs.io/en/stable/handbook/concepts.html for other supported image modes and their meaning.'}, 'sources': {'type': 'list["upload" | "webcam" | "clipboard"] | None', 'default': '["upload", "webcam", "clipboard"]', 'description': 'List of sources for the image. "upload" creates a box where user can drop an image file, "webcam" allows user to take snapshot from their webcam, "clipboard" allows users to paste an image from the clipboard. If None, defaults to ["upload", "webcam", "clipboard"].'}, 'image_type': {'type': '"numpy" | "pil" | "filepath"', 'default': '"numpy"', 'description': 'The format the image is converted before being passed into the prediction function. "numpy" converts the image to a numpy array with shape (height, width, 3) and values from 0 to 255, "pil" converts the image to a PIL image object, "filepath" passes a str path to a temporary file containing the image. If the image is SVG, the `type` is ignored and the filepath of the SVG is returned.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'container': {'type': 'bool', 'default': 'True', 'description': 'If True, will place the component in a container - providing some extra padding around the border.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'True', 'description': 'if True, will allow users to upload and annotate an image; if False, can only be used to display annotated images.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': 'An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'show_download_button': {'type': 'bool', 'default': 'True', 'description': 'If True, will show a button to download the image.'}, 'show_share_button': {'type': 'bool | None', 'default': 'None', 'description': 'If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.'}, 'show_clear_button': {'type': 'bool | None', 'default': 'True', 'description': 'If True, will show a button to clear the current image.'}, 'show_remove_button': {'type': 'bool | None', 'default': 'None', 'description': 'If True, will show a button to remove the selected bounding box.'}, 'handles_cursor': {'type': 'bool | None', 'default': 'True', 'description': 'If True, the cursor will change when hovering over box handles in drag mode. Can be CPU-intensive.'}}, 'postprocess': {'value': {'type': 'dict | None', 'description': 'A dict with an image and an optional patchIndex or None.'}}, 'preprocess': {'return': {'type': 'dict | None', 'description': 'A dict with the image, patchIndex, imgSize, and patchSize or None.'}, 'value': None}}, 'events': {'clear': {'type': None, 'default': None, 'description': 'This listener is triggered when the user clears the PatchSelector using the clear button for the component.'}, 'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the PatchSelector changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'upload': {'type': None, 'default': None, 'description': 'This listener is triggered when the user uploads a file into the PatchSelector.'}, 'patch_select': {'type': None, 'default': None, 'description': 'Triggered when a patch is selected by the user. Returns the patch index.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'PatchSelector': []}}}
7
+
8
+ abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
+
10
+ with gr.Blocks(
11
+ css=abs_path,
12
+ theme=gr.themes.Default(
13
+ font_mono=[
14
+ gr.themes.GoogleFont("Inconsolata"),
15
+ "monospace",
16
+ ],
17
+ ),
18
+ ) as demo:
19
+ gr.Markdown(
20
+ """
21
+ # `gradio_patch_selection`
22
+
23
+ <div style="display: flex; gap: 7px;">
24
+ <a href="https://pypi.org/project/gradio_patch_selection/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_patch_selection"></a>
25
+ </div>
26
+
27
+ A Gradio component that allows users to select patches from images by overlaying a customizable grid.
28
+ """, elem_classes=["md-custom"], header_links=True)
29
+ app.render()
30
+ gr.Markdown(
31
+ """
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install gradio_patch_selection
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ # filepath: /Users/dgcnz/development/playground/gradio_image_annotator/demo/app_dynamic_inputs.py
42
+ import gradio as gr
43
+ from gradio_patch_selection import PatchSelector
44
+
45
+
46
+ # Default values for image size and patch size
47
+ DEFAULT_IMG_SIZE = 224
48
+ DEFAULT_PATCH_SIZE = 16
49
+
50
+ example_annotation = {
51
+ "image": "https://gradio-builds.s3.amazonaws.com/demo-files/base.png",
52
+ "patch_index": 42, # Example patch index
53
+ "img_size": DEFAULT_IMG_SIZE,
54
+ "patch_size": DEFAULT_PATCH_SIZE
55
+ }
56
+
57
+ examples = [
58
+ {
59
+ "image": "https://raw.githubusercontent.com/gradio-app/gradio/main/guides/assets/logo.png",
60
+ "patch_index": 10, # Example patch index
61
+ "img_size": DEFAULT_IMG_SIZE,
62
+ "patch_size": DEFAULT_PATCH_SIZE
63
+ },
64
+ {
65
+ "image": "https://gradio-builds.s3.amazonaws.com/demo-files/base.png",
66
+ "patch_index": 42, # Example patch index
67
+ "img_size": DEFAULT_IMG_SIZE,
68
+ "patch_size": DEFAULT_PATCH_SIZE
69
+ },
70
+ ]
71
+
72
+
73
+ def get_patch_index(annotations):
74
+ \"\"\"Get the selected patch index from annotations\"\"\"
75
+ if annotations and annotations.get("patch_index") is not None:
76
+ return f"Selected Patch Index: {annotations['patch_index']}"
77
+ return "No patch selected"
78
+
79
+
80
+ def update_params(img_size, patch_size, current_annotation):
81
+ \"\"\"Update patch_size and img_size based on user inputs\"\"\"
82
+ if not current_annotation:
83
+ current_annotation = {"image": None, "patch_index": None}
84
+
85
+ # Ensure values are integers and within reasonable bounds
86
+ img_size = max(32, min(1024, int(img_size)))
87
+ patch_size = max(1, min(128, int(patch_size)))
88
+
89
+ # Preserve the existing image and patch_index if they exist
90
+ current_annotation["img_size"] = img_size
91
+ current_annotation["patch_size"] = patch_size
92
+
93
+ # Return updated annotation and parameter info string
94
+ param_info = f"Image Size: {img_size}x{img_size}\nPatch Size: {patch_size}x{patch_size}"
95
+
96
+ # Calculate grid dimensions
97
+ grid_width = img_size // patch_size
98
+ grid_height = img_size // patch_size
99
+ grid_info = f"Grid Dimensions: {grid_width}x{grid_height} ({grid_width * grid_height} patches)"
100
+
101
+ return current_annotation, param_info, grid_info
102
+
103
+
104
+ with gr.Blocks() as demo:
105
+ with gr.Tab("Dynamic Patch Selector", id="tab_dynamic_patch_selector"):
106
+ gr.Markdown("# Dynamic Patch Selector Demo")
107
+ gr.Markdown("This demo shows how to dynamically update the patch size and image size using number inputs.")
108
+
109
+ with gr.Row():
110
+ with gr.Column(scale=1):
111
+ img_size_input = gr.Number(
112
+ value=DEFAULT_IMG_SIZE,
113
+ label="Image Size",
114
+ minimum=32,
115
+ maximum=1024,
116
+ step=16,
117
+ precision=0
118
+ )
119
+ patch_size_input = gr.Number(
120
+ value=DEFAULT_PATCH_SIZE,
121
+ label="Patch Size",
122
+ minimum=1,
123
+ maximum=128,
124
+ step=1,
125
+ precision=0
126
+ )
127
+ param_info = gr.Textbox(
128
+ value=f"Image Size: {DEFAULT_IMG_SIZE}x{DEFAULT_IMG_SIZE}\nPatch Size: {DEFAULT_PATCH_SIZE}x{DEFAULT_PATCH_SIZE}",
129
+ label="Parameters",
130
+ interactive=False
131
+ )
132
+ grid_info = gr.Textbox(
133
+ value=f"Grid Dimensions: {DEFAULT_IMG_SIZE//DEFAULT_PATCH_SIZE}x{DEFAULT_IMG_SIZE//DEFAULT_PATCH_SIZE} ({(DEFAULT_IMG_SIZE//DEFAULT_PATCH_SIZE)**2} patches)",
134
+ label="Grid Information",
135
+ interactive=False
136
+ )
137
+
138
+ with gr.Row():
139
+ with gr.Column(scale=2):
140
+ annotator = PatchSelector(
141
+ example_annotation,
142
+ img_size=DEFAULT_IMG_SIZE, # Default image size
143
+ patch_size=DEFAULT_PATCH_SIZE, # Default patch size
144
+ show_grid=True,
145
+ grid_color="rgba(200, 200, 200, 0.5)"
146
+ )
147
+
148
+ with gr.Column(scale=1):
149
+ output = gr.Textbox(label="Selected Patch", value="No patch selected")
150
+ gr.Markdown("### How it works")
151
+ gr.Markdown("1. Adjust the image size and patch size using the number inputs")
152
+ gr.Markdown("2. The grid will update automatically based on your inputs")
153
+ gr.Markdown("3. Click on any patch to select it and get its index")
154
+
155
+ # Handle the parameter change events
156
+ img_size_input.change(
157
+ update_params,
158
+ inputs=[img_size_input, patch_size_input, annotator],
159
+ outputs=[annotator, param_info, grid_info]
160
+ )
161
+
162
+ patch_size_input.change(
163
+ update_params,
164
+ inputs=[img_size_input, patch_size_input, annotator],
165
+ outputs=[annotator, param_info, grid_info]
166
+ )
167
+
168
+ # Handle the patch selection event
169
+ annotator.patch_select(get_patch_index, annotator, output)
170
+
171
+ gr.Examples(examples, annotator)
172
+
173
+ if __name__ == "__main__":
174
+ demo.launch()
175
+
176
+ ```
177
+ """, elem_classes=["md-custom"], header_links=True)
178
+
179
+
180
+ gr.Markdown("""
181
+ ## `PatchSelector`
182
+
183
+ ### Initialization
184
+ """, elem_classes=["md-custom"], header_links=True)
185
+
186
+ gr.ParamViewer(value=_docs["PatchSelector"]["members"]["__init__"], linkify=[])
187
+
188
+
189
+ gr.Markdown("### Events")
190
+ gr.ParamViewer(value=_docs["PatchSelector"]["events"], linkify=['Event'])
191
+
192
+
193
+
194
+
195
+ gr.Markdown("""
196
+
197
+ ### User function
198
+
199
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
200
+
201
+ - When used as an Input, the component only impacts the input signature of the user function.
202
+ - When used as an output, the component only impacts the return signature of the user function.
203
+
204
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
205
+
206
+ - **As input:** Is passed, a dict with the image, patchIndex, imgSize, and patchSize or None.
207
+ - **As output:** Should return, a dict with an image and an optional patchIndex or None.
208
+
209
+ ```python
210
+ def predict(
211
+ value: dict | None
212
+ ) -> dict | None:
213
+ return value
214
+ ```
215
+ """, elem_classes=["md-custom", "PatchSelector-user-fn"], header_links=True)
216
+
217
+
218
+
219
+
220
+ demo.load(None, js=r"""function() {
221
+ const refs = {};
222
+ const user_fn_refs = {
223
+ PatchSelector: [], };
224
+ requestAnimationFrame(() => {
225
+
226
+ Object.entries(user_fn_refs).forEach(([key, refs]) => {
227
+ if (refs.length > 0) {
228
+ const el = document.querySelector(`.${key}-user-fn`);
229
+ if (!el) return;
230
+ refs.forEach(ref => {
231
+ el.innerHTML = el.innerHTML.replace(
232
+ new RegExp("\\b"+ref+"\\b", "g"),
233
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
234
+ );
235
+ })
236
+ }
237
+ })
238
+
239
+ Object.entries(refs).forEach(([key, refs]) => {
240
+ if (refs.length > 0) {
241
+ const el = document.querySelector(`.${key}`);
242
+ if (!el) return;
243
+ refs.forEach(ref => {
244
+ el.innerHTML = el.innerHTML.replace(
245
+ new RegExp("\\b"+ref+"\\b", "g"),
246
+ `<a href="#h-${ref.toLowerCase()}">${ref}</a>`
247
+ );
248
+ })
249
+ }
250
+ })
251
+ })
252
+ }
253
+
254
+ """)
255
+
256
+ demo.launch()
src/.github/copilot-instructions.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Project
2
+
3
+ ## Description
4
+
5
+ PatchSelector is an input gradio component that allows the user to select a patch from an image. It takes an image, a patch size and an image size as input and overlays a grid based on those parameters for the user to click on.
6
+
7
+ For example, if the image size is 224x224 and the patch size is 16, a grid of 14x14 will be overlayed on the image. The user can then select a patch by clicking on it, and the component will return the patch index.
8
+
9
+ This is meant to be used as an input gradio component for visualization of attention maps in ViT models. The component will return the patch index, which can then be used to visualize the attention map for that patch.
10
+
11
+
12
+ ## Project Structure
13
+
14
+ - frontend: Svelte frontend components, uses TypeScript.
15
+ - backend: contains the backend logic for the component. It uses Gradio to create the input component and handle the image processing.
16
+ - demo: `demo/app.py` contains the Gradio demo for the component.
17
+ - Generated code (don't edit these files)
18
+ - `backend/{package}/templates/**`
19
+ - `dist/**`
20
+
21
+ The full stack for this project is:
22
+ - Svelte/TypeScript/JavaScript: for frontend development
23
+ - Python: for backend development
24
+ - uv: for python package management
25
+ - To run python commands in the environment you can do `uv run {cmd}`. For example, `uv run gradio cc build` will build the gradio component.
26
+
27
+ ## Coding Instructions
28
+
29
+ - If you want to debug the backend or frontend, just insert print statements wherever you want and ask me to run the code. Tell me if you want the browser console or the python console or both. I'll copy its outputs to you.
30
+ - Don't add comments on the svelte files, they mess up the compilation.
src/.github/workflows/python-publish.yml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This workflow will upload a Python Package using Twine when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ release:
13
+ types: [published]
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ deploy:
20
+
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v3
27
+ with:
28
+ python-version: '3.x'
29
+ - name: Install dependencies
30
+ run: |
31
+ python -m pip install --upgrade pip
32
+ pip install build
33
+ - name: Build package
34
+ run: python -m build
35
+ - name: Publish package
36
+ uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37
+ with:
38
+ user: __token__
39
+ password: ${{ secrets.PYPI_API_TOKEN }}
src/.gitignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ .eggs/
2
+ dist/
3
+ *.pyc
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+ __tmp/*
8
+ *.pyi
9
+ node_modules
src/.venv/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ *
src/.venv/CACHEDIR.TAG ADDED
@@ -0,0 +1 @@
 
 
1
+ Signature: 8a477f597d28d172789f06886806bc55
src/.venv/bin/activate ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # This file must be used with "source bin/activate" *from bash*
23
+ # you cannot run it directly
24
+
25
+ if ! [ -z "${SCRIPT_PATH+_}" ] ; then
26
+ _OLD_SCRIPT_PATH="$SCRIPT_PATH"
27
+ fi
28
+
29
+ # Get script path (only used if environment is relocatable).
30
+ if [ -n "${BASH_VERSION:+x}" ] ; then
31
+ SCRIPT_PATH="${BASH_SOURCE[0]}"
32
+ if [ "$SCRIPT_PATH" = "$0" ]; then
33
+ # Only bash has a reasonably robust check for source'dness.
34
+ echo "You must source this script: \$ source $0" >&2
35
+ exit 33
36
+ fi
37
+ elif [ -n "${ZSH_VERSION:+x}" ] ; then
38
+ SCRIPT_PATH="${(%):-%x}"
39
+ elif [ -n "${KSH_VERSION:+x}" ] ; then
40
+ SCRIPT_PATH="${.sh.file}"
41
+ fi
42
+
43
+ deactivate () {
44
+ unset -f pydoc >/dev/null 2>&1 || true
45
+
46
+ # reset old environment variables
47
+ # ! [ -z ${VAR+_} ] returns true if VAR is declared at all
48
+ if ! [ -z "${_OLD_VIRTUAL_PATH:+_}" ] ; then
49
+ PATH="$_OLD_VIRTUAL_PATH"
50
+ export PATH
51
+ unset _OLD_VIRTUAL_PATH
52
+ fi
53
+ if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
54
+ PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
55
+ export PYTHONHOME
56
+ unset _OLD_VIRTUAL_PYTHONHOME
57
+ fi
58
+
59
+ # The hash command must be called to get it to forget past
60
+ # commands. Without forgetting past commands the $PATH changes
61
+ # we made may not be respected
62
+ hash -r 2>/dev/null
63
+
64
+ if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
65
+ PS1="$_OLD_VIRTUAL_PS1"
66
+ export PS1
67
+ unset _OLD_VIRTUAL_PS1
68
+ fi
69
+
70
+ unset VIRTUAL_ENV
71
+ unset VIRTUAL_ENV_PROMPT
72
+ if [ ! "${1-}" = "nondestructive" ] ; then
73
+ # Self destruct!
74
+ unset -f deactivate
75
+ fi
76
+ }
77
+
78
+ # unset irrelevant variables
79
+ deactivate nondestructive
80
+
81
+ VIRTUAL_ENV='/Users/dgcnz/development/playground/gradio_image_annotator/.venv'
82
+ if ([ "$OSTYPE" = "cygwin" ] || [ "$OSTYPE" = "msys" ]) && $(command -v cygpath &> /dev/null) ; then
83
+ VIRTUAL_ENV=$(cygpath -u "$VIRTUAL_ENV")
84
+ fi
85
+ export VIRTUAL_ENV
86
+
87
+ # Unset the `SCRIPT_PATH` variable, now that the `VIRTUAL_ENV` variable
88
+ # has been set. This is important for relocatable environments.
89
+ if ! [ -z "${_OLD_SCRIPT_PATH+_}" ] ; then
90
+ SCRIPT_PATH="$_OLD_SCRIPT_PATH"
91
+ export SCRIPT_PATH
92
+ unset _OLD_SCRIPT_PATH
93
+ else
94
+ unset SCRIPT_PATH
95
+ fi
96
+
97
+ _OLD_VIRTUAL_PATH="$PATH"
98
+ PATH="$VIRTUAL_ENV/bin:$PATH"
99
+ export PATH
100
+
101
+ if [ "xgradio-patch-selection" != x ] ; then
102
+ VIRTUAL_ENV_PROMPT="(gradio-patch-selection) "
103
+ else
104
+ VIRTUAL_ENV_PROMPT="($(basename "$VIRTUAL_ENV")) "
105
+ fi
106
+ export VIRTUAL_ENV_PROMPT
107
+
108
+ # unset PYTHONHOME if set
109
+ if ! [ -z "${PYTHONHOME+_}" ] ; then
110
+ _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
111
+ unset PYTHONHOME
112
+ fi
113
+
114
+ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
115
+ _OLD_VIRTUAL_PS1="${PS1-}"
116
+ PS1="${VIRTUAL_ENV_PROMPT}${PS1-}"
117
+ export PS1
118
+ fi
119
+
120
+ # Make sure to unalias pydoc if it's already there
121
+ alias pydoc 2>/dev/null >/dev/null && unalias pydoc || true
122
+
123
+ pydoc () {
124
+ python -m pydoc "$@"
125
+ }
126
+
127
+ # The hash command must be called to get it to forget past
128
+ # commands. Without forgetting past commands the $PATH changes
129
+ # we made may not be respected
130
+ hash -r 2>/dev/null
src/.venv/bin/activate.bat ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @REM Copyright (c) 2020-202x The virtualenv developers
2
+ @REM
3
+ @REM Permission is hereby granted, free of charge, to any person obtaining
4
+ @REM a copy of this software and associated documentation files (the
5
+ @REM "Software"), to deal in the Software without restriction, including
6
+ @REM without limitation the rights to use, copy, modify, merge, publish,
7
+ @REM distribute, sublicense, and/or sell copies of the Software, and to
8
+ @REM permit persons to whom the Software is furnished to do so, subject to
9
+ @REM the following conditions:
10
+ @REM
11
+ @REM The above copyright notice and this permission notice shall be
12
+ @REM included in all copies or substantial portions of the Software.
13
+ @REM
14
+ @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ @REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ @REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ @REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ @REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ @REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ @REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ @REM This file is UTF-8 encoded, so we need to update the current code page while executing it
23
+ @for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do @set _OLD_CODEPAGE=%%a
24
+ @if defined _OLD_CODEPAGE (
25
+ @"%SystemRoot%\System32\chcp.com" 65001 > nul
26
+ )
27
+
28
+ @for %%i in ("/Users/dgcnz/development/playground/gradio_image_annotator/.venv") do @set "VIRTUAL_ENV=%%~fi"
29
+
30
+ @set "VIRTUAL_ENV_PROMPT=gradio-patch-selection"
31
+ @if NOT DEFINED VIRTUAL_ENV_PROMPT (
32
+ @for %%d in ("%VIRTUAL_ENV%") do @set "VIRTUAL_ENV_PROMPT=%%~nxd"
33
+ )
34
+
35
+ @if defined _OLD_VIRTUAL_PROMPT (
36
+ @set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
37
+ ) else (
38
+ @if not defined PROMPT (
39
+ @set "PROMPT=$P$G"
40
+ )
41
+ @if not defined VIRTUAL_ENV_DISABLE_PROMPT (
42
+ @set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
43
+ )
44
+ )
45
+ @if not defined VIRTUAL_ENV_DISABLE_PROMPT (
46
+ @set "PROMPT=(%VIRTUAL_ENV_PROMPT%) %PROMPT%"
47
+ )
48
+
49
+ @REM Don't use () to avoid problems with them in %PATH%
50
+ @if defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
51
+ @set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
52
+ :ENDIFVHOME
53
+
54
+ @set PYTHONHOME=
55
+
56
+ @REM if defined _OLD_VIRTUAL_PATH (
57
+ @if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH1
58
+ @set "PATH=%_OLD_VIRTUAL_PATH%"
59
+ :ENDIFVPATH1
60
+ @REM ) else (
61
+ @if defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH2
62
+ @set "_OLD_VIRTUAL_PATH=%PATH%"
63
+ :ENDIFVPATH2
64
+
65
+ @set "PATH=%VIRTUAL_ENV%\bin;%PATH%"
66
+
67
+ :END
68
+ @if defined _OLD_CODEPAGE (
69
+ @"%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
70
+ @set _OLD_CODEPAGE=
71
+ )
src/.venv/bin/activate.csh ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # This file must be used with "source bin/activate.csh" *from csh*.
23
+ # You cannot run it directly.
24
+ # Created by Davide Di Blasi <davidedb@gmail.com>.
25
+
26
+ set newline='\
27
+ '
28
+
29
+ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH:q" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT:q" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
30
+
31
+ # Unset irrelevant variables.
32
+ deactivate nondestructive
33
+
34
+ setenv VIRTUAL_ENV '/Users/dgcnz/development/playground/gradio_image_annotator/.venv'
35
+
36
+ set _OLD_VIRTUAL_PATH="$PATH:q"
37
+ setenv PATH "$VIRTUAL_ENV:q/bin:$PATH:q"
38
+
39
+
40
+
41
+ if ('gradio-patch-selection' != "") then
42
+ setenv VIRTUAL_ENV_PROMPT 'gradio-patch-selection'
43
+ else
44
+ setenv VIRTUAL_ENV_PROMPT "$VIRTUAL_ENV:t:q"
45
+ endif
46
+
47
+ if ( $?VIRTUAL_ENV_DISABLE_PROMPT ) then
48
+ if ( $VIRTUAL_ENV_DISABLE_PROMPT == "" ) then
49
+ set do_prompt = "1"
50
+ else
51
+ set do_prompt = "0"
52
+ endif
53
+ else
54
+ set do_prompt = "1"
55
+ endif
56
+
57
+ if ( $do_prompt == "1" ) then
58
+ # Could be in a non-interactive environment,
59
+ # in which case, $prompt is undefined and we wouldn't
60
+ # care about the prompt anyway.
61
+ if ( $?prompt ) then
62
+ set _OLD_VIRTUAL_PROMPT="$prompt:q"
63
+ if ( "$prompt:q" =~ *"$newline:q"* ) then
64
+ :
65
+ else
66
+ set prompt = '('"$VIRTUAL_ENV_PROMPT:q"') '"$prompt:q"
67
+ endif
68
+ endif
69
+ endif
70
+
71
+ unset env_name
72
+ unset do_prompt
73
+
74
+ alias pydoc python -m pydoc
75
+
76
+ rehash
src/.venv/bin/activate.fish ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
23
+ # Do not run it directly.
24
+
25
+ function _bashify_path -d "Converts a fish path to something bash can recognize"
26
+ set fishy_path $argv
27
+ set bashy_path $fishy_path[1]
28
+ for path_part in $fishy_path[2..-1]
29
+ set bashy_path "$bashy_path:$path_part"
30
+ end
31
+ echo $bashy_path
32
+ end
33
+
34
+ function _fishify_path -d "Converts a bash path to something fish can recognize"
35
+ echo $argv | tr ':' '\n'
36
+ end
37
+
38
+ function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
39
+ # reset old environment variables
40
+ if test -n "$_OLD_VIRTUAL_PATH"
41
+ # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
42
+ if test (echo $FISH_VERSION | head -c 1) -lt 3
43
+ set -gx PATH (_fishify_path "$_OLD_VIRTUAL_PATH")
44
+ else
45
+ set -gx PATH $_OLD_VIRTUAL_PATH
46
+ end
47
+ set -e _OLD_VIRTUAL_PATH
48
+ end
49
+
50
+ if test -n "$_OLD_VIRTUAL_PYTHONHOME"
51
+ set -gx PYTHONHOME "$_OLD_VIRTUAL_PYTHONHOME"
52
+ set -e _OLD_VIRTUAL_PYTHONHOME
53
+ end
54
+
55
+ if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
56
+ and functions -q _old_fish_prompt
57
+ # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
58
+ set -l fish_function_path
59
+
60
+ # Erase virtualenv's `fish_prompt` and restore the original.
61
+ functions -e fish_prompt
62
+ functions -c _old_fish_prompt fish_prompt
63
+ functions -e _old_fish_prompt
64
+ set -e _OLD_FISH_PROMPT_OVERRIDE
65
+ end
66
+
67
+ set -e VIRTUAL_ENV
68
+ set -e VIRTUAL_ENV_PROMPT
69
+
70
+ if test "$argv[1]" != 'nondestructive'
71
+ # Self-destruct!
72
+ functions -e pydoc
73
+ functions -e deactivate
74
+ functions -e _bashify_path
75
+ functions -e _fishify_path
76
+ end
77
+ end
78
+
79
+ # Unset irrelevant variables.
80
+ deactivate nondestructive
81
+
82
+ set -gx VIRTUAL_ENV '/Users/dgcnz/development/playground/gradio_image_annotator/.venv'
83
+
84
+ # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
85
+ if test (echo $FISH_VERSION | head -c 1) -lt 3
86
+ set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH)
87
+ else
88
+ set -gx _OLD_VIRTUAL_PATH $PATH
89
+ end
90
+ set -gx PATH "$VIRTUAL_ENV"'/bin' $PATH
91
+
92
+ # Prompt override provided?
93
+ # If not, just use the environment name.
94
+ if test -n 'gradio-patch-selection'
95
+ set -gx VIRTUAL_ENV_PROMPT 'gradio-patch-selection'
96
+ else
97
+ set -gx VIRTUAL_ENV_PROMPT (basename "$VIRTUAL_ENV")
98
+ end
99
+
100
+ # Unset `$PYTHONHOME` if set.
101
+ if set -q PYTHONHOME
102
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
103
+ set -e PYTHONHOME
104
+ end
105
+
106
+ function pydoc
107
+ python -m pydoc $argv
108
+ end
109
+
110
+ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
111
+ # Copy the current `fish_prompt` function as `_old_fish_prompt`.
112
+ functions -c fish_prompt _old_fish_prompt
113
+
114
+ function fish_prompt
115
+ # Run the user's prompt first; it might depend on (pipe)status.
116
+ set -l prompt (_old_fish_prompt)
117
+
118
+ printf '(%s) ' $VIRTUAL_ENV_PROMPT
119
+
120
+ string join -- \n $prompt # handle multi-line prompts
121
+ end
122
+
123
+ set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
124
+ end
src/.venv/bin/activate.nu ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # virtualenv activation module
23
+ # Activate with `overlay use activate.nu`
24
+ # Deactivate with `deactivate`, as usual
25
+ #
26
+ # To customize the overlay name, you can call `overlay use activate.nu as foo`,
27
+ # but then simply `deactivate` won't work because it is just an alias to hide
28
+ # the "activate" overlay. You'd need to call `overlay hide foo` manually.
29
+
30
+ export-env {
31
+ def is-string [x] {
32
+ ($x | describe) == 'string'
33
+ }
34
+
35
+ def has-env [...names] {
36
+ $names | each {|n|
37
+ $n in $env
38
+ } | all {|i| $i == true}
39
+ }
40
+
41
+ # Emulates a `test -z`, but better as it handles e.g 'false'
42
+ def is-env-true [name: string] {
43
+ if (has-env $name) {
44
+ # Try to parse 'true', '0', '1', and fail if not convertible
45
+ let parsed = (do -i { $env | get $name | into bool })
46
+ if ($parsed | describe) == 'bool' {
47
+ $parsed
48
+ } else {
49
+ not ($env | get -i $name | is-empty)
50
+ }
51
+ } else {
52
+ false
53
+ }
54
+ }
55
+
56
+ let virtual_env = '/Users/dgcnz/development/playground/gradio_image_annotator/.venv'
57
+ let bin = 'bin'
58
+
59
+ let is_windows = ($nu.os-info.family) == 'windows'
60
+ let path_name = (if (has-env 'Path') {
61
+ 'Path'
62
+ } else {
63
+ 'PATH'
64
+ }
65
+ )
66
+
67
+ let venv_path = ([$virtual_env $bin] | path join)
68
+ let new_path = ($env | get $path_name | prepend $venv_path)
69
+
70
+ # If there is no default prompt, then use the env name instead
71
+ let virtual_env_prompt = (if ('gradio-patch-selection' | is-empty) {
72
+ ($virtual_env | path basename)
73
+ } else {
74
+ 'gradio-patch-selection'
75
+ })
76
+
77
+ let new_env = {
78
+ $path_name : $new_path
79
+ VIRTUAL_ENV : $virtual_env
80
+ VIRTUAL_ENV_PROMPT : $virtual_env_prompt
81
+ }
82
+
83
+ let new_env = (if (is-env-true 'VIRTUAL_ENV_DISABLE_PROMPT') {
84
+ $new_env
85
+ } else {
86
+ # Creating the new prompt for the session
87
+ let virtual_prefix = $'(char lparen)($virtual_env_prompt)(char rparen) '
88
+
89
+ # Back up the old prompt builder
90
+ let old_prompt_command = (if (has-env 'PROMPT_COMMAND') {
91
+ $env.PROMPT_COMMAND
92
+ } else {
93
+ ''
94
+ })
95
+
96
+ let new_prompt = (if (has-env 'PROMPT_COMMAND') {
97
+ if 'closure' in ($old_prompt_command | describe) {
98
+ {|| $'($virtual_prefix)(do $old_prompt_command)' }
99
+ } else {
100
+ {|| $'($virtual_prefix)($old_prompt_command)' }
101
+ }
102
+ } else {
103
+ {|| $'($virtual_prefix)' }
104
+ })
105
+
106
+ $new_env | merge {
107
+ PROMPT_COMMAND : $new_prompt
108
+ VIRTUAL_PREFIX : $virtual_prefix
109
+ }
110
+ })
111
+
112
+ # Environment variables that will be loaded as the virtual env
113
+ load-env $new_env
114
+ }
115
+
116
+ export alias pydoc = python -m pydoc
117
+ export alias deactivate = overlay hide activate
src/.venv/bin/activate.ps1 ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ $script:THIS_PATH = $myinvocation.mycommand.path
23
+ $script:BASE_DIR = Split-Path (Resolve-Path "$THIS_PATH/..") -Parent
24
+
25
+ function global:deactivate([switch] $NonDestructive) {
26
+ if (Test-Path variable:_OLD_VIRTUAL_PATH) {
27
+ $env:PATH = $variable:_OLD_VIRTUAL_PATH
28
+ Remove-Variable "_OLD_VIRTUAL_PATH" -Scope global
29
+ }
30
+
31
+ if (Test-Path function:_old_virtual_prompt) {
32
+ $function:prompt = $function:_old_virtual_prompt
33
+ Remove-Item function:\_old_virtual_prompt
34
+ }
35
+
36
+ if ($env:VIRTUAL_ENV) {
37
+ Remove-Item env:VIRTUAL_ENV -ErrorAction SilentlyContinue
38
+ }
39
+
40
+ if ($env:VIRTUAL_ENV_PROMPT) {
41
+ Remove-Item env:VIRTUAL_ENV_PROMPT -ErrorAction SilentlyContinue
42
+ }
43
+
44
+ if (!$NonDestructive) {
45
+ # Self destruct!
46
+ Remove-Item function:deactivate
47
+ Remove-Item function:pydoc
48
+ }
49
+ }
50
+
51
+ function global:pydoc {
52
+ python -m pydoc $args
53
+ }
54
+
55
+ # unset irrelevant variables
56
+ deactivate -nondestructive
57
+
58
+ $VIRTUAL_ENV = $BASE_DIR
59
+ $env:VIRTUAL_ENV = $VIRTUAL_ENV
60
+
61
+ if ("gradio-patch-selection" -ne "") {
62
+ $env:VIRTUAL_ENV_PROMPT = "gradio-patch-selection"
63
+ }
64
+ else {
65
+ $env:VIRTUAL_ENV_PROMPT = $( Split-Path $env:VIRTUAL_ENV -Leaf )
66
+ }
67
+
68
+ New-Variable -Scope global -Name _OLD_VIRTUAL_PATH -Value $env:PATH
69
+
70
+ $env:PATH = "$env:VIRTUAL_ENV/bin:" + $env:PATH
71
+ if (!$env:VIRTUAL_ENV_DISABLE_PROMPT) {
72
+ function global:_old_virtual_prompt {
73
+ ""
74
+ }
75
+ $function:_old_virtual_prompt = $function:prompt
76
+
77
+ function global:prompt {
78
+ # Add the custom prefix to the existing prompt
79
+ $previous_prompt_value = & $function:_old_virtual_prompt
80
+ ("(" + $env:VIRTUAL_ENV_PROMPT + ") " + $previous_prompt_value)
81
+ }
82
+ }
src/.venv/bin/activate_this.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2020-202x The virtualenv developers
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ """
23
+ Activate virtualenv for current interpreter:
24
+
25
+ import runpy
26
+ runpy.run_path(this_file)
27
+
28
+ This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
29
+ """ # noqa: D415
30
+
31
+ from __future__ import annotations
32
+
33
+ import os
34
+ import site
35
+ import sys
36
+
37
+ try:
38
+ abs_file = os.path.abspath(__file__)
39
+ except NameError as exc:
40
+ msg = "You must use import runpy; runpy.run_path(this_file)"
41
+ raise AssertionError(msg) from exc
42
+
43
+ bin_dir = os.path.dirname(abs_file)
44
+ base = bin_dir[: -len("bin") - 1] # strip away the bin part from the __file__, plus the path separator
45
+
46
+ # prepend bin to PATH (this file is inside the bin directory)
47
+ os.environ["PATH"] = os.pathsep.join([bin_dir, *os.environ.get("PATH", "").split(os.pathsep)])
48
+ os.environ["VIRTUAL_ENV"] = base # virtual env is right above bin directory
49
+ os.environ["VIRTUAL_ENV_PROMPT"] = "gradio-patch-selection" or os.path.basename(base) # noqa: SIM222
50
+
51
+ # add the virtual environments libraries to the host python import mechanism
52
+ prev_length = len(sys.path)
53
+ for lib in "../lib/python3.11/site-packages".split(os.pathsep):
54
+ path = os.path.realpath(os.path.join(bin_dir, lib))
55
+ site.addsitedir(path)
56
+ sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]
57
+
58
+ sys.real_prefix = sys.prefix
59
+ sys.prefix = base
src/.venv/bin/deactivate.bat ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @REM Copyright (c) 2020-202x The virtualenv developers
2
+ @REM
3
+ @REM Permission is hereby granted, free of charge, to any person obtaining
4
+ @REM a copy of this software and associated documentation files (the
5
+ @REM "Software"), to deal in the Software without restriction, including
6
+ @REM without limitation the rights to use, copy, modify, merge, publish,
7
+ @REM distribute, sublicense, and/or sell copies of the Software, and to
8
+ @REM permit persons to whom the Software is furnished to do so, subject to
9
+ @REM the following conditions:
10
+ @REM
11
+ @REM The above copyright notice and this permission notice shall be
12
+ @REM included in all copies or substantial portions of the Software.
13
+ @REM
14
+ @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ @REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ @REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ @REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ @REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ @REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ @REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ @set VIRTUAL_ENV=
23
+ @set VIRTUAL_ENV_PROMPT=
24
+
25
+ @REM Don't use () to avoid problems with them in %PATH%
26
+ @if not defined _OLD_VIRTUAL_PROMPT @goto ENDIFVPROMPT
27
+ @set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
28
+ @set _OLD_VIRTUAL_PROMPT=
29
+ :ENDIFVPROMPT
30
+
31
+ @if not defined _OLD_VIRTUAL_PYTHONHOME @goto ENDIFVHOME
32
+ @set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
33
+ @set _OLD_VIRTUAL_PYTHONHOME=
34
+ :ENDIFVHOME
35
+
36
+ @if not defined _OLD_VIRTUAL_PATH @goto ENDIFVPATH
37
+ @set "PATH=%_OLD_VIRTUAL_PATH%"
38
+ @set _OLD_VIRTUAL_PATH=
39
+ :ENDIFVPATH
src/.venv/bin/docutils ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.__main__ import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
src/.venv/bin/f2py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from numpy.f2py.f2py2e import main
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(main())
src/.venv/bin/fastapi ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from fastapi.cli import main
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(main())
src/.venv/bin/gradio ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from gradio.cli import cli
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(cli())
src/.venv/bin/httpx ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from httpx import main
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(main())
src/.venv/bin/huggingface-cli ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from huggingface_hub.commands.huggingface_cli import main
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(main())
src/.venv/bin/keyring ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from keyring.cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
src/.venv/bin/markdown-it ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from markdown_it.cli.parse import main
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(main())
src/.venv/bin/normalizer ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from charset_normalizer import cli
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(cli.cli_detect())
src/.venv/bin/numpy-config ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from numpy._configtool import main
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(main())
src/.venv/bin/pip ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from pip._internal.cli.main import main
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(main())
src/.venv/bin/pip3 ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from pip._internal.cli.main import main
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(main())
src/.venv/bin/pip3.11 ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from pip._internal.cli.main import main
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(main())
src/.venv/bin/pydoc.bat ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @REM Copyright (c) 2020-202x The virtualenv developers
2
+ @REM
3
+ @REM Permission is hereby granted, free of charge, to any person obtaining
4
+ @REM a copy of this software and associated documentation files (the
5
+ @REM "Software"), to deal in the Software without restriction, including
6
+ @REM without limitation the rights to use, copy, modify, merge, publish,
7
+ @REM distribute, sublicense, and/or sell copies of the Software, and to
8
+ @REM permit persons to whom the Software is furnished to do so, subject to
9
+ @REM the following conditions:
10
+ @REM
11
+ @REM The above copyright notice and this permission notice shall be
12
+ @REM included in all copies or substantial portions of the Software.
13
+ @REM
14
+ @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ @REM EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ @REM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ @REM NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ @REM LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ @REM OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ @REM WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ python.exe -m pydoc %*
src/.venv/bin/pygmentize ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from pygments.cmdline import main
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(main())
src/.venv/bin/pyproject-build ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import sys
4
+ from build.__main__ import entrypoint
5
+ if __name__ == "__main__":
6
+ if sys.argv[0].endswith("-script.pyw"):
7
+ sys.argv[0] = sys.argv[0][:-11]
8
+ elif sys.argv[0].endswith(".exe"):
9
+ sys.argv[0] = sys.argv[0][:-4]
10
+ sys.exit(entrypoint())
src/.venv/bin/python ADDED
Binary file (33.8 kB). View file
 
src/.venv/bin/python3 ADDED
Binary file (33.8 kB). View file
 
src/.venv/bin/python3.11 ADDED
Binary file (33.8 kB). View file
 
src/.venv/bin/rst2html ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.core import rst2html
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(rst2html())
src/.venv/bin/rst2html4 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.core import rst2html4
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(rst2html4())
src/.venv/bin/rst2html5 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.core import rst2html5
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(rst2html5())
src/.venv/bin/rst2latex ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.core import rst2latex
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(rst2latex())
src/.venv/bin/rst2man ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.core import rst2man
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(rst2man())
src/.venv/bin/rst2odt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.core import rst2odt
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(rst2odt())
src/.venv/bin/rst2pseudoxml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.core import rst2pseudoxml
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(rst2pseudoxml())
src/.venv/bin/rst2s5 ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.core import rst2s5
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(rst2s5())
src/.venv/bin/rst2xetex ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.core import rst2xetex
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(rst2xetex())
src/.venv/bin/rst2xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/Users/dgcnz/development/playground/gradio_image_annotator/.venv/bin/python
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from docutils.core import rst2xml
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(rst2xml())
src/.venv/bin/ruff ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fbf91b0c67faa0e60658f6e65469d113dcc098b6b09be2a8e7a4dd210e0c66a2
3
+ size 26909264