rotsl commited on
Commit
6ff4abc
·
verified ·
1 Parent(s): 0e85f71

Update model files

Browse files
Files changed (7) hide show
  1. CITATION.cff +8 -0
  2. LICENSE +211 -0
  3. README.md +80 -5
  4. best_area_w_0.1.pt +3 -0
  5. best_area_w_0.3.pt +3 -0
  6. best_area_w_0.5.pt +3 -0
  7. best_area_w_0.7.pt +3 -0
CITATION.cff ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ cff-version: 1.2.0
2
+ message: "If you use this model or code, please cite as below."
3
+ title: "Gray Leaf Spot Segmentation Model"
4
+ authors:
5
+ - family-names: "Rohan"
6
+ given-names: "R."
7
+ orcid: "https://orcid.org/0009-0005-9225-1775"
8
+ year: 2026
LICENSE ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License.
67
+
68
+ Subject to the terms and conditions of this License, each Contributor
69
+ hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
70
+ royalty-free, irrevocable copyright license to reproduce, prepare
71
+ Derivative Works of, publicly display, publicly perform, sublicense,
72
+ and distribute the Work and such Derivative Works in Source or Object
73
+ form.
74
+
75
+ 3. Grant of Patent License.
76
+
77
+ Subject to the terms and conditions of this License, each Contributor
78
+ hereby grants to You a perpetual, worldwide, non-exclusive, no-charge,
79
+ royalty-free, irrevocable (except as stated in this section) patent
80
+ license to make, have made, use, offer to sell, sell, import, and
81
+ otherwise transfer the Work, where such license applies only to those
82
+ patent claims licensable by such Contributor that are necessarily
83
+ infringed by their Contribution(s) alone or by combination of their
84
+ Contribution(s) with the Work to which such Contribution(s) was
85
+ submitted. If You institute patent litigation against any entity
86
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
87
+ the Work or a Contribution incorporated within the Work constitutes
88
+ direct or contributory patent infringement, then any patent licenses
89
+ granted to You under this License for that Work shall terminate as of
90
+ the date such litigation is filed.
91
+
92
+ 4. Redistribution.
93
+
94
+ You may reproduce and distribute copies of the Work or Derivative
95
+ Works thereof in any medium, with or without modifications, and in
96
+ Source or Object form, provided that You meet the following conditions:
97
+
98
+ (a) You must give any other recipients of the Work or
99
+ Derivative Works a copy of this License; and
100
+
101
+ (b) You must cause any modified files to carry prominent notices
102
+ stating that You changed the files; and
103
+
104
+ (c) You must retain, in the Source form of any Derivative Works
105
+ that You distribute, all copyright, patent, trademark, and
106
+ attribution notices from the Source form of the Work,
107
+ excluding those notices that do not pertain to any part of
108
+ the Derivative Works; and
109
+
110
+ (d) If the Work includes a "NOTICE" text file as part of its
111
+ distribution, then any Derivative Works that You distribute must
112
+ include a readable copy of the attribution notices contained
113
+ within such NOTICE file, excluding those notices that do not
114
+ pertain to any part of the Derivative Works, in at least one
115
+ of the following places: within a NOTICE text file distributed
116
+ as part of the Derivative Works; within the Source form or
117
+ documentation, if provided along with the Derivative Works; or,
118
+ within a display generated by the Derivative Works, if and
119
+ wherever such third-party notices normally appear. The contents
120
+ of the NOTICE file are for informational purposes only and
121
+ do not modify the License. You may add Your own attribution
122
+ notices within Derivative Works that You distribute, alongside
123
+ or as an addendum to the NOTICE text from the Work, provided
124
+ that such additional attribution notices cannot be construed
125
+ as modifying the License.
126
+
127
+ You may add Your own copyright statement to Your modifications and
128
+ may provide additional or different license terms and conditions
129
+ for use, reproduction, or distribution of Your modifications, or
130
+ for any such Derivative Works as a whole, provided Your use,
131
+ reproduction, and distribution of the Work otherwise complies with
132
+ the conditions stated in this License.
133
+
134
+ 5. Submission of Contributions.
135
+
136
+ Unless You explicitly state otherwise, any Contribution intentionally
137
+ submitted for inclusion in the Work by You to the Licensor shall be
138
+ under the terms and conditions of this License, without any additional
139
+ terms or conditions. Notwithstanding the above, nothing herein shall
140
+ supersede or modify the terms of any separate license agreement you
141
+ may have executed with Licensor regarding such Contributions.
142
+
143
+ 6. Trademarks.
144
+
145
+ This License does not grant permission to use the trade names,
146
+ trademarks, service marks, or product names of the Licensor, except as
147
+ required for reasonable and customary use in describing the origin of
148
+ the Work and reproducing the content of the NOTICE file.
149
+
150
+ 7. Disclaimer of Warranty.
151
+
152
+ Unless required by applicable law or agreed to in writing, Licensor
153
+ provides the Work (and each Contributor provides its Contributions) on
154
+ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
155
+ express or implied, including, without limitation, any warranties or
156
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR
157
+ A PARTICULAR PURPOSE. You are solely responsible for determining the
158
+ appropriateness of using or redistributing the Work and assume any
159
+ risks associated with Your exercise of permissions under this License.
160
+
161
+ 8. Limitation of Liability.
162
+
163
+ In no event and under no legal theory, whether in tort (including
164
+ negligence), contract, or otherwise, unless required by applicable law
165
+ (such as deliberate and grossly negligent acts) or agreed to in
166
+ writing, shall any Contributor be liable to You for damages, including
167
+ any direct, indirect, special, incidental, or consequential damages of
168
+ any character arising as a result of this License or out of the use or
169
+ inability to use the Work (including but not limited to damages for
170
+ loss of goodwill, work stoppage, computer failure or malfunction, or
171
+ any and all other commercial damages or losses), even if such
172
+ Contributor has been advised of the possibility of such damages.
173
+
174
+ 9. Accepting Warranty or Additional Liability.
175
+
176
+ While redistributing the Work or Derivative Works thereof, You may choose
177
+ to offer, and charge a fee for, acceptance of support, warranty,
178
+ indemnity, or other liability obligations and/or rights consistent with
179
+ this License. However, in accepting such obligations, You may act only
180
+ on Your own behalf and on Your sole responsibility, not on behalf of
181
+ any other Contributor, and only if You agree to indemnify, defend, and
182
+ hold each Contributor harmless for any liability incurred by, or claims
183
+ asserted against, such Contributor by reason of your accepting any such
184
+ warranty or additional liability.
185
+
186
+ END OF TERMS AND CONDITIONS
187
+
188
+ APPENDIX: How to apply the Apache License to your work.
189
+
190
+ To apply the Apache License to your work, attach the following
191
+ boilerplate notice, with the fields enclosed by brackets "[]"
192
+ replaced with your own identifying information. (Don't include
193
+ the brackets!) The text should be enclosed in the appropriate
194
+ comment syntax for the file format. We also recommend that a
195
+ file or class name and description of purpose be included on the
196
+ same "printed page" as the copyright notice for easier
197
+ identification within third-party archives.
198
+
199
+ Copyright [2026] [Rohan R]
200
+
201
+ Licensed under the Apache License, Version 2.0 (the "License");
202
+ you may not use this file except in compliance with the License.
203
+ You may obtain a copy of the License at
204
+
205
+ http://www.apache.org/licenses/LICENSE-2.0
206
+
207
+ Unless required by applicable law or agreed to in writing, software
208
+ distributed under the License is distributed on an "AS IS" BASIS,
209
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
210
+ See the License for the specific language governing permissions and
211
+ limitations under the License.
README.md CHANGED
@@ -1,20 +1,23 @@
1
- ---
2
- license: mit
3
  library_name: pytorch
