sachin6624 commited on
Commit
40d1897
·
verified ·
1 Parent(s): 3320dcf

Upload 3 files

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. MobileNet-V2-Cats-Dogs.keras +3 -0
  3. app.py +30 -0
  4. requirements.txt +77 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ MobileNet-V2-Cats-Dogs.keras filter=lfs diff=lfs merge=lfs -text
MobileNet-V2-Cats-Dogs.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:66e2cb8f4a8447ddb97c4190f5adcb61e34c6d5510e950f26c07f04d960c3f06
3
+ size 9644322
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ new_model = tf.keras.models.load_model("./MobileNet-V2-Cats-Dogs.keras")
7
+
8
+ def image_classifier(inp):
9
+
10
+ # Convert PIL image to TensorFlow tensor
11
+ img = tf.convert_to_tensor(inp, dtype=tf.float32)
12
+
13
+ # Resize the image
14
+ img = tf.image.resize(img, (160,160))
15
+
16
+
17
+
18
+ out = new_model.predict(tf.expand_dims(img,0)).flatten()
19
+ predictions = tf.where(out < 0.5, 0, 1)
20
+ predictions = tf.squeeze(predictions)
21
+
22
+ print("The out : ", out[0])
23
+ if out[0] > 0.5 :
24
+ return {'dog': 1}
25
+ else:
26
+ return {'cat': 1}
27
+
28
+
29
+ demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label")
30
+ demo.launch(debug=True)
requirements.txt ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==2.3.0
2
+ aiofiles==24.1.0
3
+ annotated-types==0.7.0
4
+ anyio==4.9.0
5
+ astunparse==1.6.3
6
+ certifi==2025.6.15
7
+ charset-normalizer==3.4.2
8
+ click==8.2.1
9
+ fastapi==0.115.14
10
+ ffmpy==0.6.0
11
+ filelock==3.18.0
12
+ flatbuffers==25.2.10
13
+ fsspec==2025.5.1
14
+ gast==0.6.0
15
+ google-pasta==0.2.0
16
+ gradio==5.35.0
17
+ gradio_client==1.10.4
18
+ groovy==0.1.2
19
+ grpcio==1.73.1
20
+ h11==0.16.0
21
+ h5py==3.14.0
22
+ hf-xet==1.1.5
23
+ httpcore==1.0.9
24
+ httpx==0.28.1
25
+ huggingface-hub==0.33.1
26
+ idna==3.10
27
+ Jinja2==3.1.6
28
+ keras==3.10.0
29
+ libclang==18.1.1
30
+ Markdown==3.8.2
31
+ markdown-it-py==3.0.0
32
+ MarkupSafe==3.0.2
33
+ mdurl==0.1.2
34
+ ml_dtypes==0.5.1
35
+ namex==0.1.0
36
+ numpy==2.1.3
37
+ opt_einsum==3.4.0
38
+ optree==0.16.0
39
+ orjson==3.10.18
40
+ packaging==25.0
41
+ pandas==2.3.0
42
+ pillow==11.2.1
43
+ protobuf==5.29.5
44
+ pydantic==2.11.7
45
+ pydantic_core==2.33.2
46
+ pydub==0.25.1
47
+ Pygments==2.19.2
48
+ python-dateutil==2.9.0.post0
49
+ python-multipart==0.0.20
50
+ pytz==2025.2
51
+ PyYAML==6.0.2
52
+ requests==2.32.4
53
+ rich==14.0.0
54
+ ruff==0.12.1
55
+ safehttpx==0.1.6
56
+ semantic-version==2.10.0
57
+ setuptools==80.9.0
58
+ shellingham==1.5.4
59
+ six==1.17.0
60
+ sniffio==1.3.1
61
+ starlette==0.46.2
62
+ tensorboard==2.19.0
63
+ tensorboard-data-server==0.7.2
64
+ tensorflow==2.19.0
65
+ termcolor==3.1.0
66
+ tomlkit==0.13.3
67
+ tqdm==4.67.1
68
+ typer==0.16.0
69
+ typing-inspection==0.4.1
70
+ typing_extensions==4.14.0
71
+ tzdata==2025.2
72
+ urllib3==2.5.0
73
+ uvicorn==0.35.0
74
+ websockets==15.0.1
75
+ Werkzeug==3.1.3
76
+ wheel==0.45.1
77
+ wrapt==1.17.2