Eric P. Nusbaum commited on
Commit
34f5d81
·
1 Parent(s): 24b11a6
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+ import os
6
+
7
+ # Load labels
8
+ with open('tensorflow/labels.txt', 'r') as f:
9
+ labels = f.read().splitlines()
10
+
11
+ # Load TensorFlow model
12
+ model = tf.keras.models.load_model('tensorflow/model.pb')
13
+
14
+ def preprocess_image(image):
15
+ # Resize image to the size expected by the model
16
+ target_size = (224, 224) # Replace with your model's expected input size
17
+ image = image.resize(target_size)
18
+ image = np.array(image)
19
+ image = image / 255.0 # Normalize if required
20
+ return image
21
+
22
+ def predict(image):
23
+ image = preprocess_image(image)
24
+ image = np.expand_dims(image, axis=0) # Add batch dimension
25
+ predictions = model.predict(image)
26
+ predicted_index = np.argmax(predictions, axis=1)[0]
27
+ predicted_label = labels[predicted_index]
28
+ confidence = predictions[0][predicted_index] * 100
29
+ return {predicted_label: round(confidence, 2)}
30
+
31
+ # Define Gradio interface
32
+ title = "JunkWaxHero 🦸‍♂️ - Baseball Card Set Identifier"
33
+ description = "Upload an image of a baseball card, and JunkWaxHero will identify the set it belongs to with high accuracy."
34
+
35
+ iface = gr.Interface(
36
+ fn=predict,
37
+ inputs=gr.inputs.Image(type="pil"),
38
+ outputs=gr.outputs.Label(num_top_classes=1),
39
+ title=title,
40
+ description=description,
41
+ examples=[
42
+ ["examples/card1.jpg"],
43
+ ["examples/card2.jpg"],
44
+ ["examples/card3.jpg"]
45
+ ],
46
+ allow_flagging="never"
47
+ )
48
+
49
+ if __name__ == "__main__":
50
+ iface.launch()
examples/card1.jpg ADDED

Git LFS Details

  • SHA256: 66ec5f6056195f861642483a53c60b6e8c9c3c66c1679ce4c07dd9614a0ff3bc
  • Pointer size: 132 Bytes
  • Size of remote file: 2.7 MB
examples/card2.jpg ADDED

Git LFS Details

  • SHA256: 18f560457d6d37befc6fc6bd9ab085ec118fa90e86fa11f880870096a241d9b4
  • Pointer size: 132 Bytes
  • Size of remote file: 4.43 MB
examples/card3.jpg ADDED

Git LFS Details

  • SHA256: d93d8f3a60c2bd2ce57058c6e9d39c3ea946b3197981e36e0c2eab9d65fda980
  • Pointer size: 132 Bytes
  • Size of remote file: 3.04 MB
