Spaces:
Sleeping
Sleeping
Commit
·
e64de93
1
Parent(s):
4f03596
intial
Browse files- .gitattributes +4 -0
- README.md +5 -5
- app.py +42 -0
- example_images/cat.jpg +3 -0
- example_images/dog1.jpeg +0 -0
- example_images/dog2.jpeg +3 -0
- example_images/leonberger.jpg +3 -0
- example_images/snow_leopard.jpeg +3 -0
- requierements.txt +200 -0
- transfer_learning_image_classification.ipynb +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,7 @@ 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 |
+
example_images/cat.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
example_images/dog2.jpeg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
example_images/leonberger.jpg filter=lfs diff=lfs merge=lfs -text
|
39 |
+
example_images/snow_leopard.jpeg filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 5.25.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
|
|
1 |
---
|
2 |
+
title: LN2
|
3 |
+
emoji: 🚀
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: pink
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 5.25.1
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
---
|
app.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load models
|
5 |
+
vit_classifier = pipeline("image-classification", model="jarinschnierl/vit-base-oxford-iiit-pets")
|
6 |
+
clip_detector = pipeline(model="openai/clip-vit-large-patch14", task="zero-shot-image-classification")
|
7 |
+
|
8 |
+
labels_oxford_pets = [
|
9 |
+
'Siamese', 'Birman', 'shiba inu', 'staffordshire bull terrier', 'basset hound', 'Bombay', 'japanese chin',
|
10 |
+
'chihuahua', 'german shorthaired', 'pomeranian', 'beagle', 'english cocker spaniel', 'american pit bull terrier',
|
11 |
+
'Ragdoll', 'Persian', 'Egyptian Mau', 'miniature pinscher', 'Sphynx', 'Maine Coon', 'keeshond', 'yorkshire terrier',
|
12 |
+
'havanese', 'leonberger', 'wheaten terrier', 'american bulldog', 'english setter', 'boxer', 'newfoundland', 'Bengal',
|
13 |
+
'samoyed', 'British Shorthair', 'great pyrenees', 'Abyssinian', 'pug', 'saint bernard', 'Russian Blue', 'scottish terrier'
|
14 |
+
]
|
15 |
+
|
16 |
+
def classify_pet(image):
|
17 |
+
vit_results = vit_classifier(image)
|
18 |
+
vit_output = {result['label']: result['score'] for result in vit_results}
|
19 |
+
|
20 |
+
clip_results = clip_detector(image, candidate_labels=labels_oxford_pets)
|
21 |
+
clip_output = {result['label']: result['score'] for result in clip_results}
|
22 |
+
|
23 |
+
return {"ViT Classification": vit_output, "CLIP Zero-Shot Classification": clip_output}
|
24 |
+
|
25 |
+
example_images = [
|
26 |
+
["example_images/dog1.jpeg"],
|
27 |
+
["example_images/dog2.jpeg"],
|
28 |
+
["example_images/leonberger.jpg"],
|
29 |
+
["example_images/snow_leopard.jpeg"],
|
30 |
+
["example_images/cat.jpg"]
|
31 |
+
]
|
32 |
+
|
33 |
+
iface = gr.Interface(
|
34 |
+
fn=classify_pet,
|
35 |
+
inputs=gr.Image(type="filepath"),
|
36 |
+
outputs=gr.JSON(),
|
37 |
+
title="Pet Classification Comparison",
|
38 |
+
description="Upload an image of a pet, and compare results from a trained ViT model and a zero-shot CLIP model.",
|
39 |
+
examples=example_images
|
40 |
+
)
|
41 |
+
|
42 |
+
iface.launch()
|
example_images/cat.jpg
ADDED
![]() |
Git LFS Details
|
example_images/dog1.jpeg
ADDED
![]() |
example_images/dog2.jpeg
ADDED
![]() |
Git LFS Details
|
example_images/leonberger.jpg
ADDED
![]() |
Git LFS Details
|
example_images/snow_leopard.jpeg
ADDED
![]() |
Git LFS Details
|
requierements.txt
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
absl-py==2.1.0
|
2 |
+
accelerate==1.5.2
|
3 |
+
aiohappyeyeballs==2.6.1
|
4 |
+
aiohttp==3.11.14
|
5 |
+
aiosignal==1.3.2
|
6 |
+
annotated-types==0.7.0
|
7 |
+
anyio==4.9.0
|
8 |
+
argon2-cffi==23.1.0
|
9 |
+
argon2-cffi-bindings==21.2.0
|
10 |
+
arrow==1.3.0
|
11 |
+
asttokens==3.0.0
|
12 |
+
async-lru==2.0.5
|
13 |
+
async-timeout==5.0.1
|
14 |
+
attrs==25.3.0
|
15 |
+
babel==2.17.0
|
16 |
+
backoff==2.2.1
|
17 |
+
beautifulsoup4==4.13.3
|
18 |
+
bleach==6.2.0
|
19 |
+
boto3==1.37.16
|
20 |
+
botocore==1.37.16
|
21 |
+
cachetools==5.5.2
|
22 |
+
certifi==2025.1.31
|
23 |
+
cffi==1.17.1
|
24 |
+
charset-normalizer==3.4.1
|
25 |
+
click==8.1.8
|
26 |
+
comm==0.2.2
|
27 |
+
contourpy==1.3.1
|
28 |
+
cycler==0.12.1
|
29 |
+
datasets==3.4.1
|
30 |
+
debugpy==1.8.13
|
31 |
+
decorator==5.2.1
|
32 |
+
defusedxml==0.7.1
|
33 |
+
dill==0.3.8
|
34 |
+
docker==7.1.0
|
35 |
+
evaluate==0.4.3
|
36 |
+
exceptiongroup==1.2.2
|
37 |
+
executing==2.2.0
|
38 |
+
fastapi==0.115.11
|
39 |
+
fastjsonschema==2.21.1
|
40 |
+
filelock==3.18.0
|
41 |
+
fonttools==4.56.0
|
42 |
+
fqdn==1.5.1
|
43 |
+
frozenlist==1.5.0
|
44 |
+
fsspec==2024.12.0
|
45 |
+
google-auth==2.38.0
|
46 |
+
google-auth-oauthlib==1.2.1
|
47 |
+
grpcio==1.71.0
|
48 |
+
h11==0.14.0
|
49 |
+
httpcore==1.0.7
|
50 |
+
httptools==0.6.4
|
51 |
+
httpx==0.28.1
|
52 |
+
huggingface-hub==0.29.3
|
53 |
+
idna==3.10
|
54 |
+
ipykernel==6.26.0
|
55 |
+
ipython==8.17.2
|
56 |
+
ipywidgets==8.1.1
|
57 |
+
isoduration==20.11.0
|
58 |
+
jedi==0.19.2
|
59 |
+
Jinja2==3.1.6
|
60 |
+
jmespath==1.0.1
|
61 |
+
joblib==1.4.2
|
62 |
+
json5==0.10.0
|
63 |
+
jsonpointer==3.0.0
|
64 |
+
jsonschema==4.23.0
|
65 |
+
jsonschema-specifications==2024.10.1
|
66 |
+
jupyter-events==0.12.0
|
67 |
+
jupyter-lsp==2.2.5
|
68 |
+
jupyter_client==8.6.3
|
69 |
+
jupyter_core==5.7.2
|
70 |
+
jupyter_server==2.15.0
|
71 |
+
jupyter_server_terminals==0.5.3
|
72 |
+
jupyterlab==4.2.0
|
73 |
+
jupyterlab_pygments==0.3.0
|
74 |
+
jupyterlab_server==2.27.3
|
75 |
+
jupyterlab_widgets==3.0.13
|
76 |
+
kiwisolver==1.4.8
|
77 |
+
lightning==2.5.1
|
78 |
+
lightning-cloud==0.5.70
|
79 |
+
lightning-utilities==0.14.2
|
80 |
+
lightning_sdk==0.2.4
|
81 |
+
litdata==0.2.32
|
82 |
+
litserve==0.2.6
|
83 |
+
Markdown==3.7
|
84 |
+
markdown-it-py==3.0.0
|
85 |
+
MarkupSafe==3.0.2
|
86 |
+
matplotlib==3.8.2
|
87 |
+
matplotlib-inline==0.1.7
|
88 |
+
mdurl==0.1.2
|
89 |
+
mistune==3.1.3
|
90 |
+
mpmath==1.3.0
|
91 |
+
multidict==6.2.0
|
92 |
+
multiprocess==0.70.16
|
93 |
+
nbclient==0.10.2
|
94 |
+
nbconvert==7.16.6
|
95 |
+
nbformat==5.10.4
|
96 |
+
nest-asyncio==1.6.0
|
97 |
+
networkx==3.4.2
|
98 |
+
notebook_shim==0.2.4
|
99 |
+
numpy==1.26.4
|
100 |
+
nvidia-cublas-cu12==12.4.5.8
|
101 |
+
nvidia-cuda-cupti-cu12==12.4.127
|
102 |
+
nvidia-cuda-nvrtc-cu12==12.4.127
|
103 |
+
nvidia-cuda-runtime-cu12==12.4.127
|
104 |
+
nvidia-cudnn-cu12==9.1.0.70
|
105 |
+
nvidia-cufft-cu12==11.2.1.3
|
106 |
+
nvidia-curand-cu12==10.3.5.147
|
107 |
+
nvidia-cusolver-cu12==11.6.1.9
|
108 |
+
nvidia-cusparse-cu12==12.3.1.170
|
109 |
+
nvidia-cusparselt-cu12==0.6.2
|
110 |
+
nvidia-nccl-cu12==2.21.5
|
111 |
+
nvidia-nvjitlink-cu12==12.4.127
|
112 |
+
nvidia-nvtx-cu12==12.4.127
|
113 |
+
oauthlib==3.2.2
|
114 |
+
overrides==7.7.0
|
115 |
+
packaging==24.2
|
116 |
+
pandas==2.1.4
|
117 |
+
pandocfilters==1.5.1
|
118 |
+
parso==0.8.4
|
119 |
+
pexpect==4.9.0
|
120 |
+
pillow==11.1.0
|
121 |
+
platformdirs==4.3.7
|
122 |
+
prometheus_client==0.21.1
|
123 |
+
prompt_toolkit==3.0.50
|
124 |
+
propcache==0.3.0
|
125 |
+
protobuf==4.23.4
|
126 |
+
psutil==7.0.0
|
127 |
+
ptyprocess==0.7.0
|
128 |
+
pure_eval==0.2.3
|
129 |
+
pyarrow==19.0.1
|
130 |
+
pyasn1==0.6.1
|
131 |
+
pyasn1_modules==0.4.1
|
132 |
+
pycparser==2.22
|
133 |
+
pydantic==2.10.6
|
134 |
+
pydantic_core==2.27.2
|
135 |
+
Pygments==2.19.1
|
136 |
+
PyJWT==2.10.1
|
137 |
+
pyparsing==3.2.1
|
138 |
+
python-dateutil==2.9.0.post0
|
139 |
+
python-dotenv==1.0.1
|
140 |
+
python-json-logger==3.3.0
|
141 |
+
python-multipart==0.0.20
|
142 |
+
pytorch-lightning==2.5.1
|
143 |
+
pytz==2025.1
|
144 |
+
PyYAML==6.0.2
|
145 |
+
pyzmq==26.3.0
|
146 |
+
referencing==0.36.2
|
147 |
+
regex==2024.11.6
|
148 |
+
requests==2.32.3
|
149 |
+
requests-oauthlib==2.0.0
|
150 |
+
rfc3339-validator==0.1.4
|
151 |
+
rfc3986-validator==0.1.1
|
152 |
+
rich==13.9.4
|
153 |
+
rpds-py==0.23.1
|
154 |
+
rsa==4.9
|
155 |
+
s3transfer==0.11.4
|
156 |
+
safetensors==0.5.3
|
157 |
+
scikit-learn==1.3.2
|
158 |
+
scipy==1.11.4
|
159 |
+
Send2Trash==1.8.3
|
160 |
+
simple-term-menu==1.6.6
|
161 |
+
six==1.17.0
|
162 |
+
sniffio==1.3.1
|
163 |
+
soupsieve==2.6
|
164 |
+
stack-data==0.6.3
|
165 |
+
starlette==0.46.1
|
166 |
+
sympy==1.13.1
|
167 |
+
tensorboard==2.15.1
|
168 |
+
tensorboard-data-server==0.7.2
|
169 |
+
terminado==0.18.1
|
170 |
+
threadpoolctl==3.6.0
|
171 |
+
tinycss2==1.4.0
|
172 |
+
tokenizers==0.21.1
|
173 |
+
tomli==2.2.1
|
174 |
+
torch==2.6.0
|
175 |
+
torchaudio==2.6.0
|
176 |
+
torchmetrics==1.3.1
|
177 |
+
torchvision==0.21.0
|
178 |
+
tornado==6.4.2
|
179 |
+
tqdm==4.67.1
|
180 |
+
traitlets==5.14.3
|
181 |
+
transformers==4.50.0
|
182 |
+
triton==3.2.0
|
183 |
+
types-python-dateutil==2.9.0.20241206
|
184 |
+
typing_extensions==4.12.2
|
185 |
+
tzdata==2025.1
|
186 |
+
uri-template==1.3.0
|
187 |
+
urllib3==2.3.0
|
188 |
+
uvicorn==0.34.0
|
189 |
+
uvloop==0.21.0
|
190 |
+
watchfiles==1.0.4
|
191 |
+
wcwidth==0.2.13
|
192 |
+
webcolors==24.11.1
|
193 |
+
webencodings==0.5.1
|
194 |
+
websocket-client==1.8.0
|
195 |
+
websockets==15.0.1
|
196 |
+
Werkzeug==3.1.3
|
197 |
+
wget==3.2
|
198 |
+
widgetsnbextension==4.0.13
|
199 |
+
xxhash==3.5.0
|
200 |
+
yarl==1.18.3
|
transfer_learning_image_classification.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|