Skip to content

Instantly share code, notes, and snippets.

View Srking501's full-sized avatar
🤓
MSc Data Science (with AI)

Abdullah Alshadadi Srking501

🤓
MSc Data Science (with AI)
View GitHub Profile
@Srking501
Srking501 / one_line_device_selector_pytorch.py
Created September 29, 2025 17:59
One line code for selecting `torch.device` (includes the "mps" for Apple Silicon)
import torch
device = (
"cuda"
if torch.cuda.is_available()
else "mps"
if torch.backends.mps.is_available()
else "cpu"
)
@Srking501
Srking501 / download_cityscapes.py
Last active July 28, 2024 13:17
More stable and safe way of downloading Cityscapes in Google Colab by utilising "Secrets" (in this example, installing `gtFine` and `leftImg8bit`)
import os
cityscapes_dir = "data/cityscapes/"
if not os.path.exists(cityscapes_dir):
os.makedirs(cityscapes_dir)
if not os.listdir(cityscapes_dir):
# Once you setup 'username' and 'password' "Secret" keys that corresponds