Spaces:
Sleeping
Sleeping
Commit ·
b58acd3
1
Parent(s): 6f68034
app building, first gui
Browse files- .gitignore +1 -0
- app.py +33 -4
- notebooks/app.py/app.py +36 -0
- notebooks/assets/cat.png +0 -0
- notebooks/assets/dog.png +0 -0
- notebooks/assets/feline_bulldog.png +0 -0
- notebooks/assets/model_dogs_cats.pkl +3 -0
- notebooks/dogs_vs_cats.ipynb +0 -0
- requirements.txt +133 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
/venv2
|
app.py
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../dogs_vs_cats.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['temp', 'learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
|
| 5 |
+
|
| 6 |
+
# %% ../dogs_vs_cats.ipynb 1
|
| 7 |
+
from fastai.vision.all import *
|
| 8 |
import gradio as gr
|
| 9 |
|
| 10 |
+
def is_cat(x): return x[0].isupper()
|
| 11 |
+
|
| 12 |
+
# %% ../dogs_vs_cats.ipynb 4
|
| 13 |
+
import pathlib
|
| 14 |
+
temp = pathlib.PosixPath
|
| 15 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
| 16 |
+
|
| 17 |
+
# %% ../dogs_vs_cats.ipynb 5
|
| 18 |
+
learn = load_learner('./assets/model_dogs_cats.pkl')
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# %% ../dogs_vs_cats.ipynb 9
|
| 22 |
+
categories:list = ('Dog', 'Cat')
|
| 23 |
+
|
| 24 |
+
def classify_image(img):
|
| 25 |
+
pred, idx, probs = learn.predict(img)
|
| 26 |
+
return dict(zip(categories, map(float, probs)))
|
| 27 |
+
|
| 28 |
+
# %% ../dogs_vs_cats.ipynb 12
|
| 29 |
+
# creating the gradio interface
|
| 30 |
+
|
| 31 |
+
image = gr.Image(height=192, width=192)
|
| 32 |
+
label = gr.Label()
|
| 33 |
+
examples:list = ['./assets/dog.png', './assets/cat.png', './assets/feline_bulldog.png']
|
| 34 |
|
| 35 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 36 |
+
intf.launch(inline=False)
|
notebooks/app.py/app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../dogs_vs_cats.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['temp', 'learn', 'categories', 'image', 'label', 'examples', 'intf', 'is_cat', 'classify_image']
|
| 5 |
+
|
| 6 |
+
# %% ../dogs_vs_cats.ipynb 1
|
| 7 |
+
from fastai.vision.all import *
|
| 8 |
+
import gradio as gr
|
| 9 |
+
|
| 10 |
+
def is_cat(x): return x[0].isupper()
|
| 11 |
+
|
| 12 |
+
# %% ../dogs_vs_cats.ipynb 4
|
| 13 |
+
import pathlib
|
| 14 |
+
temp = pathlib.PosixPath
|
| 15 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
| 16 |
+
|
| 17 |
+
# %% ../dogs_vs_cats.ipynb 5
|
| 18 |
+
learn = load_learner('./assets/model_dogs_cats.pkl')
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# %% ../dogs_vs_cats.ipynb 9
|
| 22 |
+
categories:list = ('Dog', 'Cat')
|
| 23 |
+
|
| 24 |
+
def classify_image(img):
|
| 25 |
+
pred, idx, probs = learn.predict(img)
|
| 26 |
+
return dict(zip(categories, map(float, probs)))
|
| 27 |
+
|
| 28 |
+
# %% ../dogs_vs_cats.ipynb 12
|
| 29 |
+
# creating the gradio interface
|
| 30 |
+
|
| 31 |
+
image = gr.Image(height=192, width=192)
|
| 32 |
+
label = gr.Label()
|
| 33 |
+
examples:list = ['./assets/dog.png', './assets/cat.png', './assets/feline_bulldog.png']
|
| 34 |
+
|
| 35 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 36 |
+
intf.launch(inline=False)
|
notebooks/assets/cat.png
ADDED
|
notebooks/assets/dog.png
ADDED
|
notebooks/assets/feline_bulldog.png
ADDED
|
notebooks/assets/model_dogs_cats.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1c09d8f778f89c9eb588eefd9a5ba094eb163cd3ea708a4ea567a83e924f149f
|
| 3 |
+
size 47059947
|
notebooks/dogs_vs_cats.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiofiles==23.2.1
|
| 2 |
+
annotated-types==0.7.0
|
| 3 |
+
anyio==4.4.0
|
| 4 |
+
asttokens==2.4.1
|
| 5 |
+
astunparse==1.6.3
|
| 6 |
+
blis==0.7.11
|
| 7 |
+
catalogue==2.0.10
|
| 8 |
+
certifi==2024.7.4
|
| 9 |
+
charset-normalizer==3.3.2
|
| 10 |
+
click==8.1.7
|
| 11 |
+
cloudpathlib==0.18.1
|
| 12 |
+
colorama==0.4.6
|
| 13 |
+
comm==0.2.2
|
| 14 |
+
confection==0.1.5
|
| 15 |
+
contourpy==1.2.1
|
| 16 |
+
cycler==0.12.1
|
| 17 |
+
cymem==2.0.8
|
| 18 |
+
debugpy==1.8.2
|
| 19 |
+
decorator==5.1.1
|
| 20 |
+
dnspython==2.6.1
|
| 21 |
+
email_validator==2.2.0
|
| 22 |
+
execnb==0.1.6
|
| 23 |
+
executing==2.0.1
|
| 24 |
+
fastai==2.7.15
|
| 25 |
+
fastapi==0.111.1
|
| 26 |
+
fastapi-cli==0.0.4
|
| 27 |
+
fastcore==1.5.55
|
| 28 |
+
fastdownload==0.0.7
|
| 29 |
+
fastprogress==1.0.3
|
| 30 |
+
ffmpy==0.3.2
|
| 31 |
+
filelock==3.15.4
|
| 32 |
+
fonttools==4.53.1
|
| 33 |
+
fsspec==2024.6.1
|
| 34 |
+
ghapi==1.0.5
|
| 35 |
+
gradio==4.39.0
|
| 36 |
+
gradio_client==1.1.1
|
| 37 |
+
h11==0.14.0
|
| 38 |
+
httpcore==1.0.5
|
| 39 |
+
httptools==0.6.1
|
| 40 |
+
httpx==0.27.0
|
| 41 |
+
huggingface-hub==0.24.2
|
| 42 |
+
idna==3.7
|
| 43 |
+
importlib_resources==6.4.0
|
| 44 |
+
intel-openmp==2021.4.0
|
| 45 |
+
ipykernel==6.29.5
|
| 46 |
+
ipython==8.26.0
|
| 47 |
+
ipywidgets==8.1.3
|
| 48 |
+
jedi==0.19.1
|
| 49 |
+
Jinja2==3.1.4
|
| 50 |
+
joblib==1.4.2
|
| 51 |
+
jupyter_client==8.6.2
|
| 52 |
+
jupyter_core==5.7.2
|
| 53 |
+
jupyterlab_widgets==3.0.11
|
| 54 |
+
kiwisolver==1.4.5
|
| 55 |
+
langcodes==3.4.0
|
| 56 |
+
language_data==1.2.0
|
| 57 |
+
marisa-trie==1.2.0
|
| 58 |
+
markdown-it-py==3.0.0
|
| 59 |
+
MarkupSafe==2.1.5
|
| 60 |
+
matplotlib==3.9.1
|
| 61 |
+
matplotlib-inline==0.1.7
|
| 62 |
+
mdurl==0.1.2
|
| 63 |
+
mkl==2021.4.0
|
| 64 |
+
mpmath==1.3.0
|
| 65 |
+
murmurhash==1.0.10
|
| 66 |
+
nbdev==2.3.26
|
| 67 |
+
nest-asyncio==1.6.0
|
| 68 |
+
networkx==3.3
|
| 69 |
+
numpy==1.26.4
|
| 70 |
+
orjson==3.10.6
|
| 71 |
+
packaging==24.1
|
| 72 |
+
pandas==2.2.2
|
| 73 |
+
parso==0.8.4
|
| 74 |
+
pillow==10.4.0
|
| 75 |
+
platformdirs==4.2.2
|
| 76 |
+
preshed==3.0.9
|
| 77 |
+
prompt_toolkit==3.0.47
|
| 78 |
+
psutil==6.0.0
|
| 79 |
+
pure_eval==0.2.3
|
| 80 |
+
pydantic==2.8.2
|
| 81 |
+
pydantic_core==2.20.1
|
| 82 |
+
pydub==0.25.1
|
| 83 |
+
Pygments==2.18.0
|
| 84 |
+
pyparsing==3.1.2
|
| 85 |
+
python-dateutil==2.9.0.post0
|
| 86 |
+
python-dotenv==1.0.1
|
| 87 |
+
python-multipart==0.0.9
|
| 88 |
+
pytz==2024.1
|
| 89 |
+
pywin32==306
|
| 90 |
+
PyYAML==6.0.1
|
| 91 |
+
pyzmq==26.0.3
|
| 92 |
+
requests==2.32.3
|
| 93 |
+
rich==13.7.1
|
| 94 |
+
ruff==0.5.5
|
| 95 |
+
scikit-learn==1.5.1
|
| 96 |
+
scipy==1.14.0
|
| 97 |
+
seaborn==0.13.2
|
| 98 |
+
semantic-version==2.10.0
|
| 99 |
+
setuptools==71.1.0
|
| 100 |
+
shellingham==1.5.4
|
| 101 |
+
six==1.16.0
|
| 102 |
+
smart-open==7.0.4
|
| 103 |
+
sniffio==1.3.1
|
| 104 |
+
spacy==3.7.5
|
| 105 |
+
spacy-legacy==3.0.12
|
| 106 |
+
spacy-loggers==1.0.5
|
| 107 |
+
srsly==2.4.8
|
| 108 |
+
stack-data==0.6.3
|
| 109 |
+
starlette==0.37.2
|
| 110 |
+
sympy==1.13.1
|
| 111 |
+
tbb==2021.13.0
|
| 112 |
+
thinc==8.2.5
|
| 113 |
+
threadpoolctl==3.5.0
|
| 114 |
+
tomlkit==0.12.0
|
| 115 |
+
torch==2.3.1
|
| 116 |
+
torchvision==0.18.1
|
| 117 |
+
tornado==6.4.1
|
| 118 |
+
tqdm==4.66.4
|
| 119 |
+
traitlets==5.14.3
|
| 120 |
+
typer==0.12.3
|
| 121 |
+
typing_extensions==4.12.2
|
| 122 |
+
tzdata==2024.1
|
| 123 |
+
urllib3==2.2.2
|
| 124 |
+
uvicorn==0.30.3
|
| 125 |
+
wasabi==1.1.3
|
| 126 |
+
watchdog==4.0.1
|
| 127 |
+
watchfiles==0.22.0
|
| 128 |
+
wcwidth==0.2.13
|
| 129 |
+
weasel==0.4.1
|
| 130 |
+
websockets==11.0.3
|
| 131 |
+
wheel==0.43.0
|
| 132 |
+
widgetsnbextension==4.0.11
|
| 133 |
+
wrapt==1.16.0
|