Instructions to use Nekshay/Car_VS_Rest with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Nekshay/Car_VS_Rest with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="Nekshay/Car_VS_Rest") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("Nekshay/Car_VS_Rest") model = AutoModelForImageClassification.from_pretrained("Nekshay/Car_VS_Rest", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update tempo.txt
Browse files
tempo.txt
CHANGED
|
@@ -6,6 +6,7 @@ def detect_half_circles(binary_image, threshold=80):
|
|
| 6 |
contours, _ = cv2.findContours(binary_image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
| 7 |
|
| 8 |
detected_shapes = []
|
|
|
|
| 9 |
|
| 10 |
for contour in contours:
|
| 11 |
# Approximate the contour
|
|
@@ -31,9 +32,12 @@ def detect_half_circles(binary_image, threshold=80):
|
|
| 31 |
|
| 32 |
# Draw a bounding rectangle around the detected half-circle
|
| 33 |
x, y, w, h = cv2.boundingRect(contour)
|
| 34 |
-
cv2.rectangle(
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
return
|
| 37 |
|
| 38 |
# Example usage
|
| 39 |
# Load the binary masked image (make sure it's a binary image)
|
|
|
|
| 6 |
contours, _ = cv2.findContours(binary_image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
| 7 |
|
| 8 |
detected_shapes = []
|
| 9 |
+
output_image = cv2.cvtColor(binary_image, cv2.COLOR_GRAY2BGR)
|
| 10 |
|
| 11 |
for contour in contours:
|
| 12 |
# Approximate the contour
|
|
|
|
| 32 |
|
| 33 |
# Draw a bounding rectangle around the detected half-circle
|
| 34 |
x, y, w, h = cv2.boundingRect(contour)
|
| 35 |
+
cv2.rectangle(output_image, (x, y), (x + w, y + h), (0, 255, 0), 2)
|
| 36 |
+
|
| 37 |
+
# Draw the contour with a different color
|
| 38 |
+
cv2.drawContours(output_image, [approx], -1, (0, 0, 255), 2)
|
| 39 |
|
| 40 |
+
return output_image, detected_shapes
|
| 41 |
|
| 42 |
# Example usage
|
| 43 |
# Load the binary masked image (make sure it's a binary image)
|