Downloads · 30 days
11
7% of all-time downloads
namelessai/Crashly
Crashly is a image classification model from namelessai. Use it when you need a label for an image. It is set up for transformers. The card lists the license as apache-2.0.
An image classification model for detecting car crashes from traffic cams. An easier to run version of Crashly is currently in development. To run this model, use the following code snippet.
Downloads · 30 days
11
7% of all-time downloads
All-time downloads
159
Public
Repo size
8.9 MB
Likes
1
Public
Click a slice to open those files.
.tflite8.9 MB · 100%
From the Hugging Face model README
An image classification model for detecting car crashes from traffic cams. An easier to run version of Crashly is currently in development. To run this model, use the following code snippet.
import numpy as np
from PIL import Image
import tensorflow as tf
# Load TFLite model and allocate tensors.
interpreter = tf.lite.Interpreter(model_path="{model_name}.tflite")
interpreter.allocate_tensors()
# Get input and output tensors.
input_details = interpreter.get_input_details()
output_details = interpreter.get_output_details()
input_shape = input_details[0]['shape']
# Load and preprocess image
def load_image(image_path):
img = Image.open(image_path).convert('RGB')
img = img.resize([input_shape[1], input_shape[2]])
img = np.asarray(img, dtype='float32') / 255
# Return a scaled array between -1 and 1
return img * 2 - 1
if __name__ == "__main__":
input_data = load_image("/tmp/your-image-here.jpg")
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()
# The function `get_tensor()` returns a copy of the tensor data.
# Use `tensor()` in order to get a pointer to the tensor.
output_data = interpreter.get_tensor(output_details[0]['index'])
print(output_data)