dcskycam commited on
Commit
c9e7619
·
verified ·
1 Parent(s): e7ffcd9

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +2 -61
README.md CHANGED
@@ -68,68 +68,9 @@ Overall accuracy: **98.6%**
68
 
69
  ## Usage
70
 
71
- ### Python (TensorFlow Lite Runtime on Raspberry Pi)
72
 
73
- ```python
74
- import tflite_runtime.interpreter as tflite
75
- import numpy as np
76
- from PIL import Image
77
-
78
- # Load model and labels
79
- interpreter = tflite.Interpreter(model_path="custom_heli.tflite")
80
- interpreter.allocate_tensors()
81
-
82
- with open("custom_heli-labels.txt", "r") as f:
83
- labels = [line.strip() for line in f.readlines()]
84
-
85
- # Prepare image (224x224, normalized to [0, 1])
86
- img = Image.open("candidate.jpg").convert("RGB")
87
- img = img.resize((224, 224))
88
- input_data = np.expand_dims(np.array(img, dtype=np.float32) / 255.0, axis=0)
89
-
90
- # Run inference
91
- input_details = interpreter.get_input_details()[0]
92
- interpreter.set_tensor(input_details["index"], input_data)
93
- interpreter.invoke()
94
-
95
- # Get results
96
- output = interpreter.get_tensor(interpreter.get_output_details()[0]["index"])[0]
97
- pred_idx = int(np.argmax(output))
98
- confidence = float(np.max(output))
99
-
100
- print(f"Prediction: {labels[pred_idx]} (confidence: {confidence:.4f})")
101
- ```
102
-
103
- ### Python (TensorFlow on Desktop)
104
-
105
- ```python
106
- import tensorflow as tf
107
- import numpy as np
108
- from PIL import Image
109
-
110
- # Load model
111
- interpreter = tf.lite.Interpreter(model_path="custom_heli.tflite")
112
- interpreter.allocate_tensors()
113
-
114
- # Load labels
115
- with open("custom_heli-labels.txt", "r") as f:
116
- labels = [line.strip() for line in f.readlines()]
117
-
118
- # Prepare and run inference (same as above)
119
- img = Image.open("candidate.jpg").convert("RGB")
120
- img = img.resize((224, 224))
121
- input_data = np.expand_dims(np.array(img, dtype=np.float32) / 255.0, axis=0)
122
-
123
- input_details = interpreter.get_input_details()[0]
124
- interpreter.set_tensor(input_details["index"], input_data)
125
- interpreter.invoke()
126
-
127
- output = interpreter.get_tensor(interpreter.get_output_details()[0]["index"])[0]
128
- pred_idx = int(np.argmax(output))
129
- confidence = float(np.max(output))
130
-
131
- print(f"Prediction: {labels[pred_idx]} (confidence: {confidence:.4f})")
132
- ```
133
 
134
  ## Citation
135
 
 
68
 
69
  ## Usage
70
 
71
+ This model was intended to be used with the TensorFlow Lite (TFLite) runtimes and Python 3.11. TFLite has been deprecated. As the DCSkycam project has concluded, there will not be a migration to the newer LiteRT interpreter.
72
 
73
+ The repository includes an `inference.py` file with a sample implementation that has been tested on desktop (OSX) and a Raspberry Pi 5 device (Trixie 64-bit).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  ## Citation
76