# IDE
# .vscode/ # commented to share info with others
# MacOS
*.DS_Store
# Virtual env
.venv/
venv/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 # pip install psycopg2-binary | |
from typing import Optional | |
class InterfaceSQL: | |
def __init__(self, database:str, host:str, port:str, user:str, password:str): | |
conn = psycopg2.connect( | |
database=database, | |
host=host, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import torch | |
import numpy as np | |
def prepare_image_for_display( | |
data: torch.Tensor|np.ndarray, | |
channels_selected: list[int] = [0,1,2], | |
permute_channels: bool = False, | |
normalize: bool = True, |
- Use HTML tags to define the table to get the best layout result
- Use either backticks (```) or the HTML
pre
element with attributelang
- Keep a blank line before and after a code block for correct formatting and syntax highlighting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
from pathlib import Path | |
from utils_sql import InterfaceSQL # custom psycopg2 | |
from shapely.geometry import shape | |
if __name__ == '__main__': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stream_download(url:str, output_filepath:Path, desc:str='Item Download'): | |
response = requests.get(url, stream=True) | |
total = int(response.headers.get('content-length', 0)) | |
with open(output_filepath, 'wb') as f, tqdm(desc=desc,total=total,unit='iB',unit_scale=True,unit_divisor=1024,) as bar: | |
for data in response.iter_content(chunk_size=1024): | |
size = f.write(data) | |
bar.update(size) |
NewerOlder