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
# 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"); |
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 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: |
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
# 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 |
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 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) |
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 | |
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********,把*替换正确数值 |
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 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() |
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 gradio as gr | |
from utils import read_image_from_stream | |
# For Gradio | |
f = read_image_from_stream() | |
def func(data): | |
image = "" | |
while True: |
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 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): |
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
# 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) |
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
# 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) |
NewerOlder