Skip to content

Instantly share code, notes, and snippets.

View wnma3mz's full-sized avatar
🎯
Focusing

wnma wnma3mz

🎯
Focusing
View GitHub Profile
@wnma3mz
wnma3mz / modeling_llama.py
Last active September 22, 2024 02:16
mergeLlama
# coding=utf-8
# see func load_custom_weights
# Copyright 2022 EleutherAI and the HuggingFace Inc. team. All rights reserved.
#
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
# and OPT implementations in this library. It has been modified from its
# original forms to accommodate minor architectural differences compared
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@wnma3mz
wnma3mz / process.py
Created November 26, 2023 12:34
pi_request_droid
import os
import argparse
import zipfile
import shutil
from datetime import datetime
from tqdm import tqdm
def jpg2mp4(file_list):
with open("input.txt", "w") as f:
for fname in file_list:
@wnma3mz
wnma3mz / mi_temp.py
Created November 25, 2023 14:20
mi_temp.py
# coding: utf-8
# Simplify from https://github.com/JsBergbau/MiTemperature2/blob/master/LYWSD03MMC.py
import argparse
import json
import logging
import math
import os
import re
import threading
import time
@wnma3mz
wnma3mz / MyCrossEntropyLossFunction.py
Last active September 14, 2023 03:19
MyTorchLoss.py
import torch
class MyCrossEntropyLossFunction(torch.autograd.Function):
@staticmethod
def forward(ctx, outputs, targets):
bs = outputs.size(0)
outputs = torch.softmax(outputs, dim=1)
loss = -torch.log(outputs[range(bs), targets])
ctx.save_for_backward(outputs, targets)
@wnma3mz
wnma3mz / slack_requests.py
Created June 10, 2023 08:30
send, command, receive msg from/to claude
import requests
import json
import time
# 创建bot时获取,注:需要在OAuth & Permission中添加若干权限,channels:history,channels:read,channels:write,groups:history,groups:read,groups:write,chat:write, im:history, im:write, mpim:history,mpim:read, mpim:write
token = "" # 固定
# F12 获取
user_token = "" # 固定
header_text = "" # 形如----WebKitFormBoundary********,把*替换正确数值
@wnma3mz
wnma3mz / app.py
Created March 18, 2023 09:27
gradio real-time update text
import gradio as gr
res = [] # It can only be stored in lists.
def generate_text():
for x in range(10):
res.append(str(x))
yield " ".join(res) # Here is to add to the display, not replace it.
yield " ".join(res)
f = generate_text()
@wnma3mz
wnma3mz / app.py
Last active March 18, 2023 09:22
video_flask_stream for gradio
import gradio as gr
from utils import read_image_from_stream
# For Gradio
f = read_image_from_stream()
def func(data):
image = ""
while True:
def cal_PR(TP, FN, FP, TN):
print(TP, FN, FP, TN)
P = TP / (TP + FP)
R = TP / (TP + FN)
Acc = (TP + TN) / (TP + TN + FP + FN)
return Acc, P, R
def count_tfnp(label, output, TN, FP, TP, FN):
# coding: utf-8
import json
import os
import subprocess
import pickle
import time
import base64
import numpy as np
from flask import (Blueprint, Flask, current_app, jsonify, make_response,
request, send_file)
# coding: utf-8
import json
import os
import subprocess
import pickle
import time
import base64
import numpy as np
from flask import (Blueprint, Flask, current_app, jsonify, make_response,
request, send_file)