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
|
@@ -1,98 +1,29 @@
|
|
| 1 |
import cv2
|
| 2 |
import numpy as np
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
start_y = y_max
|
| 29 |
-
|
| 30 |
-
# Move the line towards the top-left corner
|
| 31 |
-
while start_x >= 0 and start_y >= 0:
|
| 32 |
-
# Calculate the end point of the line
|
| 33 |
-
end_x = int(start_x - line_length * np.cos(angle_radians))
|
| 34 |
-
end_y = int(start_y - line_length * np.sin(angle_radians))
|
| 35 |
-
|
| 36 |
-
# Draw the line on the binary mask
|
| 37 |
-
cv2.line(binary_mask, (start_x, start_y), (end_x, end_y), 255, 2)
|
| 38 |
-
|
| 39 |
-
# Check if the line touches the mask
|
| 40 |
-
if binary_mask[end_y, end_x] == 255:
|
| 41 |
-
break
|
| 42 |
-
|
| 43 |
-
# Move the line towards the top-left corner
|
| 44 |
-
start_x -= 1
|
| 45 |
-
start_y -= 1
|
| 46 |
-
|
| 47 |
-
# Display or save the image with the line
|
| 48 |
-
cv2.imshow('Line Image', binary_mask)
|
| 49 |
-
cv2.waitKey(0)
|
| 50 |
-
cv2.destroyAllWindows()
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
import cv2
|
| 54 |
-
import numpy as np
|
| 55 |
-
|
| 56 |
-
def is_pixel_on_line(image, start, end):
|
| 57 |
-
# Bresenham's line algorithm
|
| 58 |
-
x0, y0 = start
|
| 59 |
-
x1, y1 = end
|
| 60 |
-
dx = abs(x1 - x0)
|
| 61 |
-
dy = abs(y1 - y0)
|
| 62 |
-
sx = 1 if x0 < x1 else -1
|
| 63 |
-
sy = 1 if y0 < y1 else -1
|
| 64 |
-
err = dx - dy
|
| 65 |
-
|
| 66 |
-
while True:
|
| 67 |
-
# Check if the current pixel is white (255)
|
| 68 |
-
if image[y0, x0] == 255:
|
| 69 |
-
return True # Pixel is present on the line
|
| 70 |
-
|
| 71 |
-
# Check if we have reached the end point
|
| 72 |
-
if (x0, y0) == (x1, y1):
|
| 73 |
-
break
|
| 74 |
-
|
| 75 |
-
e2 = 2 * err
|
| 76 |
-
if e2 > -dy:
|
| 77 |
-
err -= dy
|
| 78 |
-
x0 += sx
|
| 79 |
-
if e2 < dx:
|
| 80 |
-
err += dx
|
| 81 |
-
y0 += sy
|
| 82 |
-
|
| 83 |
-
return False # No white pixel is present on the line
|
| 84 |
-
|
| 85 |
-
# Read the binary mask image
|
| 86 |
-
mask_path = 'mask_image.png'
|
| 87 |
-
mask = cv2.imread(mask_path, cv2.IMREAD_GRAYSCALE)
|
| 88 |
-
|
| 89 |
-
# Define the start and end coordinates of the line
|
| 90 |
-
start_point = (10, 10)
|
| 91 |
-
end_point = (100, 100)
|
| 92 |
-
|
| 93 |
-
# Check if any white pixel is present on the line
|
| 94 |
-
is_pixel_present = is_pixel_on_line(mask, start_point, end_point)
|
| 95 |
-
if is_pixel_present:
|
| 96 |
-
print("At least one white pixel is present on the line.")
|
| 97 |
else:
|
| 98 |
-
print("No
|
|
|
|
| 1 |
import cv2
|
| 2 |
import numpy as np
|
| 3 |
|
| 4 |
+
# Load the mask image
|
| 5 |
+
mask = cv2.imread('mask_image.png', cv2.IMREAD_GRAYSCALE) # Replace 'mask_image.png' with the path to your mask image
|
| 6 |
+
|
| 7 |
+
# Apply Gaussian blur to the image to reduce noise
|
| 8 |
+
blurred = cv2.GaussianBlur(mask, (5, 5), 0)
|
| 9 |
+
|
| 10 |
+
# Apply Hough Circle Transform to detect circles
|
| 11 |
+
circles = cv2.HoughCircles(blurred, cv2.HOUGH_GRADIENT, dp=1, minDist=20, param1=50, param2=30, minRadius=0, maxRadius=0)
|
| 12 |
+
|
| 13 |
+
if circles is not None:
|
| 14 |
+
circles = np.uint16(np.around(circles))
|
| 15 |
+
|
| 16 |
+
# Filter out semicircles based on the position of the circle centers
|
| 17 |
+
semicircles = [circle[0] for circle in circles[0] if circle[1] < mask.shape[0] / 2]
|
| 18 |
+
|
| 19 |
+
# Draw the semicircles on a blank image
|
| 20 |
+
semicircle_image = np.zeros_like(mask)
|
| 21 |
+
for (x, y, r) in semicircles:
|
| 22 |
+
cv2.circle(semicircle_image, (x, y), r, (255, 255, 255), thickness=cv2.FILLED)
|
| 23 |
+
|
| 24 |
+
# Display the image with the semicircles
|
| 25 |
+
cv2.imshow('Semicircles in Mask', semicircle_image)
|
| 26 |
+
cv2.waitKey(0)
|
| 27 |
+
cv2.destroyAllWindows()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
else:
|
| 29 |
+
print("No semicircles found in the image.")
|