ismot Asadel Ann commited on
Commit
3670998
·
0 Parent(s):

Duplicate from asaderu/100-Sports_Classification

Browse files

Co-authored-by: Asadel Ann <[email protected]>

Files changed (9) hide show
  1. .gitattributes +34 -0
  2. LICENSE +21 -0
  3. README.md +14 -0
  4. app.py +71 -0
  5. cvexport.manifest +13 -0
  6. labels.txt +100 -0
  7. metadata_properties.json +22 -0
  8. model.pb +3 -0
  9. requirements.txt +5 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt 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
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+  MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: 100-Sports Classification
3
+ emoji: 📈
4
+ colorFrom: indigo
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 3.15.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ duplicated_from: asaderu/100-Sports_Classification
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ import gradio as gr
4
+ import pathlib
5
+ import numpy as np
6
+ import tensorflow
7
+ import PIL.Image
8
+ from PIL import Image
9
+
10
+
11
+ class Model:
12
+ def __init__(self, model_filepath):
13
+ self.graph_def = tensorflow.compat.v1.GraphDef()
14
+ self.graph_def.ParseFromString(model_filepath.read_bytes())
15
+
16
+ input_names, self.output_names = self._get_graph_inout(self.graph_def)
17
+ assert len(input_names) == 1
18
+ self.input_name = input_names[0]
19
+ self.input_shape = self._get_input_shape(self.graph_def, self.input_name)
20
+
21
+ def predict(self, image_filepath):
22
+ image = Image.fromarray(image_filepath).resize(self.input_shape)
23
+ input_array = np.array(image, dtype=np.float32)[np.newaxis, :, :, :]
24
+
25
+ with tensorflow.compat.v1.Session() as sess:
26
+ tensorflow.import_graph_def(self.graph_def, name='')
27
+ out_tensors = [sess.graph.get_tensor_by_name(o + ':0') for o in self.output_names]
28
+ outputs = sess.run(out_tensors, {self.input_name + ':0': input_array})
29
+
30
+ return {name: outputs[i] for i, name in enumerate(self.output_names)}
31
+
32
+ @staticmethod
33
+ def _get_graph_inout(graph_def):
34
+ input_names = []
35
+ inputs_set = set()
36
+ outputs_set = set()
37
+
38
+ for node in graph_def.node:
39
+ if node.op == 'Placeholder':
40
+ input_names.append(node.name)
41
+
42
+ for i in node.input:
43
+ inputs_set.add(i.split(':')[0])
44
+ outputs_set.add(node.name)
45
+
46
+ output_names = list(outputs_set - inputs_set)
47
+ return input_names, output_names
48
+
49
+ @staticmethod
50
+ def _get_input_shape(graph_def, input_name):
51
+ for node in graph_def.node:
52
+ if node.name == input_name:
53
+ return [dim.size for dim in node.attr['shape'].shape.dim][1:3]
54
+
55
+
56
+ def print_outputs(outputs):
57
+ labelopen = open("labels.txt", 'r')
58
+ labels = [line.split(',') for line in labelopen.readlines()]
59
+ outputs = list(outputs.values())[0]
60
+ return str(labels[outputs[0].argmax()][0])
61
+
62
+
63
+ def main(gambar):
64
+ m = pathlib.Path("model.pb")
65
+ #i = pathlib.Path(gambar)
66
+
67
+ model = Model(m)
68
+ outputs = model.predict(gambar)
69
+ return print_outputs(outputs)
70
+ demo = gr.Interface(main, gr.Image(shape=(500, 500)), "text")
71
+ demo.launch()
cvexport.manifest ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "DomainType": "Classification",
3
+ "Platform": "TensorFlow",
4
+ "Flavor": null,
5
+ "ExporterVersion": "2.1",
6
+ "ExportedDate": "2023-01-03T08:46:55.194281Z",
7
+ "IterationId": "94a3200d-9b31-47ec-8e5a-078338a30274",
8
+ "ModelFileName": "model.pb",
9
+ "LabelFileName": "labels.txt",
10
+ "MetadataPropsFileName": "metadata_properties.json",
11
+ "ModelFileSHA1": "4d51fef7e4518d0762d87b4fc745c4014d54c83e",
12
+ "SchemaVersion": "1.0"
13
+ }
labels.txt ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Air Hockey
2
+ American Football
3
+ Ampute Football
4
+ Archery
5
+ Arm Wrestling
6
+ Axe Throwing
7
+ Balance Beam
8
+ Barell Racing
9
+ Baseball
10
+ Basketball
11
+ Baton Twirling
12
+ Bike Polo
13
+ Billiards
14
+ BMX
15
+ Bobsled
16
+ Bowling
17
+ Boxing
18
+ Bull Riding
19
+ Bungee Jumping
20
+ Canoe Slamon
21
+ CheerLeading
22
+ Chuckwagon Racing
23
+ Cricket
24
+ Croquet
25
+ Curling
26
+ Disk Golf
27
+ F1
28
+ Fencing
29
+ Field Hockey
30
+ Figure Skating Men
31
+ Figure Skating Pairs
32
+ Figure Skating Women
33
+ Fly Fishing
34
+ Frisbee
35
+ Gaga
36
+ Giant Slalom
37
+ Golf
38
+ Hammer Throw
39
+ hang gliding
40
+ harness Racing
41
+ High Jump
42
+ Hockey
43
+ Horse Jumping
44
+ Horse Racing
45
+ horsesoe pitching
46
+ Hurdles
47
+ Hydroplane Racing
48
+ Ice Climbing
49
+ Ice Yachting
50
+ jai Alai
51
+ javelin
52
+ Jousting
53
+ Judo
54
+ Lacrosse
55
+ Log Rolling
56
+ Luge
57
+ Motorcycle Racing
58
+ mushing
59
+ Nascar Racing
60
+ Olympic Wrestling
61
+ Parallel Bar
62
+ Pole Climbing
63
+ Pole Dancing
64
+ Pole Vault
65
+ Polo
66
+ Pommel Horse
67
+ Rings
68
+ Rock Climbing
69
+ Rolerblade racing
70
+ Roller Derby
71
+ rowing
72
+ rugby
73
+ Sailboat
74
+ Shot Put
75
+ Shuffleboard
76
+ Sider Car Racing
77
+ Ski Jumping
78
+ Sky Surfing
79
+ skydiving
80
+ snow boarding
81
+ snow mobile racing
82
+ speed skating
83
+ Steer Wrestling
84
+ Sumo Wrestling
85
+ Surfing
86
+ Swimming
87
+ Table Tennis
88
+ Tennis
89
+ Track Bicycle
90
+ Trapeze
91
+ Tug of War
92
+ Ultimate
93
+ Uneven Bars
94
+ volley ball
95
+ water cycling
96
+ water polo
97
+ weightlifting
98
+ wheelchair basketball
99
+ Wheelchair Racing
100
+ wingsuit flying
metadata_properties.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "CustomVision.Metadata.AdditionalModelInfo": "",
3
+ "CustomVision.Metadata.Version": "1.2",
4
+ "CustomVision.Postprocess.Method": "ClassificationMultiClass",
5
+ "CustomVision.Postprocess.Yolo.Biases": "[]",
6
+ "CustomVision.Postprocess.Yolo.NmsThreshold": "0.0",
7
+ "CustomVision.Preprocess.CropHeight": "0",
8
+ "CustomVision.Preprocess.CropMethod": "FullImageShorterSide",
9
+ "CustomVision.Preprocess.CropWidth": "0",
10
+ "CustomVision.Preprocess.MaxDimension": "0",
11
+ "CustomVision.Preprocess.MaxScale": "0.0",
12
+ "CustomVision.Preprocess.MinDimension": "0",
13
+ "CustomVision.Preprocess.MinScale": "0.0",
14
+ "CustomVision.Preprocess.NormalizeMean": "[0.0, 0.0, 0.0]",
15
+ "CustomVision.Preprocess.NormalizeStd": "[1.0, 1.0, 1.0]",
16
+ "CustomVision.Preprocess.ResizeMethod": "Stretch",
17
+ "CustomVision.Preprocess.TargetHeight": "300",
18
+ "CustomVision.Preprocess.TargetWidth": "300",
19
+ "Image.BitmapPixelFormat": "Rgb8",
20
+ "Image.ColorSpaceGamma": "SRGB",
21
+ "Image.NominalPixelRange": "Normalized_0_1"
22
+ }
model.pb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:422142a00891f51158e5b335ef9262e7a3f0b3d416526e30b797225e254ec52b
3
+ size 45282442
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ pillow
2
+ gradio
3
+ tensorflow
4
+ numpy
5
+ pathlib