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
ee |
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
# Check whether generation prompts always contain the subject word | |
# This check is necessary as FactualGPT requires subject word. | |
from tqdm import tqdm | |
def check_dataset_generation_prompt_contains_subject(data): | |
# check whether generation prompts always contain the subject word | |
invalid_index = [] | |
for i, d in tqdm(enumerate(data), total=len(data)): | |
subj = d['requested_rewrite']['subject'] | |
target = d['requested_rewrite']['target_true'] |
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 datetime | |
import argparse | |
import os | |
import random | |
import torch | |
import numpy as np | |
from omegaconf import OmegaConf | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--save_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
# ----------- Load models | |
from PIL import Image | |
import requests | |
from transformers import CLIPProcessor, CLIPModel | |
model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32") | |
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32") | |
def get_batches_of_text_input_ids(texts, batch_size=32): | |
outputs = [] |
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
# in MAC os : there is an error with declare -n | |
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
# reload the terminal | |
a1=(200, 1e-3) | |
a2=(300, 1e-4) | |
a3=(400, 1e-5) | |
candidates=(a1 a2 a3) | |
for p in ${candidates[@]} |
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 csv | |
import numpy as np | |
import datetime | |
def append_right(values, length=10): | |
return [str(v)+" "*(length - len(str(v))) for v in values] | |
delimiter = '\t' | |
# write header |
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
# -*- coding:utf-8 -*- | |
# Copyright to the Author : Bumjin Park | |
# Date : 2023.08.21 | |
import smtplib | |
from email.mime.text import MIMEText | |
from email.mime.multipart import MIMEMultipart | |
class Mail(): | |
def __init__(self, sender=<type your email>, password=<type your password>): |