Instructions to use ottoykh/Smart-Traffic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ottoykh/Smart-Traffic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-segmentation", model="ottoykh/Smart-Traffic")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ottoykh/Smart-Traffic", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload 2 files
Browse files
traffic-image/__init__.py
ADDED
|
File without changes
|
traffic-image/image_processing.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytz
|
| 2 |
+
import datetime
|
| 3 |
+
import os
|
| 4 |
+
import requests
|
| 5 |
+
from urllib.parse import urlparse
|
| 6 |
+
import time
|
| 7 |
+
from ultralytics import YOLO
|
| 8 |
+
|
| 9 |
+
def process_images(image_urls):
|
| 10 |
+
hong_kong_timezone = pytz.timezone('Asia/Hong_Kong')
|
| 11 |
+
|
| 12 |
+
while True:
|
| 13 |
+
current_time = datetime.datetime.now(tz=hong_kong_timezone).strftime("%Y%m%d%H%M%S")
|
| 14 |
+
folder_name = f"/content/{current_time}"
|
| 15 |
+
print(folder_name)
|
| 16 |
+
os.makedirs(folder_name, exist_ok=True)
|
| 17 |
+
|
| 18 |
+
for image_url in image_urls:
|
| 19 |
+
response = requests.get(image_url)
|
| 20 |
+
image_data = response.content
|
| 21 |
+
parsed_url = urlparse(image_url)
|
| 22 |
+
image_name = os.path.basename(parsed_url.path)
|
| 23 |
+
file_name = os.path.join(folder_name, image_name)
|
| 24 |
+
with open(file_name, "wb") as file:
|
| 25 |
+
file.write(image_data)
|
| 26 |
+
print(file_name)
|
| 27 |
+
|
| 28 |
+
folder_name_formatted = f"'{folder_name}'"
|
| 29 |
+
|
| 30 |
+
yolo = YOLO('/content/Smart-Traffic/best.pt')
|
| 31 |
+
yolo.set_conf(0.45)
|
| 32 |
+
yolo.predict(source=folder_name_formatted, save=True, save_txt=True)
|
| 33 |
+
|
| 34 |
+
time.sleep(120)
|