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
from reg_resampler import resampler | |
# Initialize the resampler object | |
rs = resampler() | |
# You might recieve info about class merger for low sample classes | |
# Generate classes | |
Y_classes = rs.fit(train, target=target, bins=num_bins) | |
# Create the actual target variable | |
Y = df_train[target] |
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
from datasets import load_dataset | |
from transformers import AutoTokenizer | |
#load the dataset | |
dataset = load_dataset("imdb") | |
#create tokenizer | |
tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased") | |
def encode_batch(batch): | |
"""Encodes a batch of input data using the model tokenizer.""" |
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 numpy as np | |
from transformers import AutoConfig, AutoModelWithHeads | |
from transformers import TrainingArguments, Trainer, EvalPrediction | |
config = AutoConfig.from_pretrained( | |
"distilbert-base-uncased", | |
num_labels=2, | |
) | |
model = AutoModelWithHeads.from_pretrained( |
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 argparse | |
from transformers import AutoTokenizer | |
import torch | |
import numpy as np | |
from collections import Counter | |
import pandas as pd | |
import numpy as np | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F |
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
[verbose]: Creating arXiv submission AutoTeX object | |
[verbose]: *** Using TeX Live 2020 *** | |
[verbose]: Calling arXiv submission AutoTeX process | |
[verbose]: TeX/AutoTeX.pm: admin_timeout = minion | |
[verbose]: <Copyright-logo.txt> is of type 'unknown'. | |
[verbose]: <Copyright-lppl.txt> is of type 'unknown'. | |
[verbose]: <Copyright.txt> is of type 'unknown'. | |
[verbose]: <Makefile> is of type 'unknown'. | |
[verbose]: <README.md> is of type 'unknown'. |
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 convert_annot_to_yolov5(x_min, y_min, x_max, y_max, img): | |
""" | |
Convert annotations into required yolov5 formamt | |
x_center, y_center, width, height | |
""" | |
w = x_max - x_min | |
h = y_max - y_min | |
imgheight,imgwidth = img.shape[0], img.shape[1] | |
#x,y,w,h = a['hbox'] //for each tag in gtboxes object | |
""" |
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
for i, data in enumerate(test_dataloader, 0): | |
x0, x1 = data | |
concat = torch.cat((x0, x1), 0) | |
output1, output2 = model(x0.to(device), x1.to(device)) | |
eucledian_distance = F.pairwise_distance(output1, output2) | |
if label == torch.FloatTensor([[0]]): | |
label = "Original Pair Of Signature" | |
else: | |
label = "Forged Pair Of Signature" |
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
from waitress import serve | |
import io | |
from flask import Flask, request,jsonify | |
from PIL import Image | |
import base64 | |
from spacymodels.activeorpassive.model import find_passive_or_active | |
import spacy | |
import pandas as pd | |
import torch | |
import numpy as np |
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 re | |
import wandb | |
from datasets import load_dataset, concatenate_datasets | |
from functools import partial | |
import logging | |
logger = logging.getLogger(__name__) | |
def load_hf_format_dataset(file_path,split): |
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 time | |
import json | |
import multiprocessing | |
from multiprocessing import Pool | |
txt_path = "tamil_dataset.txt" | |
json_path = "tamil_final_dataset.json" | |