Skip to content

Instantly share code, notes, and snippets.

@grapeot
grapeot / structured_color.md
Created November 25, 2024 05:09
使用CoT+QWen2.5-32b生成,prompt是:介绍一下结构色。背景:蝴蝶的翅膀是彩色的,一方面是因为色素,一方面是因为结构色。

结构色的意义和影响

什么是结构色

结构色的基本定义

结构色,也被称为构造色或物理色,是一种通过物体表面的微小物理结构与光相互作用而产生的颜色效果。这种颜色不是由吸收某些波长的光线形成(如传统意义下的色素颜色),而是基于光波的干涉、衍射或者散射等光学效应形成的。

结构色与传统色素不同之处

@grapeot
grapeot / translate.py
Last active November 24, 2024 07:41
A reference implementation for performing offline inference using multiple GPUs, with each GPU hosting one instance of the model. Surprisingly, I couldn't find existing tools that easily support this. Therefore, I had to manually launch several server instances on different ports and use Ray's data set parallelization along with a server manager…
# The VLLM servers were launched using something like:
# CUDA_VISIBLE_DEVICES=2 vllm serve Qwen/Qwen2.5-32B-Instruct-GPTQ-Int4 --quantization gptq --max-model-len 4096 --port 8003
from openai import OpenAI
import ray
from ray.util import ActorPool
from tqdm import tqdm
def read_file(file_path: str) -> list[str]:
"""
@grapeot
grapeot / gpt4o.py
Created June 17, 2024 15:11
使用GPT-4o识别云量
import os
import base64
import requests
import json
def get_cloudiness(image_path):
# 读取OpenAI API Key
api_key = os.getenv('OPENAI_API_KEY')
if not api_key:
@grapeot
grapeot / auto_focus.py
Created February 28, 2024 23:04
A reference implementation of auto-focusing by local entropy. https://yage.ai/auto-focus.html
"""
A class supporting the auto-focusing of a telescope.
"""
from astropy.io import fits
from astropy.stats import sigma_clipped_stats
from photutils.detection import DAOStarFinder
from glob import glob
from tqdm import tqdm
from typing import List, Dict, Any
from time import time
@grapeot
grapeot / track.py
Last active November 1, 2022 07:34
ZWO AM5自动跟踪红色滑块
import zwoasi
import cv2
import numpy as np
from simple_pid import PID
from alpaca import Telescope
def initializeCamera():
zwoasi.init('./ASICamera2.dll')
camera = zwoasi.Camera(0)
controls = camera.get_controls()
@grapeot
grapeot / extractFeatures.py
Created April 24, 2017 03:14
Use Caffe2 to extract features
# Initial imports
import os
import sys
import logging
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
from caffe2.proto import caffe2_pb2
import numpy as np
import skimage.io
import skimage.transform
set -g default-terminal "screen-256color"
set -g status-right '#[fg=black] #(hostname), %H:%M, #(uptime | egrep -o "average.*"|perl -pe "s|average: ||")'
setw -g automatic-rename
# mouse mode
set -g mode-mouse on
setw -g mouse-select-window on
setw -g mouse-select-pane on
setw -g mode-keys vi
@grapeot
grapeot / .zshrc
Last active August 29, 2015 13:55
my .zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases
@grapeot
grapeot / install_numba.sh
Created November 19, 2013 23:37
install numba in Debian 7
sudo apt-get install llvm cython python-pip python-llvm
git clone https://github.com/numba/numba.git # Not sure whether this is necessary
cd numba
sudo pip install -r requirements.txt
sudo pip install numba
@grapeot
grapeot / gitemail.php
Created September 24, 2013 22:22
A php script to send auto email notifications when a github repo is pushed. More details available at http://grapeot.me/automatic-email-notification-on-github-pushes.html.
<?
$r = 'This is an automatically generated message notifying you that someone pushed new commits to the github repo <project>.' . " Don't forget to do git pull before your editing.\r\n\r\nEdit summary: \r\n";
$payload = $_REQUEST['payload'];
preg_match_all('@"name":"([\w ]*?)","email@', $payload, $matches);
$authors = $matches[1];
preg_match_all('@"message":"([^"]*)"@', $payload, $matches);
$messages = $matches[1];
preg_match_all('@"url":"([^"]*)"@', $payload, $matches);
$links= $matches[1];
for ($i = 0; $i < count($messages) - 1; ++$i)