This file contains 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
# init git | |
cd existing_folder | |
git init --initial-branch=main | |
git remote add origin git@gitlab-XXXX.com:yanwei.liu/XXXX-XXXX.git | |
# git commit | |
git add . | |
git commit -m "Initial commit" | |
git push -u origin main |
This file contains 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 torch | |
import torch.nn.functional as F | |
def pad_image_to_nearest_multiple(image, multiple=32): | |
image = torch.from_numpy(image.astype(np.float32)).unsqueeze(0) | |
channels, height, width = image.shape | |
padded_height = ((height + multiple - 1) // multiple) * multiple | |
padded_width = ((width + multiple - 1) // multiple) * multiple | |
This file contains 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 warnings | |
warnings.simplefilter(action='ignore', category=FutureWarning) | |
import datetime | |
import pandas as pd | |
from pycoingecko import CoinGeckoAPI | |
import yfinance as yf | |
def get_monthly_prices_stock(symbol, date): | |
today = datetime.date.today() |
This file contains 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 cv2 | |
import imageio | |
import rawpy | |
class RawImage: | |
""" | |
A class for working with raw image files. | |
Attributes: | |
file_path (str): The path to the raw image file. |
This file contains 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 os | |
import random | |
from shutil import copyfile | |
import numpy as np | |
from PIL import Image | |
import multiprocessing as mp | |
class DarkFace2YOLOv5: | |
def __init__(self, data_dir, class_list, train_ratio=0.8, random_seed=None): | |
self.data_dir = data_dir |
This file contains 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 numpy as np | |
import cv2 | |
import imageio | |
def simplest_color_balance(img, percent): | |
out_channels = [] | |
channels = cv2.split(img) | |
for channel in channels: | |
total_pixels = img.shape[0] * img.shape[1] | |
low_val, high_val = np.percentile(channel, [percent, 100 - percent]) |
This file contains 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 os | |
import xml.etree.ElementTree as ET | |
import csv | |
# Set the paths for the input and output directories | |
voc_path = '/home/Yanwei_Liu/Datasets/PASCALRAW/annotations/' | |
train_img_path = '/home/Yanwei_Liu/Datasets/PASCALRAW/images/train/' | |
val_img_path = '/home/Yanwei_Liu/Datasets/PASCALRAW/images/val/' | |
train_file_path = '/home/Yanwei_Liu/Datasets/PASCALRAW/trainval/train.txt' |
This file contains 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
(Pdb) pdb.set_trace = lambda: None # This replaces the set_trace() function! | |
(Pdb) continue |
This file contains 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
""" | |
Implementation of IQA metrics in PyTorch, including PSNR, SSIM, LPIPS, NIQE, and LOE. | |
""" | |
import torch | |
import torch.nn as nn | |
import torchvision.models as models | |
import torchvision.transforms.functional as F | |
from torch.nn.functional import conv2d | |
from IQA_pytorch import SSIM, LPIPSvgg |
This file contains 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 pandas as pd | |
import numpy as np | |
from sklearn.model_selection import train_test_split | |
from sklearn.linear_model import LinearRegression | |
from sklearn.metrics import mean_absolute_error, mean_squared_error | |
from FinMind.data import DataLoader | |
dl = DataLoader() | |
stock_data = dl.taiwan_stock_daily( | |
stock_id='2330', start_date='2010-01-01', end_date='2022-12-20' |