pixelprotest commited on
Commit
5556340
·
1 Parent(s): ac50dd1

Add code and model

Browse files
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../001_bunnies_recognition.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'interface', 'classify_image']
5
+
6
+ # %% ../001_bunnies_recognition.ipynb 33
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+
10
+ # %% ../001_bunnies_recognition.ipynb 35
11
+ learn = load_learner('model_bunnies.pkl')
12
+
13
+ # %% ../001_bunnies_recognition.ipynb 37
14
+ categories = ('Bunny', 'Nijntje', 'Peter Rabbit', 'Simon')
15
+
16
+ def classify_image(img):
17
+ pred, idx, probs = learn.predict(img)
18
+ return dict(zip(categories, map(float, probs)))
19
+
20
+ # %% ../001_bunnies_recognition.ipynb 39
21
+ image = gr.Image(width=512, height=512)
22
+ label = gr.Label()
23
+ # examples = ['nijn.jpg', 'nijntjesimon.png', 'simon.jpg', 'bunny.jpg']
24
+ examples = ['./bunnies_examples/img001.jpeg',
25
+ './bunnies_examples/img002.png',
26
+ './bunnies_examples/img003.jpeg',
27
+ './bunnies_examples/img004.png',
28
+ './bunnies_examples/img005.png',
29
+ './bunnies_examples/img006.png',
30
+ './bunnies_examples/img007.jpeg',
31
+ './bunnies_examples/img008.jpg',
32
+ './bunnies_examples/miff_handdrawn.jpeg',
33
+ './bunnies_examples/ttaro_bunny.png'
34
+ ]
35
+
36
+ interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
37
+ interface.launch(inline=False)
bunnies_examples/img001.jpeg ADDED
bunnies_examples/img002.png ADDED
bunnies_examples/img003.jpeg ADDED
bunnies_examples/img004.png ADDED
bunnies_examples/img005.png ADDED
bunnies_examples/img006.png ADDED
bunnies_examples/img007.jpeg ADDED
bunnies_examples/img008.jpg ADDED
bunnies_examples/miff_handdrawn.jpeg ADDED
bunnies_examples/ttaro_bunny.png ADDED
model_bunnies.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2687f2883026b06cf61cd15fbac17571c8435c44736f9d12721be9dbeed00dc6
3
+ size 46992558
requirements.txt ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ annotated-types==0.7.0
3
+ anyio==4.6.2.post1
4
+ argon2-cffi==23.1.0
5
+ argon2-cffi-bindings==21.2.0
6
+ arrow==1.3.0
7
+ asttokens==2.4.1
8
+ astunparse==1.6.3
9
+ async-lru==2.0.4
10
+ attrs==24.2.0
11
+ babel==2.16.0
12
+ beautifulsoup4==4.12.3
13
+ bleach==6.1.0
14
+ blis==1.0.1
15
+ catalogue==2.0.10
16
+ certifi==2024.8.30
17
+ cffi==1.17.1
18
+ charset-normalizer==3.4.0
19
+ click==8.1.7
20
+ cloudpathlib==0.20.0
21
+ comm==0.2.2
22
+ confection==0.1.5
23
+ contourpy==1.3.0
24
+ cycler==0.12.1
25
+ cymem==2.0.8
26
+ debugpy==1.8.7
27
+ decorator==5.1.1
28
+ defusedxml==0.7.1
29
+ duckduckgo_search==6.3.2
30
+ exceptiongroup==1.2.2
31
+ execnb==0.1.6
32
+ executing==2.1.0
33
+ fastai==2.7.18
34
+ fastapi==0.115.3
35
+ fastcore==1.7.19
36
+ fastdownload==0.0.7
37
+ fastjsonschema==2.20.0
38
+ fastprogress==1.0.3
39
+ ffmpy==0.4.0
40
+ filelock==3.13.1
41
+ fonttools==4.54.1
42
+ fqdn==1.5.1
43
+ fsspec==2024.2.0
44
+ ghapi==1.0.6
45
+ gradio==5.3.0
46
+ gradio_client==1.4.2
47
+ h11==0.14.0
48
+ httpcore==1.0.6
49
+ httpx==0.27.2
50
+ huggingface-hub==0.26.1
51
+ idna==3.10
52
+ ipykernel==6.29.5
53
+ ipython==8.28.0
54
+ ipywidgets==8.1.5
55
+ isoduration==20.11.0
56
+ jedi==0.19.1
57
+ Jinja2==3.1.4
58
+ joblib==1.4.2
59
+ json5==0.9.25
60
+ jsonpointer==3.0.0
61
+ jsonschema==4.23.0
62
+ jsonschema-specifications==2024.10.1
63
+ jupyter-events==0.10.0
64
+ jupyter-lsp==2.2.5
65
+ jupyter_client==8.6.3
66
+ jupyter_core==5.7.2
67
+ jupyter_server==2.14.2
68
+ jupyter_server_terminals==0.5.3
69
+ jupyterlab==4.2.5
70
+ jupyterlab-vim==4.1.4
71
+ jupyterlab_pygments==0.3.0
72
+ jupyterlab_server==2.27.3
73
+ jupyterlab_widgets==3.0.13
74
+ kaggle==1.6.17
75
+ kiwisolver==1.4.7
76
+ langcodes==3.4.1
77
+ language_data==1.2.0
78
+ marisa-trie==1.2.1
79
+ markdown-it-py==3.0.0
80
+ MarkupSafe==2.1.5
81
+ matplotlib==3.9.2
82
+ matplotlib-inline==0.1.7
83
+ mdurl==0.1.2
84
+ mistune==3.0.2
85
+ mpmath==1.3.0
86
+ murmurhash==1.0.10
87
+ nbclient==0.10.0
88
+ nbconvert==7.16.4
89
+ nbdev==2.3.31
90
+ nbformat==5.10.4
91
+ nest-asyncio==1.6.0
92
+ networkx==3.2.1
93
+ notebook_shim==0.2.4
94
+ numpy==2.0.2
95
+ nvidia-cublas-cu12==12.1.3.1
96
+ nvidia-cuda-cupti-cu12==12.1.105
97
+ nvidia-cuda-nvrtc-cu12==12.1.105
98
+ nvidia-cuda-runtime-cu12==12.1.105
99
+ nvidia-cudnn-cu12==9.1.0.70
100
+ nvidia-cufft-cu12==11.0.2.54
101
+ nvidia-curand-cu12==10.3.2.106
102
+ nvidia-cusolver-cu12==11.4.5.107
103
+ nvidia-cusparse-cu12==12.1.0.106
104
+ nvidia-nccl-cu12==2.21.5
105
+ nvidia-nvjitlink-cu12==12.1.105
106
+ nvidia-nvtx-cu12==12.1.105
107
+ orjson==3.10.10
108
+ overrides==7.7.0
109
+ packaging==24.1
110
+ pandas==2.2.3
111
+ pandocfilters==1.5.1
112
+ parso==0.8.4
113
+ pexpect==4.9.0
114
+ pillow==10.2.0
115
+ platformdirs==4.3.6
116
+ preshed==3.0.9
117
+ primp==0.6.4
118
+ prometheus_client==0.21.0
119
+ prompt_toolkit==3.0.48
120
+ psutil==6.1.0
121
+ ptyprocess==0.7.0
122
+ pure_eval==0.2.3
123
+ pycparser==2.22
124
+ pydantic==2.9.2
125
+ pydantic_core==2.23.4
126
+ pydub==0.25.1
127
+ Pygments==2.18.0
128
+ pyparsing==3.2.0
129
+ python-dateutil==2.9.0.post0
130
+ python-json-logger==2.0.7
131
+ python-multipart==0.0.12
132
+ python-slugify==8.0.4
133
+ pytz==2024.2
134
+ PyYAML==6.0.2
135
+ pyzmq==26.2.0
136
+ referencing==0.35.1
137
+ requests==2.32.3
138
+ rfc3339-validator==0.1.4
139
+ rfc3986-validator==0.1.1
140
+ rich==13.9.2
141
+ rpds-py==0.20.0
142
+ ruff==0.7.1
143
+ safetensors==0.4.5
144
+ scikit-learn==1.5.2
145
+ scipy==1.14.1
146
+ semantic-version==2.10.0
147
+ Send2Trash==1.8.3
148
+ shellingham==1.5.4
149
+ six==1.16.0
150
+ smart-open==7.0.5
151
+ sniffio==1.3.1
152
+ soupsieve==2.6
153
+ spacy==3.8.2
154
+ spacy-legacy==3.0.12
155
+ spacy-loggers==1.0.5
156
+ srsly==2.4.8
157
+ stack-data==0.6.3
158
+ starlette==0.41.0
159
+ sympy==1.13.1
160
+ terminado==0.18.1
161
+ text-unidecode==1.3
162
+ thinc==8.3.2
163
+ threadpoolctl==3.5.0
164
+ tinycss2==1.3.0
165
+ tomli==2.0.2
166
+ tomlkit==0.12.0
167
+ torch==2.5.0+cu121
168
+ torchaudio==2.5.0+cu121
169
+ torchvision==0.20.0+cu121
170
+ tornado==6.4.1
171
+ tqdm==4.66.5
172
+ traitlets==5.14.3
173
+ triton==3.1.0
174
+ typer==0.12.5
175
+ types-python-dateutil==2.9.0.20241003
176
+ typing_extensions==4.12.2
177
+ tzdata==2024.2
178
+ uri-template==1.3.0
179
+ urllib3==2.2.3
180
+ uvicorn==0.32.0
181
+ wasabi==1.1.3
182
+ watchdog==5.0.3
183
+ wcwidth==0.2.13
184
+ weasel==0.4.1
185
+ webcolors==24.8.0
186
+ webencodings==0.5.1
187
+ websocket-client==1.8.0
188
+ websockets==12.0
189
+ widgetsnbextension==4.0.13
190
+ wrapt==1.16.0