Instructions to use namelessai/Crashly with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use namelessai/Crashly with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="namelessai/Crashly") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("namelessai/Crashly", dtype="auto") - Notebooks
- Google Colab
- Kaggle
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)
- Downloads last month
- 17