chun
commited on
Commit
•
bcfc921
1
Parent(s):
f83714c
Upload 8 files
Browse files- a01.jpg +0 -0
- a02.jpg +0 -0
- a03.jpg +0 -0
- a04.jpg +0 -0
- app.py +40 -0
- cats&dog.h5 +3 -0
- img.png +0 -0
- requirements.txt +90 -0
a01.jpg
ADDED
![]() |
a02.jpg
ADDED
![]() |
a03.jpg
ADDED
![]() |
a04.jpg
ADDED
![]() |
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from keras.models import load_model
|
2 |
+
import numpy as np
|
3 |
+
from keras.preprocessing import image
|
4 |
+
import gradio as gr
|
5 |
+
from PIL import Image
|
6 |
+
|
7 |
+
def a(img):
|
8 |
+
#img = img.reshape(1, 64, 64,3)
|
9 |
+
#img = img.reshape( 64, 64,3)
|
10 |
+
model=load_model('./cats&dog.h5')
|
11 |
+
#test_image=image.load_img("pic01.jpg",target_size=(64,64))
|
12 |
+
test_image=image.img_to_array(img)
|
13 |
+
test_image=np.expand_dims(test_image, axis=0)
|
14 |
+
result=model.predict(test_image)
|
15 |
+
if result[0][0]==1:
|
16 |
+
prediction='Dog'
|
17 |
+
print(prediction)
|
18 |
+
return prediction
|
19 |
+
else:
|
20 |
+
prediction='Cat'
|
21 |
+
print(prediction)
|
22 |
+
return prediction
|
23 |
+
|
24 |
+
|
25 |
+
input = gr.inputs.Image(type='pil', label="Original Image", source="upload", optional=True)
|
26 |
+
#input_2 = gr.inputs.Image(type='pil', label="Original Image", source="webcam", optional=True)
|
27 |
+
#inputs = [input, input_2]
|
28 |
+
inputs = [input]
|
29 |
+
outputs = gr.outputs.Image(type="pil", label="Output Image")
|
30 |
+
title = "Dog and Cat Object detection"
|
31 |
+
|
32 |
+
demo=gr.Interface(a,
|
33 |
+
inputs,
|
34 |
+
outputs,
|
35 |
+
title=title,
|
36 |
+
examples=["a01.jpg", "a02.jpg","a03.jpg","a04.jpg"],
|
37 |
+
theme="huggingface").launch(enable_queue=True)
|
38 |
+
|
39 |
+
if __name__ == "__main__":
|
40 |
+
demo.launch()
|
cats&dog.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:663f04cce565132efb471b4f5b8262483d497055dad55e0b285e1247b29ab818
|
3 |
+
size 9793864
|
img.png
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
absl-py==1.4.0
|
2 |
+
aiofiles==23.2.1
|
3 |
+
altair==5.1.1
|
4 |
+
annotated-types==0.5.0
|
5 |
+
anyio==3.7.1
|
6 |
+
astunparse==1.6.3
|
7 |
+
attrs==23.1.0
|
8 |
+
cachetools==5.3.1
|
9 |
+
certifi==2023.7.22
|
10 |
+
charset-normalizer==3.2.0
|
11 |
+
click==8.1.7
|
12 |
+
colorama==0.4.6
|
13 |
+
contourpy==1.1.1
|
14 |
+
cycler==0.11.0
|
15 |
+
exceptiongroup==1.1.3
|
16 |
+
fastapi==0.103.1
|
17 |
+
ffmpy==0.3.1
|
18 |
+
filelock==3.12.4
|
19 |
+
flatbuffers==23.5.26
|
20 |
+
fonttools==4.42.1
|
21 |
+
fsspec==2023.9.1
|
22 |
+
gast==0.4.0
|
23 |
+
google-auth==2.23.0
|
24 |
+
google-auth-oauthlib==1.0.0
|
25 |
+
google-pasta==0.2.0
|
26 |
+
gradio==3.44.3
|
27 |
+
gradio_client==0.5.0
|
28 |
+
grpcio==1.58.0
|
29 |
+
h11==0.14.0
|
30 |
+
h5py==3.9.0
|
31 |
+
httpcore==0.18.0
|
32 |
+
httpx==0.25.0
|
33 |
+
huggingface-hub==0.17.2
|
34 |
+
idna==3.4
|
35 |
+
importlib-metadata==6.8.0
|
36 |
+
importlib-resources==6.0.1
|
37 |
+
Jinja2==3.1.2
|
38 |
+
jsonschema==4.19.0
|
39 |
+
jsonschema-specifications==2023.7.1
|
40 |
+
keras==2.13.1
|
41 |
+
Keras-Preprocessing==1.1.2
|
42 |
+
kiwisolver==1.4.5
|
43 |
+
libclang==16.0.6
|
44 |
+
Markdown==3.4.4
|
45 |
+
MarkupSafe==2.1.3
|
46 |
+
matplotlib==3.8.0
|
47 |
+
numpy==1.24.3
|
48 |
+
oauthlib==3.2.2
|
49 |
+
opt-einsum==3.3.0
|
50 |
+
orjson==3.9.7
|
51 |
+
packaging==23.1
|
52 |
+
pandas==2.1.0
|
53 |
+
Pillow==10.0.1
|
54 |
+
protobuf==4.24.3
|
55 |
+
pyasn1==0.5.0
|
56 |
+
pyasn1-modules==0.3.0
|
57 |
+
pydantic==2.3.0
|
58 |
+
pydantic_core==2.6.3
|
59 |
+
pydub==0.25.1
|
60 |
+
pyparsing==3.1.1
|
61 |
+
python-dateutil==2.8.2
|
62 |
+
python-multipart==0.0.6
|
63 |
+
pytz==2023.3.post1
|
64 |
+
PyYAML==6.0.1
|
65 |
+
referencing==0.30.2
|
66 |
+
requests==2.31.0
|
67 |
+
requests-oauthlib==1.3.1
|
68 |
+
rpds-py==0.10.3
|
69 |
+
rsa==4.9
|
70 |
+
semantic-version==2.10.0
|
71 |
+
six==1.16.0
|
72 |
+
sniffio==1.3.0
|
73 |
+
starlette==0.27.0
|
74 |
+
tensorboard==2.13.0
|
75 |
+
tensorboard-data-server==0.7.1
|
76 |
+
tensorflow==2.13.0
|
77 |
+
tensorflow-estimator==2.13.0
|
78 |
+
tensorflow-intel==2.13.0
|
79 |
+
tensorflow-io-gcs-filesystem==0.31.0
|
80 |
+
termcolor==2.3.0
|
81 |
+
toolz==0.12.0
|
82 |
+
tqdm==4.66.1
|
83 |
+
typing_extensions==4.8.0
|
84 |
+
tzdata==2023.3
|
85 |
+
urllib3==1.26.16
|
86 |
+
uvicorn==0.23.2
|
87 |
+
websockets==11.0.3
|
88 |
+
Werkzeug==2.3.7
|
89 |
+
wrapt==1.15.0
|
90 |
+
zipp==3.17.0
|