Spaces:
Sleeping
Sleeping
Commit
·
31fe54c
1
Parent(s):
d8c5a5c
Cats and Dogs classifier interface
Browse filesGradio interface for Cats & Dogs classifier
- .idea/.gitignore +3 -0
- .idea/Cats_and_Dogs.iml +8 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +4 -0
- .idea/modules.xml +8 -0
- .idea/vcs.xml +6 -0
- app.py +24 -0
- model.pkl +3 -0
.idea/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
.idea/Cats_and_Dogs.iml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$" />
|
5 |
+
<orderEntry type="inheritedJdk" />
|
6 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
7 |
+
</component>
|
8 |
+
</module>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
4 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/Cats_and_Dogs.iml" filepath="$PROJECT_DIR$/.idea/Cats_and_Dogs.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/vcs.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="VcsDirectoryMappings">
|
4 |
+
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
5 |
+
</component>
|
6 |
+
</project>
|
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
#__all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
3 |
+
|
4 |
+
!pip install -Uqq fastai
|
5 |
+
from fastai.vision.all import *
|
6 |
+
import gradio as gr
|
7 |
+
|
8 |
+
def is_cat(x): return x[0].isupper()
|
9 |
+
|
10 |
+
learn = load_learner('model.pkl')
|
11 |
+
|
12 |
+
categories = ('Dog', 'Cat')
|
13 |
+
|
14 |
+
def classify_image(img):
|
15 |
+
pred, idx, probs = learn.predict(img)
|
16 |
+
return(dict(zip(categories, map(float, probs)))
|
17 |
+
|
18 |
+
image = gr.inputs.Image(shape=(192, 192))
|
19 |
+
label = gr.outputs.Label()
|
20 |
+
examples = ['dog.jpg', 'cat.jpg', 'dunno.jpg']
|
21 |
+
|
22 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
23 |
+
intf.launch(inline=False)
|
24 |
+
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:735aa4051f1f09d113cd1dd1a4b4dd251c6797e06527a85d97977767887be232
|
3 |
+
size 47063121
|