4
  pipeline_tag: image-segmentation
5
  tags:
6
  - image-segmentation
7
  - pytorch
8
  - unet
9
- ---
10
 
11
  # Gray Leaf Spot Segmentation Model
12
 
13
  PyTorch U-Net segmentation model trained for gray leaf spot segmentation.
14
 
15
- ## Files
16
 
17
- - `grayleafspot.pt`: serialized model artifact
 
 
 
 
 
 
18
  - `requirements.txt`: minimal runtime dependencies
19
 
20
  ## Usage
@@ -26,6 +29,78 @@ model = torch.load("grayleafspot.pt", map_location="cpu")
26
  model.eval()
27
  ```
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  ## Access
30
 
31
  This repository is gated with manual approval enabled on the Hugging Face Hub.
 
1
+ license: apache-2.0
 
2
  library_name: pytorch
3
  pipeline_tag: image-segmentation
4
  tags:
5
  - image-segmentation
6
  - pytorch
7
  - unet
 
8
 
9
  # Gray Leaf Spot Segmentation Model
10
 
11
  PyTorch U-Net segmentation model trained for gray leaf spot segmentation.
12
 
 
13
 
14
+
15
+
16
+ - `grayleafspot.pt`: main U-Net model artifact
17
+ - `best_area_w_0.1.pt`: area consistency U-Net (weight=0.1)
18
+ - `best_area_w_0.3.pt`: area consistency U-Net (weight=0.3)
19
+ - `best_area_w_0.5.pt`: area consistency U-Net (weight=0.5)
20
+ - `best_area_w_0.7.pt`: area consistency U-Net (weight=0.7)
21
  - `requirements.txt`: minimal runtime dependencies
22
 
23
  ## Usage
 
29
  model.eval()
30
  ```
