Skip to content

Instantly share code, notes, and snippets.

View AlphaNext's full-sized avatar
🧧
Focusing

AlphaNext

🧧
Focusing
  • Beijing
View GitHub Profile
@AlphaNext
AlphaNext / README_hfd.md
Created March 25, 2024 10:03 — forked from padeoe/README_hfd.md
CLI-Tool for download Huggingface models and datasets with aria2/wget+git

🤗Huggingface Model Downloader

Considering the lack of multi-threaded download support in the official huggingface-cli, and the inadequate error handling in hf_transfer, this command-line tool smartly utilizes wget or aria2 for LFS files and git clone for the rest.

Features

  • ⏯️ Resume from breakpoint: You can re-run it or Ctrl+C anytime.
  • 🚀 Multi-threaded Download: Utilize multiple threads to speed up the download process.
  • 🚫 File Exclusion: Use --exclude or --include to skip or specify files, save time for models with duplicate formats (e.g., *.bin or *.safetensors).
  • 🔐 Auth Support: For gated models that require Huggingface login, use --hf_username and --hf_token to authenticate.
  • 🪞 Mirror Site Support: Set up with HF_ENDPOINT environment variable.
@AlphaNext
AlphaNext / avif2png.py
Created March 31, 2023 10:19
avif image to png using python
# firstly, pip install pillow-avif-plugin Pillow
from PIL import Image
import pillow_avif
import sys
aviffile = sys.argv[1]
avifImage = Image.open(aviffile)
avifImage.save(aviffile.replace('avif', 'png'), 'png')
@AlphaNext
AlphaNext / Conv2d_channel_slim.py
Created February 7, 2023 08:17
PyTorch Conv2d operation slim output channels, and reduction Conv2d operation
import torch
import pdb
import numpy as np
class Net(torch.nn.Module):
def __init__(self, n_feature, n_output):
super(Net, self).__init__()
self.conv = torch.nn.Conv2d(n_feature, n_output, 1)
def forward(self, x):
x = self.conv(x)
@AlphaNext
AlphaNext / curl.md
Created October 19, 2022 10:12 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

pass cpp struct result to android part using android JNI
@AlphaNext
AlphaNext / py2_Check_Encode.py
Created February 12, 2020 02:50
Get Chinese character index from a character dictionary List with Python2
# solve bug in Github project : https://github.com/Wang-Tianwei/Decoupled-attention-network
# method 0
# could use readlines() and open file function, but remember that
# your dicts variable format and your Chinese characters format
##############################################################################################
# method 1
dict_file = open('char.U', 'r')
@AlphaNext
AlphaNext / GIF_to_OpenCV.cpp
Created December 23, 2019 05:47
read GIF image using ImageMagick and convert GIF to OpenCV Mat frames
#include <opencv2/opencv.hpp>
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
using namespace cv;
// imageMagick installation on Mac OSX: https://www.sethvargo.com/install-imagemagick-on-osx-lion/
// read gif's first frame to cv::Mat https://stackoverflow.com/questions/41841553/convert-magickimage-to-cvmat
// ref link: https://imagemagick.org/discourse-server/viewtopic.php?t=35080
@AlphaNext
AlphaNext / Learn_Eigen.cpp
Last active August 6, 2024 02:08
Learn and use Eigen quickly
#include <Eigen/Dense>
#include <vector>
#include <stdio.h>
#include <iostream>
using namespace Eigen;
using namespace std;
// Eigen is column major storage
int main(){
std::vector<Matrix<float, 2, 3> > batch_m;
MatrixXf x(2,3);