Skip to content

Instantly share code, notes, and snippets.

View georgepar's full-sized avatar

Giorgos Paraskevopoulos georgepar

View GitHub Profile
import argparse
import sys
from stream2sentence import generate_sentences
def file_or_pipe_input(file_path=None):
if file_path:
with open(file_path, "r", encoding="utf-8") as file:
yield file.read()
else:
from typing import Dict, Optional
import torch
import torch.nn as nn
from torchcrf import CRF
from transformers import AutoModel
class TransformerSlidingWindower(nn.Module):
"""Apply model on a strided sliding window
@georgepar
georgepar / poetry.lock
Last active April 8, 2021 18:22
Dependencies
[[package]]
name = "absl-py"
version = "0.12.0"
description = "Abseil Python Common Libraries, see https://github.com/abseil/abseil-py."
category = "main"
optional = false
python-versions = "*"
[package.dependencies]
six = "*"
@georgepar
georgepar / README.md
Last active June 12, 2020 14:08
ACL 2020 papers.csv creator

How to run

  • Download this as a tab separated file
  • Run python create_papers_csv.py --inp acl2020_accepted_papers.tsv --out out.csv --n-keywords 5

Create the embeddings and projection files

  • python embeddings.py ../acl-2020-virtual-conference-sitedata/papers.csv
  • python reduce.py ../acl-2020-virtual-conference-sitedata/papers.csv embeddings.torch > ../sitedata_acl2020/papers_projection.json --projection-method [tsne|umap]
@georgepar
georgepar / dataloading.py
Created December 27, 2019 12:25
Dataloading helper for Pattern Recognition Lab 3 in NTUA
import numpy as np
import gzip
import copy
from sklearn.preprocessing import LabelEncoder
from torch.utils.data import Dataset
from torch.utils.data import SubsetRandomSampler, DataLoader
class_mapping = {
'Rock': 'Rock',
@georgepar
georgepar / dataloading.py
Created December 27, 2019 12:25
Dataloading helper for Pattern Recognition Lab 3 in NTUA
import numpy as np
import gzip
import copy
from sklearn.preprocessing import LabelEncoder
from torch.utils.data import Dataset
from torch.utils.data import SubsetRandomSampler, DataLoader
class_mapping = {
'Rock': 'Rock',
import os
import requests
from torch.utils.data import Dataset
from silx.io.dictdump import h5todict
def download_file(url, fname):
resp = requests.get(url, stream=True)
with open(fname, 'wb') as fd:
for datum in resp.iter_content():
@georgepar
georgepar / python.json
Created May 31, 2019 07:54
VS Code snippets
{
"Create Class": {
"prefix": "cls",
"body": [
"class ${1:MyClass}(${2:object}):",
" def __init__(self, ${3:*args}, ${4:**kwargs}):",
" super(${1:MyClass}, self).__init__(${5:*args}, ${6:**kwargs})"
],
"description": "Create Class"
},
import mlflow
import mlflow.pytorch
class MlFlowLogger(object):
def __init__(self,
uri=None,
experiment_name=None,
model_path='models',
**params):
import mlflow
import mlflow.pytorch
class MlFlowLogger(object):
def __init__(self,
uri=None,
experiment_name=None,
model_path='models',
**params):