Spaces:
Runtime error
Runtime error
update
Browse files- .gitattributes +0 -27
- README.md +0 -37
- app.py +0 -41
- categories.txt +0 -1
- models/VGG16.py +0 -34
- models/modelNet.py +0 -19
- models/model_v1.py +0 -47
- models/{mobilenet_v2/best_model.pth → modelnet/best_model.h5} +2 -2
- requirements.txt +0 -13
- samples/basking.jpg +0 -0
- samples/blacktip.jpg +0 -0
- samples/blue.jpg +0 -0
- samples/bull.jpg +0 -0
- samples/hammerhead.jpg +0 -0
- samples/lemon.jpg +0 -0
- samples/mako.jpg +0 -0
- samples/nurse.jpg +0 -0
- samples/sand tiger.jpg +0 -0
- samples/thresher.jpg +0 -0
- samples/tigre.jpg +0 -0
- samples/whale.jpg +0 -0
- samples/white.jpg +0 -0
- samples/whitetip.jpg +0 -0
.gitattributes
DELETED
@@ -1,27 +0,0 @@
|
|
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
DELETED
@@ -1,37 +0,0 @@
|
|
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
DELETED
@@ -1,41 +0,0 @@
|
|
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
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
basking;blacktip;blue;bull;hammerhead;lemon;mako;nurse;sand tiger;thresher;tiger;whale;white;whitetip
|
|
|
|
models/VGG16.py
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
import tensorflow as tf
|
2 |
-
from tensorflow.keras.callbacks import TensorBoard, EarlyStopping, ModelCheckpoint
|
3 |
-
from tensorflow.keras.layers import Conv2D, Dense, Flatten, GlobalMaxPooling2D
|
4 |
-
from tensorflow.keras.layers import Dense, Input, MaxPooling2D
|
5 |
-
from tensorflow.keras import Model
|
6 |
-
|
7 |
-
|
8 |
-
def VGG16(nbr_class):
|
9 |
-
# 224 224 3
|
10 |
-
img_input = Input(shape=(224,224,3))
|
11 |
-
|
12 |
-
# first convolution
|
13 |
-
x = Conv2D(64, (3,3), activation='relu', padding='same')(img_input)
|
14 |
-
x = Conv2D(64, (3,3), activation='relu', padding='same')(x)
|
15 |
-
x = MaxPooling2D((2,2), strides = (2,2))(x)
|
16 |
-
|
17 |
-
# second convolution
|
18 |
-
x = Conv2D(128, (3,3), activation='relu', padding='same')(x)
|
19 |
-
x = Conv2D(128, (3,3), activation='relu', padding='same')(x)
|
20 |
-
x = MaxPooling2D((2,2), strides = (2,2))(x)
|
21 |
-
|
22 |
-
# third convolution
|
23 |
-
x = Conv2D(256, (3,3), activation='relu', padding='same')(x)
|
24 |
-
x = Conv2D(256, (3,3), activation='relu', padding='same')(x)
|
25 |
-
x = Conv2D(256, (3,3), activation='relu', padding='same')(x)
|
26 |
-
x = MaxPooling2D((2,2), strides = (2,2))(x)
|
27 |
-
|
28 |
-
x = Flatten()(x)
|
29 |
-
x = Dense(1024, activation='relu')(x)
|
30 |
-
x = Dense(1024, activation='relu')(x)
|
31 |
-
x = Dense(nbr_class, activation='softmax')(x)
|
32 |
-
|
33 |
-
|
34 |
-
return Model(img_input, x, name="vgg16")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
models/modelNet.py
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
|
2 |
-
import tensorflow as tf
|
3 |
-
from tensorflow.keras.callbacks import TensorBoard, EarlyStopping, ModelCheckpoint
|
4 |
-
from tensorflow.keras.layers import Conv2D, Dense, GlobalMaxPooling2D
|
5 |
-
from tensorflow.keras.layers import Dense, MaxPooling2D, BatchNormalization
|
6 |
-
from tensorflow.keras.models import Sequential
|
7 |
-
from tensorflow.keras import Model
|
8 |
-
|
9 |
-
|
10 |
-
def modelNet(nbr_class):
|
11 |
-
mobile_net = tf.keras.applications.MobileNetV2(input_shape=(224,224,3), include_top=False)
|
12 |
-
mobile_net.trainable=False
|
13 |
-
|
14 |
-
model = Sequential([
|
15 |
-
mobile_net,
|
16 |
-
tf.keras.layers.GlobalAveragePooling2D(),
|
17 |
-
tf.keras.layers.Dense(nbr_class, activation = 'softmax')])
|
18 |
-
|
19 |
-
return model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
models/model_v1.py
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
|
2 |
-
import tensorflow as tf
|
3 |
-
from tensorflow.keras.callbacks import TensorBoard, EarlyStopping, ModelCheckpoint
|
4 |
-
from tensorflow.keras.layers import Conv2D, Dense, GlobalMaxPooling2D
|
5 |
-
from tensorflow.keras.layers import Dense, MaxPooling2D, BatchNormalization
|
6 |
-
from tensorflow.keras.models import Sequential
|
7 |
-
from tensorflow.keras import Model
|
8 |
-
|
9 |
-
def model_v1(nbr_class):
|
10 |
-
model = Sequential()
|
11 |
-
model.add(Conv2D(64,(3,3), activation="relu", input_shape=(224,224,3)))
|
12 |
-
model.add(BatchNormalization())
|
13 |
-
model.add(Conv2D(64,(3,3), activation="relu"))
|
14 |
-
model.add(BatchNormalization())
|
15 |
-
model.add(MaxPooling2D())
|
16 |
-
|
17 |
-
model.add(Conv2D(128,(3,3), activation="relu"))
|
18 |
-
model.add(BatchNormalization())
|
19 |
-
model.add(Conv2D(128,(3,3), activation="relu"))
|
20 |
-
model.add(BatchNormalization())
|
21 |
-
model.add(MaxPooling2D())
|
22 |
-
|
23 |
-
model.add(Conv2D(256,(3,3), activation="relu"))
|
24 |
-
model.add(BatchNormalization())
|
25 |
-
model.add(Conv2D(256,(3,3), activation="relu"))
|
26 |
-
model.add(BatchNormalization())
|
27 |
-
model.add(MaxPooling2D())
|
28 |
-
|
29 |
-
# model.add(Conv2D(512,(3,3), activation="relu"))
|
30 |
-
# model.add(BatchNormalization())
|
31 |
-
# model.add(Conv2D(512,(3,3), activation="relu"))
|
32 |
-
# model.add(BatchNormalization())
|
33 |
-
# model.add(MaxPooling2D())
|
34 |
-
|
35 |
-
# model.add(Conv2D(512,(3,3), activation="relu"))
|
36 |
-
# model.add(BatchNormalization())
|
37 |
-
# model.add(Conv2D(512,(3,3), activation="relu"))
|
38 |
-
# model.add(BatchNormalization())
|
39 |
-
# model.add(Conv2D(512,(3,3), activation="relu"))
|
40 |
-
# model.add(BatchNormalization())
|
41 |
-
# model.add(GlobalMaxPooling2D())
|
42 |
-
|
43 |
-
model.add(Dense(1024, activation="relu"))
|
44 |
-
model.add(BatchNormalization())
|
45 |
-
model.add(Dense(nbr_class, activation="softmax"))
|
46 |
-
|
47 |
-
return model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
models/{mobilenet_v2/best_model.pth → modelnet/best_model.h5}
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e7c1ec8dba0efbf87bd07ad89555987bd7be807efbc77d42cab2d0c75a45d6a0
|
3 |
+
size 9556672
|
requirements.txt
DELETED
@@ -1,13 +0,0 @@
|
|
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
DELETED
Binary file (2.86 MB)
|
|
samples/blacktip.jpg
DELETED
Binary file (24.3 kB)
|
|
samples/blue.jpg
DELETED
Binary file (4.01 MB)
|
|
samples/bull.jpg
DELETED
Binary file (3.31 MB)
|
|
samples/hammerhead.jpg
DELETED
Binary file (103 kB)
|
|
samples/lemon.jpg
DELETED
Binary file (553 kB)
|
|
samples/mako.jpg
DELETED
Binary file (37.2 kB)
|
|
samples/nurse.jpg
DELETED
Binary file (37.1 kB)
|
|
samples/sand tiger.jpg
DELETED
Binary file (128 kB)
|
|
samples/thresher.jpg
DELETED
Binary file (126 kB)
|
|
samples/tigre.jpg
DELETED
Binary file (44.9 kB)
|
|
samples/whale.jpg
DELETED
Binary file (222 kB)
|
|
samples/white.jpg
DELETED
Binary file (209 kB)
|
|
samples/whitetip.jpg
DELETED
Binary file (41.4 kB)
|
|