zihaoz96 commited on
Commit
3f3da6d
1 Parent(s): 42fa709
.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Shark Classifier Mobilenet_v2
3
+ emoji: 🦈
4
+ colorFrom: indigo
5
+ colorTo: green
6
+ sdk: gradio
7
+ app_file: app.py
8
+ pinned: false
9
+ ---
10
+
11
+ # Configuration
12
+
13
+ `title`: _string_
14
+ Display title for the Space
15
+
16
+ `emoji`: _string_
17
+ Space emoji (emoji-only character allowed)
18
+
19
+ `colorFrom`: _string_
20
+ Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
21
+
22
+ `colorTo`: _string_
23
+ Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
24
+
25
+ `sdk`: _string_
26
+ Can be either `gradio` or `streamlit`
27
+
28
+ `sdk_version` : _string_
29
+ Only applicable for `streamlit` SDK.
30
+ See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
31
+
32
+ `app_file`: _string_
33
+ Path to your main application file (which contains either `gradio` or `streamlit` Python code).
34
+ Path is relative to the root of the repository.
35
+
36
+ `pinned`: _boolean_
37
+ Whether the Space stays on top of your list.
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ import pandas as pd
4
+ from tensorflow.keras import models
5
+
6
+ import tensorflow as tf
7
+
8
+ # open categories.txt in read mode
9
+ categories = open("categories.txt", "r")
10
+ labels = categories.readline().split(";")
11
+
12
+ model = models.load_model('models/modelnet/best_model.h5')
13
+
14
+
15
+ def predict_image(image):
16
+ image = np.array(image) / 255
17
+ image = np.expand_dims(image, axis=0)
18
+
19
+ pred = model.predict(image)
20
+
21
+ acc = dict((labels[i], "%.2f" % pred[0][i]) for i in range(len(labels)))
22
+ print(acc)
23
+ return acc
24
+
25
+
26
+ image = gr.inputs.Image(shape=(224, 224), label="Upload Your Image Here")
27
+ label = gr.outputs.Label(num_top_classes=len(labels))
28
+
29
+ samples = ['samples/basking.jpg', 'samples/blacktip.jpg', 'samples/blue.jpg', 'samples/bull.jpg', 'samples/hammerhead.jpg',
30
+ 'samples/lemon.jpg', 'samples/mako.jpg', 'samples/nurse.jpg', 'samples/sand tiger.jpg', 'samples/thresher.jpg',
31
+ 'samples/tigre.jpg', 'samples/whale.jpg', 'samples/white.jpg', 'samples/whitetip.jpg']
32
+
33
+ interface = gr.Interface(
34
+ fn=predict_image,
35
+ inputs=image,
36
+ outputs=label,
37
+ capture_session=True,
38
+ allow_flagging=False,
39
+ examples=samples
40
+ )
41
+ interface.launch()
categories.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ basking;blacktip;blue;bull;hammerhead;lemon;mako;nurse;sand tiger;thresher;tiger;whale;white;whitetip
requirements.txt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ gradio
2
+ torch
3
+ torchvision
4
+ Pillow
5
+ gdown
6
+ numpy
7
+ scipy
8
+ cmake
9
+ onnxruntime-gpu
10
+ opencv-python-headless
11
+ encoded-video
12
+ hugsvision
13
+ tensorflow
samples/basking.jpg ADDED
samples/blacktip.jpg ADDED
samples/blue.jpg ADDED
samples/bull.jpg ADDED
samples/hammerhead.jpg ADDED
samples/lemon.jpg ADDED
samples/mako.jpg ADDED
samples/nurse.jpg ADDED
samples/sand tiger.jpg ADDED
samples/thresher.jpg ADDED
samples/tigre.jpg ADDED
samples/whale.jpg ADDED
samples/white.jpg ADDED
samples/whitetip.jpg ADDED