onnx/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
onnx/README.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Custom Vision Export Object Detection Models
2
+ This model is exported from [Custom Vision Service](https://customvision.ai)
3
+
4
+ Please visit our [Sample scripts respository](https://github.com/Azure-Samples/customvision-export-samples).
5
+
6
+ ## Prerequisites
7
+ (For TensorFlow Lite model) TensorFlow Lite 2.1 or newer
8
+
9
+ ## Input specification
10
+ This model expects 320x320, 3-channel RGB images. Pixel values need to be in the range of [0-255].
11
+
12
+ ## Output specification
13
+ There are three outputs from this model.
14
+
15
+ * detected_boxes
16
+ The detected bounding boxes. Each bounding box is represented as [x1, y1, x2, y2] where (x1, y1) and (x2, y2) are the coordinates of box corners.
17
+ * detected_scores
18
+ Probability for each detected boxes.
19
+ * detected_classes
20
+ The class index for the detected boxes.
21
+
22
+ # Reference
23
+ * [Custom Vision Service documentation](https://docs.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/)
24
+ * [Sample scripts](https://github.com/Azure-Samples/customvision-export-samples)
onnx/cvexport.manifest ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "DomainType": "ObjectDetection",
3
+ "Platform": "ONNX",
4
+ "Flavor": null,
5
+ "ExporterVersion": "2.0",
6
+ "ExportedDate": "2025-01-10T18:55:56.72257Z",
7
+ "IterationId": "159e9c3e-6435-4b9b-826d-ca39f5889fbc",
8
+ "ModelFileName": "model.onnx",
9
+ "LabelFileName": "labels.txt",
10
+ "MetadataPropsFileName": "metadata_properties.json",
11
+ "ModelFileSHA1": "949c71d256808ed71dafaeb424f54bd94051857e",
12
+ "SchemaVersion": "1.0"
13
+ }
onnx/labels.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ 1984 Topps
2
+ 1987 Topps
3
+ 1989 Bowman
4
+ 1989 Fleer
5
+ 1989 Upper Deck
6
+ 1990 Donruss
7
+ 1990 Topps
8
+ 1991 Upper Deck
9
+ 1993 Topps
onnx/metadata_properties.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "CustomVision.Metadata.AdditionalModelInfo": "",
3
+ "CustomVision.Metadata.Version": "1.2",
4
+ "CustomVision.Postprocess.Method": "SSD",
5
+ "CustomVision.Postprocess.Yolo.Biases": "[]",
6
+ "CustomVision.Postprocess.Yolo.NmsThreshold": "0.0",
7
+ "CustomVision.Preprocess.CropHeight": "0",
8
+ "CustomVision.Preprocess.CropMethod": "NoCrop",
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": "320",
18
+ "CustomVision.Preprocess.TargetWidth": "320",
19
+ "Image.BitmapPixelFormat": "Rgb8",
20
+ "Image.ColorSpaceGamma": "SRGB",
21
+ "Image.NominalPixelRange": "Normalized_0_1"
22
+ }
onnx/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eba88166ae625c537736423715adc31baf4e7cb0dabbdd76f6ee6cbbcacb969f
3
+ size 11670194
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ tensorflow==2.11.0 # Replace with your TensorFlow version
3
+ Pillow
4
+ numpy
tensorflow/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
tensorflow/README.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Custom Vision Export Object Detection Models
2
+ This model is exported from [Custom Vision Service](https://customvision.ai)
3
+
4
+ Please visit our [Sample scripts respository](https://github.com/Azure-Samples/customvision-export-samples).
5
+
6
+ ## Prerequisites
7
+ (For TensorFlow Lite model) TensorFlow Lite 2.1 or newer
8
+
9
+ ## Input specification
10
+ This model expects 320x320, 3-channel RGB images. Pixel values need to be in the range of [0-255].
11
+
12
+ ## Output specification
13
+ There are three outputs from this model.
14
+
15
+ * detected_boxes
16
+ The detected bounding boxes. Each bounding box is represented as [x1, y1, x2, y2] where (x1, y1) and (x2, y2) are the coordinates of box corners.
17
+ * detected_scores
18
+ Probability for each detected boxes.
19
+ * detected_classes
20
+ The class index for the detected boxes.
21
+
22
+ # Reference
23
+ * [Custom Vision Service documentation](https://docs.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/)
24
+ * [Sample scripts](https://github.com/Azure-Samples/customvision-export-samples)
tensorflow/cvexport.manifest ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "DomainType": "ObjectDetection",
3
+ "Platform": "TensorFlow",
4
+ "Flavor": null,
5
+ "ExporterVersion": "2.1",
6
+ "ExportedDate": "2025-01-10T18:55:38.4488602Z",
7
+ "IterationId": "159e9c3e-6435-4b9b-826d-ca39f5889fbc",
8
+ "ModelFileName": "model.pb",
9
+ "LabelFileName": "labels.txt",
10
+ "MetadataPropsFileName": "metadata_properties.json",
11
+ "ModelFileSHA1": "7b0dd1f64b803acf61535d256e662ccafa5ae0e1",
12
+ "SchemaVersion": "1.0"
13
+ }
tensorflow/labels.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ 1984 Topps
2
+ 1987 Topps
3
+ 1989 Bowman
4
+ 1989 Fleer
5
+ 1989 Upper Deck
6
+ 1990 Donruss
7
+ 1990 Topps
8
+ 1991 Upper Deck
9
+ 1993 Topps
tensorflow/metadata_properties.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "CustomVision.Metadata.AdditionalModelInfo": "",
3
+ "CustomVision.Metadata.Version": "1.2",
4
+ "CustomVision.Postprocess.Method": "SSD",
5
+ "CustomVision.Postprocess.Yolo.Biases": "[]",
6
+ "CustomVision.Postprocess.Yolo.NmsThreshold": "0.0",
7
+ "CustomVision.Preprocess.CropHeight": "0",
8
+ "CustomVision.Preprocess.CropMethod": "NoCrop",
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": "320",
18
+ "CustomVision.Preprocess.TargetWidth": "320",
19
+ "Image.BitmapPixelFormat": "Rgb8",
20
+ "Image.ColorSpaceGamma": "SRGB",
21
+ "Image.NominalPixelRange": "Normalized_0_1"
22
+ }
tensorflow/model.pb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33d1cd529b08c684ab287dd874d64c94275607cd0c0316c5cb32349e81b49d86
3
+ size 11687739