Theodor commited on
Commit
362755a
·
1 Parent(s): 2825edb
.DS_Store ADDED
Binary file (6.15 kB). View file
 
.idea/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
.idea/.name ADDED
@@ -0,0 +1 @@
 
 
1
+ dogsVScats
.idea/dogsVScats.iml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
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
+ <excludeFolder url="file://$MODULE_DIR$/venv" />
6
+ </content>
7
+ <orderEntry type="inheritedJdk" />
8
+ <orderEntry type="sourceFolder" forTests="false" />
9
+ </component>
10
+ </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 (lesson2)" 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/dogsVScats.iml" filepath="$PROJECT_DIR$/.idea/dogsVScats.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ <mapping directory="$PROJECT_DIR$/dogsVScats" vcs="Git" />
6
+ </component>
7
+ </project>
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = ["is_cat", "learn", "classify_image", "categories", "image", "label", "examples", "intf"]
2
+
3
+ from fastai.vision.all import *
4
+ import gradio as gr
5
+
6
+
7
+ def is_cat(x): return x[0].isupper()
8
+
9
+
10
+ learn = load_learner("model.pkl")
11
+ categories = ("Dog", "Cat")
12
+
13
+
14
+ def classify_image(img):
15
+ pred, idx, probs = learn.predict(img)
16
+ return dict(zip(categories, map(float, probs)))
17
+
18
+
19
+ image = gr.inputs.Image(shape=(192, 192))
20
+ label = gr.outputs.Label()
21
+ examples = ["dog.jpg", "cat.jpg", "dunno.jpg"]
22
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
23
+ intf.launch(inline=False)
cat.jpg ADDED
dog.jpg ADDED
dogsVScats/.DS_Store ADDED
Binary file (6.15 kB). View file
 
dunno.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:babc28f71785a1bcc138d70bbf6d92145e4794f11fee587f664311e0c348ca57
3
+ size 47061483