marii commited on
Commit
61aab1a
·
1 Parent(s): 05a64ac
00_app.ipynb ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 9,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "# default_exp core"
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "markdown",
14
+ "metadata": {},
15
+ "source": [
16
+ "# module name here\n",
17
+ "\n",
18
+ "> API details."
19
+ ]
20
+ },
21
+ {
22
+ "cell_type": "code",
23
+ "execution_count": 2,
24
+ "metadata": {},
25
+ "outputs": [],
26
+ "source": [
27
+ "#hide\n",
28
+ "from nbdev.showdoc import *"
29
+ ]
30
+ },
31
+ {
32
+ "cell_type": "code",
33
+ "execution_count": 3,
34
+ "metadata": {},
35
+ "outputs": [
36
+ {
37
+ "data": {
38
+ "text/html": [
39
+ "<table border=\"1\" class=\"dataframe\">\n",
40
+ " <thead>\n",
41
+ " <tr style=\"text-align: left;\">\n",
42
+ " <th>epoch</th>\n",
43
+ " <th>train_loss</th>\n",
44
+ " <th>valid_loss</th>\n",
45
+ " <th>accuracy</th>\n",
46
+ " <th>time</th>\n",
47
+ " </tr>\n",
48
+ " </thead>\n",
49
+ " <tbody>\n",
50
+ " <tr>\n",
51
+ " <td>0</td>\n",
52
+ " <td>0.966888</td>\n",
53
+ " <td>0.311951</td>\n",
54
+ " <td>0.899188</td>\n",
55
+ " <td>00:28</td>\n",
56
+ " </tr>\n",
57
+ " </tbody>\n",
58
+ "</table>"
59
+ ],
60
+ "text/plain": [
61
+ "<IPython.core.display.HTML object>"
62
+ ]
63
+ },
64
+ "metadata": {},
65
+ "output_type": "display_data"
66
+ },
67
+ {
68
+ "data": {
69
+ "text/html": [
70
+ "<table border=\"1\" class=\"dataframe\">\n",
71
+ " <thead>\n",
72
+ " <tr style=\"text-align: left;\">\n",
73
+ " <th>epoch</th>\n",
74
+ " <th>train_loss</th>\n",
75
+ " <th>valid_loss</th>\n",
76
+ " <th>accuracy</th>\n",
77
+ " <th>time</th>\n",
78
+ " </tr>\n",
79
+ " </thead>\n",
80
+ " <tbody>\n",
81
+ " <tr>\n",
82
+ " <td>0</td>\n",
83
+ " <td>0.458197</td>\n",
84
+ " <td>0.272663</td>\n",
85
+ " <td>0.908660</td>\n",
86
+ " <td>00:31</td>\n",
87
+ " </tr>\n",
88
+ " </tbody>\n",
89
+ "</table>"
90
+ ],
91
+ "text/plain": [
92
+ "<IPython.core.display.HTML object>"
93
+ ]
94
+ },
95
+ "metadata": {},
96
+ "output_type": "display_data"
97
+ }
98
+ ],
99
+ "source": [
100
+ "from fastai.vision.all import *\n",
101
+ "path = untar_data(URLs.PETS)\n",
102
+ "dls = ImageDataLoaders.from_name_re(path, get_image_files(path/'images'), pat='(.+)_\\d+.jpg', item_tfms=Resize(460), batch_tfms=aug_transforms(size=224, min_scale=0.75))\n",
103
+ "learn = vision_learner(dls, models.resnet50, metrics=accuracy)\n",
104
+ "learn.fine_tune(1)\n",
105
+ "learn.path = Path('.')\n",
106
+ "learn.export()"
107
+ ]
108
+ },
109
+ {
110
+ "cell_type": "code",
111
+ "execution_count": 4,
112
+ "metadata": {},
113
+ "outputs": [],
114
+ "source": [
115
+ "#export\n",
116
+ "learn = load_learner('export.pkl')"
117
+ ]
118
+ },
119
+ {
120
+ "cell_type": "code",
121
+ "execution_count": 5,
122
+ "metadata": {},
123
+ "outputs": [],
124
+ "source": [
125
+ "#export\n",
126
+ "labels = learn.dls.vocab\n",
127
+ "def predict(img):\n",
128
+ " img = PILImage.create(img)\n",
129
+ " pred,pred_idx,probs = learn.predict(img)\n",
130
+ "\n",
131
+ " return {labels[i]: float(probs[i]) for i in range(len(labels))}"
132
+ ]
133
+ },
134
+ {
135
+ "cell_type": "code",
136
+ "execution_count": 6,
137
+ "metadata": {},
138
+ "outputs": [
139
+ {
140
+ "name": "stdout",
141
+ "output_type": "stream",
142
+ "text": [
143
+ "Running on local URL: http://127.0.0.1:7860/\n",
144
+ "Running on public URL: https://31643.gradio.app\n",
145
+ "\n",
146
+ "This share link expires in 72 hours. For free permanent hosting, check out Spaces (https://huggingface.co/spaces)\n"
147
+ ]
148
+ },
149
+ {
150
+ "data": {
151
+ "text/html": [
152
+ "\n",
153
+ " <iframe\n",
154
+ " width=\"900\"\n",
155
+ " height=\"500\"\n",
156
+ " src=\"https://31643.gradio.app\"\n",
157
+ " frameborder=\"0\"\n",
158
+ " allowfullscreen\n",
159
+ " \n",
160
+ " ></iframe>\n",
161
+ " "
162
+ ],
163
+ "text/plain": [
164
+ "<IPython.lib.display.IFrame at 0x7f5124f51430>"
165
+ ]
166
+ },
167
+ "metadata": {},
168
+ "output_type": "display_data"
169
+ },
170
+ {
171
+ "data": {
172
+ "text/plain": [
173
+ "(<fastapi.applications.FastAPI at 0x7f51600bf880>,\n",
174
+ " 'http://127.0.0.1:7860/',\n",
175
+ " 'https://31643.gradio.app')"
176
+ ]
177
+ },
178
+ "execution_count": 6,
179
+ "metadata": {},
180
+ "output_type": "execute_result"
181
+ },
182
+ {
183
+ "data": {
184
+ "text/html": [],
185
+ "text/plain": [
186
+ "<IPython.core.display.HTML object>"
187
+ ]
188
+ },
189
+ "metadata": {},
190
+ "output_type": "display_data"
191
+ }
192
+ ],
193
+ "source": [
194
+ "#export\n",
195
+ "import gradio as gr\n",
196
+ "gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)"
197
+ ]
198
+ },
199
+ {
200
+ "cell_type": "code",
201
+ "execution_count": 10,
202
+ "metadata": {},
203
+ "outputs": [
204
+ {
205
+ "name": "stdout",
206
+ "output_type": "stream",
207
+ "text": [
208
+ "Converted 00_app.ipynb.\r\n",
209
+ "Converted index.ipynb.\r\n"
210
+ ]
211
+ }
212
+ ],
213
+ "source": [
214
+ "! nbdev_build_lib"
215
+ ]
216
+ },
217
+ {
218
+ "cell_type": "code",
219
+ "execution_count": null,
220
+ "metadata": {},
221
+ "outputs": [],
222
+ "source": []
223
+ }
224
+ ],
225
+ "metadata": {
226
+ "kernelspec": {
227
+ "display_name": "Python 3 (ipykernel)",
228
+ "language": "python",
229
+ "name": "python3"
230
+ },
231
+ "language_info": {
232
+ "codemirror_mode": {
233
+ "name": "ipython",
234
+ "version": 3
235
+ },
236
+ "file_extension": ".py",
237
+ "mimetype": "text/x-python",
238
+ "name": "python",
239
+ "nbconvert_exporter": "python",
240
+ "pygments_lexer": "ipython3",
241
+ "version": "3.9.7"
242
+ }
243
+ },
244
+ "nbformat": 4,
245
+ "nbformat_minor": 2
246
+ }
CONTRIBUTING.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # How to contribute
2
+
3
+ ## How to get started
4
+
5
+ Before anything else, please install the git hooks that run automatic scripts during each commit and merge to strip the notebooks of superfluous metadata (and avoid merge conflicts). After cloning the repository, run the following command inside it:
6
+ ```
7
+ nbdev_install_git_hooks
8
+ ```
9
+
10
+ ## Did you find a bug?
11
+
12
+ * Ensure the bug was not already reported by searching on GitHub under Issues.
13
+ * If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.
14
+ * Be sure to add the complete error messages.
15
+
16
+ #### Did you write a patch that fixes a bug?
17
+
18
+ * Open a new GitHub pull request with the patch.
19
+ * Ensure that your PR includes a test that fails without your patch, and pass with it.
20
+ * Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
21
+
22
+ ## PR submission guidelines
23
+
24
+ * Keep each PR focused. While it's more convenient, do not combine several unrelated fixes together. Create as many branches as needing to keep each PR focused.
25
+ * Do not mix style changes/fixes with "functional" changes. It's very difficult to review such PRs and it most likely get rejected.
26
+ * Do not add/remove vertical whitespace. Preserve the original style of the file you edit as much as you can.
27
+ * Do not turn an already submitted PR into your development playground. If after you submitted PR, you discovered that more work is needed - close the PR, do the required work and then submit a new PR. Otherwise each of your commits requires attention from maintainers of the project.
28
+ * If, however, you submitted a PR and received a request for changes, you should proceed with commits inside that PR, so that the maintainer can see the incremental fixes and won't need to review the whole PR again. In the exception case where you realize it'll take many many commits to complete the requests, then it's probably best to close the PR, do the work and then submit it again. Use common sense where you'd choose one way over another.
29
+
30
+ ## Do you want to contribute to the documentation?
31
+
32
+ * Docs are automatically created from the notebooks in the nbs folder.
33
+
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
MANIFEST.in ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ include settings.ini
2
+ include LICENSE
3
+ include CONTRIBUTING.md
4
+ include README.md
5
+ recursive-exclude * __pycache__
Makefile ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ONESHELL:
2
+ SHELL := /bin/bash
3
+ SRC = $(wildcard ./*.ipynb)
4
+
5
+ all: pets docs
6
+
7
+ pets: $(SRC)
8
+ nbdev_build_lib
9
+ touch pets
10
+
11
+ sync:
12
+ nbdev_update_lib
13
+
14
+ docs_serve: docs
15
+ cd docs && bundle exec jekyll serve
16
+
17
+ docs: $(SRC)
18
+ nbdev_build_docs
19
+ touch docs
20
+
21
+ test:
22
+ nbdev_test_nbs
23
+
24
+ release: pypi conda_release
25
+ nbdev_bump_version
26
+
27
+ conda_release:
28
+ fastrelease_conda_package
29
+
30
+ pypi: dist
31
+ twine upload --repository pypi dist/*
32
+
33
+ dist: clean
34
+ python setup.py sdist bdist_wheel
35
+
36
+ clean:
37
+ rm -rf dist
README.md CHANGED
@@ -1,12 +1,20 @@
1
- ---
2
- title: Study_group_example
3
- emoji: 🐠
4
- colorFrom: purple
5
- colorTo: green
6
- sdk: gradio
7
- sdk_version: 2.9.4
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
 
 
 
 
 
 
 
 
 
1
+ # nbdev template
2
+
3
+ Use this template to more easily create your [nbdev](https://nbdev.fast.ai/) project.
4
+
5
+ _If you are using an older version of this template, and want to upgrade to the theme-based version, see [this helper script](https://gist.github.com/hamelsmu/977e82a23dcd8dcff9058079cb4a8f18) (more explanation of what this means is contained in the link to the script)_.
6
+
7
+ ## Troubleshooting Tips
8
+
9
+ - Make sure you are using the latest version of nbdev with `pip install -U nbdev`
10
+ - If you are using an older version of this template, see the instructions above on how to upgrade your template.
11
+ - It is important for you to spell the name of your user and repo correctly in `settings.ini` or the website will not have the correct address from which to source assets like CSS for your site. When in doubt, you can open your browser's developer console and see if there are any errors related to fetching assets for your website due to an incorrect URL generated by misspelled values from `settings.ini`.
12
+ - If you change the name of your repo, you have to make the appropriate changes in `settings.ini`
13
+ - After you make changes to `settings.ini`, run `nbdev_build_lib && nbdev_clean_nbs && nbdev_build_docs` to make sure all changes are propagated appropriately.
14
+
15
+
16
+ ## Previewing Documents Locally
17
+
18
+ It is often desirable to preview nbdev generated documentation locally before having it built and rendered by GitHub Pages. This requires you to run Jekyll locally, which requires installing Ruby and Jekyll. Instructions on how to install Jekyll are provided [on Jekyll's site](https://jekyllrb.com/). You can run the command `make docs_serve` from the root of your repo to serve the documentation locally after calling `nbdev_build_docs` to generate the docs.
19
+
20
+ In order to allow you to run Jekyll locally this project contains manifest files, called Gem files, that specify all Ruby dependencies for Jekyll & nbdev. **If you do not plan to preview documentation locally**, you can choose to delete `docs/Gemfile` and `docs/Gemfile.lock` from your nbdev project (for example, after creating a new repo from this template).
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: 00_app.ipynb (unless otherwise specified).
2
+
3
+ __all__ = ['learn', 'predict', 'labels']
4
+
5
+ # Cell
6
+ learn = load_learner('export.pkl')
7
+
8
+ # Cell
9
+ labels = learn.dls.vocab
10
+ def predict(img):
11
+ img = PILImage.create(img)
12
+ pred,pred_idx,probs = learn.predict(img)
13
+
14
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
15
+
16
+ # Cell
17
+ import gradio as gr
18
+ gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
docker-compose.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: "3"
2
+ services:
3
+ fastai: &fastai
4
+ restart: unless-stopped
5
+ working_dir: /data
6
+ image: fastai/codespaces
7
+ logging:
8
+ driver: json-file
9
+ options:
10
+ max-size: 50m
11
+ stdin_open: true
12
+ tty: true
13
+ volumes:
14
+ - .:/data/
15
+
16
+ notebook:
17
+ <<: *fastai
18
+ command: bash -c "pip install -e . && jupyter notebook --allow-root --no-browser --ip=0.0.0.0 --port=8080 --NotebookApp.token='' --NotebookApp.password=''"
19
+ ports:
20
+ - "8080:8080"
21
+
22
+ watcher:
23
+ <<: *fastai
24
+ command: watchmedo shell-command --command nbdev_build_docs --pattern *.ipynb --recursive --drop
25
+ network_mode: host # for GitHub Codespaces https://github.com/features/codespaces/
26
+
27
+ jekyll:
28
+ <<: *fastai
29
+ ports:
30
+ - "4000:4000"
31
+ command: >
32
+ bash -c "pip install .
33
+ && nbdev_build_docs && cd docs
34
+ && bundle i
35
+ && chmod -R u+rwx . && bundle exec jekyll serve --host 0.0.0.0"
docs/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ _site/
docs/Gemfile ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ source "https://rubygems.org"
2
+
3
+ gem "jekyll", ">= 3.7"
4
+ gem "jekyll-remote-theme"
docs/_config.yml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ repository: marii.moe/pets
2
+ output: web
3
+ topnav_title: pets
4
+ site_title: pets
5
+ company_name: apache
6
+ description: A example for study group
7
+ # Set to false to disable KaTeX math
8
+ use_math: true
9
+ # Add Google analytics id if you have one and want to use it here
10
+ google_analytics:
11
+ # See http://nbdev.fast.ai/search for help with adding Search
12
+ google_search:
13
+
14
+ host: 127.0.0.1
15
+ # the preview server used. Leave as is.
16
+ port: 4000
17
+ # the port where the preview is rendered.
18
+
19
+ exclude:
20
+ - .idea/
21
+ - .gitignore
22
+ - vendor
23
+
24
+ exclude: [vendor]
25
+
26
+ highlighter: rouge
27
+ markdown: kramdown
28
+ kramdown:
29
+ input: GFM
30
+ auto_ids: true
31
+ hard_wrap: false
32
+ syntax_highlighter: rouge
33
+
34
+ collections:
35
+ tooltips:
36
+ output: false
37
+
38
+ defaults:
39
+ -
40
+ scope:
41
+ path: ""
42
+ type: "pages"
43
+ values:
44
+ layout: "page"
45
+ comments: true
46
+ search: true
47
+ sidebar: home_sidebar
48
+ topnav: topnav
49
+ -
50
+ scope:
51
+ path: ""
52
+ type: "tooltips"
53
+ values:
54
+ layout: "page"
55
+ comments: true
56
+ search: true
57
+ tooltip: true
58
+
59
+ sidebars:
60
+ - home_sidebar
61
+
62
+ plugins:
63
+ - jekyll-remote-theme
64
+
65
+ remote_theme: fastai/nbdev-jekyll-theme
66
+ baseurl: /pets/
docs/_data/topnav.yml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ topnav:
2
+ - title: Topnav
3
+ items:
4
+ - title: github
5
+ external_url: https://github.com/marii.moe/pets/tree/{branch}/
6
+
7
+ #Topnav dropdowns
8
+ topnav_dropdowns:
9
+ - title: Topnav dropdowns
10
+ folders:
docs/feed.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ search: exclude
3
+ layout: none
4
+ ---
5
+
6
+ <?xml version="1.0" encoding="UTF-8"?>
7
+ <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
8
+ <channel>
9
+ <title>{{ site.title | xml_escape }}</title>
10
+ <description>{{ site.description | xml_escape }}</description>
11
+ <link>{{ site.url }}/</link>
12
+ <atom:link href="{{ "/feed.xml" | prepend: site.url }}" rel="self" type="application/rss+xml"/>
13
+ <pubDate>{{ site.time | date_to_rfc822 }}</pubDate>
14
+ <lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
15
+ <generator>Jekyll v{{ jekyll.version }}</generator>
16
+ {% for post in site.posts limit:10 %}
17
+ <item>
18
+ <title>{{ post.title | xml_escape }}</title>
19
+ <description>{{ post.content | xml_escape }}</description>
20
+ <pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
21
+ <link>{{ post.url | prepend: site.url }}</link>
22
+ <guid isPermaLink="true">{{ post.url | prepend: site.url }}</guid>
23
+ {% for tag in post.tags %}
24
+ <category>{{ tag | xml_escape }}</category>
25
+ {% endfor %}
26
+ {% for tag in page.tags %}
27
+ <category>{{ cat | xml_escape }}</category>
28
+ {% endfor %}
29
+ </item>
30
+ {% endfor %}
31
+ </channel>
32
+ </rss>
docs/sitemap.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ layout: none
3
+ search: exclude
4
+ ---
5
+
6
+ <?xml version="1.0" encoding="UTF-8"?>
7
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
8
+ {% for post in site.posts %}
9
+ {% unless post.search == "exclude" %}
10
+ <url>
11
+ <loc>{{site.url}}{{post.url}}</loc>
12
+ </url>
13
+ {% endunless %}
14
+ {% endfor %}
15
+
16
+
17
+ {% for page in site.pages %}
18
+ {% unless page.search == "exclude" %}
19
+ <url>
20
+ <loc>{{site.url}}{{ page.url}}</loc>
21
+ </url>
22
+ {% endunless %}
23
+ {% endfor %}
24
+ </urlset>
index.ipynb ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "#hide\n",
10
+ "from your_lib.core import *"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "markdown",
15
+ "metadata": {},
16
+ "source": [
17
+ "# Project name here\n",
18
+ "\n",
19
+ "> Summary description here."
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "markdown",
24
+ "metadata": {},
25
+ "source": [
26
+ "This file will become your README and also the index of your documentation."
27
+ ]
28
+ },
29
+ {
30
+ "cell_type": "markdown",
31
+ "metadata": {},
32
+ "source": [
33
+ "## Install"
34
+ ]
35
+ },
36
+ {
37
+ "cell_type": "markdown",
38
+ "metadata": {},
39
+ "source": [
40
+ "`pip install your_project_name`"
41
+ ]
42
+ },
43
+ {
44
+ "cell_type": "markdown",
45
+ "metadata": {},
46
+ "source": [
47
+ "## How to use"
48
+ ]
49
+ },
50
+ {
51
+ "cell_type": "markdown",
52
+ "metadata": {},
53
+ "source": [
54
+ "Fill me in please! Don't forget code examples:"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": null,
60
+ "metadata": {},
61
+ "outputs": [
62
+ {
63
+ "data": {
64
+ "text/plain": [
65
+ "2"
66
+ ]
67
+ },
68
+ "execution_count": null,
69
+ "metadata": {},
70
+ "output_type": "execute_result"
71
+ }
72
+ ],
73
+ "source": [
74
+ "1+1"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "code",
79
+ "execution_count": null,
80
+ "metadata": {},
81
+ "outputs": [],
82
+ "source": []
83
+ }
84
+ ],
85
+ "metadata": {
86
+ "kernelspec": {
87
+ "display_name": "Python 3",
88
+ "language": "python",
89
+ "name": "python3"
90
+ }
91
+ },
92
+ "nbformat": 4,
93
+ "nbformat_minor": 2
94
+ }
pets/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ __version__ = "0.0.1"
pets/__pycache__/_nbdev.cpython-39.pyc ADDED
Binary file (500 Bytes). View file
 
pets/_nbdev.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED BY NBDEV! DO NOT EDIT!
2
+
3
+ __all__ = ["index", "modules", "custom_doc_links", "git_url"]
4
+
5
+ index = {"learn": "00_app.ipynb",
6
+ "predict": "00_app.ipynb",
7
+ "labels": "00_app.ipynb"}
8
+
9
+ modules = ["core.py"]
10
+
11
+ doc_url = "https://marii.moe.github.io/pets/"
12
+
13
+ git_url = "https://github.com/marii.moe/pets/tree/{branch}/"
14
+
15
+ def custom_doc_links(name): return None
pets/core.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: 00_app.ipynb (unless otherwise specified).
2
+
3
+ __all__ = ['learn', 'predict', 'labels']
4
+
5
+ # Cell
6
+ learn = load_learner('export.pkl')
7
+
8
+ # Cell
9
+ labels = learn.dls.vocab
10
+ def predict(img):
11
+ img = PILImage.create(img)
12
+ pred,pred_idx,probs = learn.predict(img)
13
+
14
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
15
+
16
+ # Cell
17
+ import gradio as gr
18
+ gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
settings.ini ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [DEFAULT]
2
+ # All sections below are required unless otherwise specified
3
+ host = github
4
+ lib_name = pets
5
+ # For Enterprise Git add variable repo_name and company name
6
+ repo_name = study_group_nbdev
7
+ # company_name = nike
8
+
9
+ user = marii.moe
10
+ description = A example for study group
11
+ # keywords = some keywords
12
+ author = {author}
13
+ author_email = {author_email}
14
+ copyright = apache
15
+ branch = {branch}
16
+ version = 0.0.1
17
+ min_python = 3.6
18
+ audience = Developers
19
+ language = English
20
+ # Set to True if you want to create a more fancy sidebar.json than the default
21
+ custom_sidebar = False
22
+ # Add licenses and see current list in `setup.py`
23
+ license = apache2
24
+ # From 1-7: Planning Pre-Alpha Alpha Beta Production Mature Inactive
25
+ status = 2
26
+
27
+ # Optional. Same format as setuptools requirements
28
+ # requirements =
29
+ # Optional. Same format as setuptools console_scripts
30
+ # console_scripts =
31
+ # Optional. Same format as setuptools dependency-links
32
+ # dep_links =
33
+
34
+ ###
35
+ # You probably won't need to change anything under here,
36
+ # unless you have some special requirements
37
+ ###
38
+
39
+ # Change to, e.g. "nbs", to put your notebooks in nbs dir instead of repo root
40
+ nbs_path = .
41
+ doc_path = docs
42
+
43
+ # Whether to look for library notebooks recursively in the `nbs_path` dir
44
+ recursive = False
45
+
46
+ # Anything shown as '%(...)s' is substituted with that setting automatically
47
+ doc_host = https://%(user)s.github.io
48
+ #For Enterprise Git pages use:
49
+ #doc_host = https://pages.github.%(company_name)s.com.
50
+
51
+
52
+ doc_baseurl = /%(lib_name)s/
53
+ # For Enterprise Github pages docs use:
54
+ # doc_baseurl = /%(repo_name)s/%(lib_name)s/
55
+
56
+ git_url = https://github.com/%(user)s/%(lib_name)s/tree/%(branch)s/
57
+ # For Enterprise Github use:
58
+ #git_url = https://github.%(company_name)s.com/%(repo_name)s/%(lib_name)s/tree/%(branch)s/
59
+
60
+
61
+
62
+ lib_path = %(lib_name)s
63
+ title = %(lib_name)s
64
+
65
+ #Optional advanced parameters
66
+ #Monospace docstings: adds <pre> tags around the doc strings, preserving newlines/indentation.
67
+ #monospace_docstrings = False
68
+ #Test flags: introduce here the test flags you want to use separated by |
69
+ #tst_flags =
70
+ #Custom sidebar: customize sidebar.json yourself for advanced sidebars (False/True)
71
+ #custom_sidebar =
72
+ #Cell spacing: if you want cell blocks in code separated by more than one new line
73
+ #cell_spacing =
74
+ #Custom jekyll styles: if you want more jekyll styles than tip/important/warning, set them here
75
+ #jekyll_styles = note,warning,tip,important
setup.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pkg_resources import parse_version
2
+ from configparser import ConfigParser
3
+ import setuptools,re,sys
4
+ assert parse_version(setuptools.__version__)>=parse_version('36.2')
5
+
6
+ # note: all settings are in settings.ini; edit there, not here
7
+ config = ConfigParser(delimiters=['='])
8
+ config.read('settings.ini')
9
+ cfg = config['DEFAULT']
10
+
11
+ cfg_keys = 'version description keywords author author_email'.split()
12
+ expected = cfg_keys + "lib_name user branch license status min_python audience language".split()
13
+ for o in expected: assert o in cfg, "missing expected setting: {}".format(o)
14
+ setup_cfg = {o:cfg[o] for o in cfg_keys}
15
+
16
+ if len(sys.argv)>1 and sys.argv[1]=='version':
17
+ print(setup_cfg['version'])
18
+ exit()
19
+
20
+ licenses = {
21
+ 'apache2': ('Apache Software License 2.0','OSI Approved :: Apache Software License'),
22
+ 'mit': ('MIT License', 'OSI Approved :: MIT License'),
23
+ 'gpl2': ('GNU General Public License v2', 'OSI Approved :: GNU General Public License v2 (GPLv2)'),
24
+ 'gpl3': ('GNU General Public License v3', 'OSI Approved :: GNU General Public License v3 (GPLv3)'),
25
+ 'bsd3': ('BSD License', 'OSI Approved :: BSD License'),
26
+ }
27
+ statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha',
28
+ '4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ]
29
+ py_versions = '2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10'.split()
30
+
31
+ lic = licenses.get(cfg['license'].lower(), (cfg['license'], None))
32
+ min_python = cfg['min_python']
33
+
34
+ requirements = ['pip', 'packaging']
35
+ if cfg.get('requirements'): requirements += cfg.get('requirements','').split()
36
+ if cfg.get('pip_requirements'): requirements += cfg.get('pip_requirements','').split()
37
+ dev_requirements = (cfg.get('dev_requirements') or '').split()
38
+
39
+ long_description = open('README.md').read()
40
+ # ![png](docs/images/output_13_0.png)
41
+ for ext in ['png', 'svg']:
42
+ long_description = re.sub(r'!\['+ext+'\]\((.*)\)', '!['+ext+']('+'https://raw.githubusercontent.com/{}/{}'.format(cfg['user'],cfg['lib_name'])+'/'+cfg['branch']+'/\\1)', long_description)
43
+ long_description = re.sub(r'src=\"(.*)\.'+ext+'\"', 'src=\"https://raw.githubusercontent.com/{}/{}'.format(cfg['user'],cfg['lib_name'])+'/'+cfg['branch']+'/\\1.'+ext+'\"', long_description)
44
+
45
+ setuptools.setup(
46
+ name = cfg['lib_name'],
47
+ license = lic[0],
48
+ classifiers = [
49
+ 'Development Status :: ' + statuses[int(cfg['status'])],
50
+ 'Intended Audience :: ' + cfg['audience'].title(),
51
+ 'Natural Language :: ' + cfg['language'].title(),
52
+ ] + ['Programming Language :: Python :: '+o for o in py_versions[py_versions.index(min_python):]] + (['License :: ' + lic[1] ] if lic[1] else []),
53
+ url = cfg['git_url'],
54
+ packages = setuptools.find_packages(),
55
+ include_package_data = True,
56
+ install_requires = requirements,
57
+ extras_require={ 'dev': dev_requirements },
58
+ python_requires = '>=' + cfg['min_python'],
59
+ long_description = long_description,
60
+ long_description_content_type = 'text/markdown',
61
+ zip_safe = False,
62
+ entry_points = { 'console_scripts': cfg.get('console_scripts','').split() },
63
+ **setup_cfg)
64
+