31
 
32
+ ## Training & Inference Pipeline
33
+
34
+ This repository follows the TrainPetri pipeline for image segmentation, adapted for gray leaf spot. Key steps:
35
+
36
+ ### Environment Setup (Apple Silicon recommended)
37
+
38
+ 1. Create and activate a Python 3.10+ virtual environment:
39
+ ```bash
40
+ python3.10 -m venv trainenv
41
+ source trainenv/bin/activate
42
+ pip install --upgrade pip
43
+ pip install -r requirements.txt
44
+ ```
45
+
46
+ ### Dataset Preparation
47
+
48
+ - Place your raw images in `raw/` and corresponding masks in `masks/` (matching filenames).
49
+ - To expand the dataset with augmentations:
50
+ ```bash
51
+ python src/build_augmented_dataset.py --copies-per-image 4 --clean
52
+ ```
53
+
54
+ ### Training
55
+
56
+ - Standard U-Net training:
57
+ ```bash
58
+ python src/train.py --image-dir augmented_dataset/raw --mask-dir augmented_dataset/masks --epochs 40 --batch-size 4 --lr 1e-4 --image-size 256 --freeze-encoder-epochs 5
59
+ ```
60
+ - Area consistency U-Net (LabelMe JSON polygons):
61
+ ```bash
62
+ ./trainenv/bin/python src/area_consistency/train_area.py
63
+ ```
64
+
65
+ ### Inference
66
+
67
+ - On a single image:
68
+ ```bash
69
+ python src/predict.py --input raw/your_image.jpg --weights models/best_finetuned.pt --output-dir predictions
70
+ ```
71
+ - On a folder:
72
+ ```bash
73
+ python src/predict.py --input raw --weights models/best_finetuned.pt --output-dir predictions
74
+ ```
75
+
76
+ ### Best Practices
77
+
78
+ - Always keep your trusted human-label masks unchanged.
79
+ - Use augmentations and area consistency loss for improved generalization.
80
+ - Inspect overlay outputs to verify mask quality.
81
+ - For Apple Silicon, MPS acceleration is used automatically if available.
82
+
83
+
84
+
85
+
86
+ ## Citation
87
+
88
+ If you use this model or code, please cite:
89
+
90
+ ```
91
+ @software{rohan_grayleafspot_2026,
92
+ author = {Rohan, R.},
93
+ title = {Gray Leaf Spot Segmentation Model},
94
+ year = {2026},
95
+ orcid = {0009-0005-9225-1775}
96
+ }
97
+ ```
98
+
99
+
100
+ -## License
101
+
102
+ This project is licensed under the Apache License 2.0. See the LICENSE file for details.
103
+
104
  ## Access
105
 
106
  This repository is gated with manual approval enabled on the Hugging Face Hub.
best_area_w_0.1.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82c6182345f6bc552bd0c928217ebb36749aba66a3c60ad026ad840e91b13622
3
+ size 23560454
best_area_w_0.3.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06ede61290e9cf32603660859277a03fcb7a646c64d4119f84c43cef34c46be6
3
+ size 23560454
best_area_w_0.5.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:942f1b74e545ff451f7ad8ff479e54005ff1b32efcd07d7bd0e4064c2b7ea166
3
+ size 23560454
best_area_w_0.7.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e868313abe5335d60cb92ed3d968b04b80e1c63c7c63ea031699f109d38a840d
3
+ size 23560454