Spaces:
Runtime error
Runtime error
final script
Browse files- app.py +20 -4
- cat.jpg +0 -0
- cat_vs_dog_app.ipynb +62 -0
- dog.jpg +0 -0
- model.pkl +3 -0
- requirements.txt +0 -0
app.py
CHANGED
@@ -1,7 +1,23 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#|export
|
2 |
+
from fastai.vision.all import *
|
3 |
import gradio as gr
|
4 |
+
from fastbook import *
|
5 |
|
6 |
+
def is_cat(x): return x[0].isupper()
|
|
|
7 |
|
8 |
+
#|export
|
9 |
+
learn = load_learner('model.pkl')
|
10 |
+
|
11 |
+
#|export
|
12 |
+
categories = ('Dog', 'Cat')
|
13 |
+
|
14 |
+
def classify_image(im):
|
15 |
+
pred, idx, probs = learn.predict(im)
|
16 |
+
return dict(zip(categories, map(float, probs)))
|
17 |
+
|
18 |
+
#|export
|
19 |
+
categories = ('Dog', 'Cat')
|
20 |
+
|
21 |
+
def classify_image(im):
|
22 |
+
pred, idx, probs = learn.predict(im)
|
23 |
+
return dict(zip(categories, map(float, probs)))
|
cat.jpg
ADDED
![]() |
cat_vs_dog_app.ipynb
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 3,
|
6 |
+
"id": "663730d7",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [
|
9 |
+
{
|
10 |
+
"ename": "ModuleNotFoundError",
|
11 |
+
"evalue": "No module named 'gradio'",
|
12 |
+
"output_type": "error",
|
13 |
+
"traceback": [
|
14 |
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
15 |
+
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
|
16 |
+
"Input \u001b[1;32mIn [3]\u001b[0m, in \u001b[0;36m<cell line: 3>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m#|\u001b[39;00m\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mfastai\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mvision\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mall\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;241m*\u001b[39m\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mgradio\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mgr\u001b[39;00m\n",
|
17 |
+
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'gradio'"
|
18 |
+
]
|
19 |
+
}
|
20 |
+
],
|
21 |
+
"source": [
|
22 |
+
"#|\n",
|
23 |
+
"from fastai.vision.all import *\n",
|
24 |
+
"import gradio as gr\n",
|
25 |
+
"\n",
|
26 |
+
"def is_cat(x): return x[0].isupper() "
|
27 |
+
]
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"cell_type": "code",
|
31 |
+
"execution_count": null,
|
32 |
+
"id": "25d8b577",
|
33 |
+
"metadata": {},
|
34 |
+
"outputs": [],
|
35 |
+
"source": [
|
36 |
+
"img = PILImage.create('dog.jpg')\n",
|
37 |
+
"img"
|
38 |
+
]
|
39 |
+
}
|
40 |
+
],
|
41 |
+
"metadata": {
|
42 |
+
"kernelspec": {
|
43 |
+
"display_name": "Python 3 (ipykernel)",
|
44 |
+
"language": "python",
|
45 |
+
"name": "python3"
|
46 |
+
},
|
47 |
+
"language_info": {
|
48 |
+
"codemirror_mode": {
|
49 |
+
"name": "ipython",
|
50 |
+
"version": 3
|
51 |
+
},
|
52 |
+
"file_extension": ".py",
|
53 |
+
"mimetype": "text/x-python",
|
54 |
+
"name": "python",
|
55 |
+
"nbconvert_exporter": "python",
|
56 |
+
"pygments_lexer": "ipython3",
|
57 |
+
"version": "3.9.12"
|
58 |
+
}
|
59 |
+
},
|
60 |
+
"nbformat": 4,
|
61 |
+
"nbformat_minor": 5
|
62 |
+
}
|
dog.jpg
ADDED
![]() |
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1c09d8f778f89c9eb588eefd9a5ba094eb163cd3ea708a4ea567a83e924f149f
|
3 |
+
size 47059947
|
requirements.txt
ADDED
File without changes
|