Skip to content

Instantly share code, notes, and snippets.

View mythrex's full-sized avatar
🎯
Focusing

Shivam Kaushik mythrex

🎯
Focusing
View GitHub Profile
{
"embeddings": [
{
"tensorName": "p_companion_embeddings",
"tensorShape": [
8424,
360
],
"tensorPath": "https://raw.githubusercontent.com/mythrex/p_companion_embedding/main/embeddings_l3_small.tsv",
"metadataPath": "https://raw.githubusercontent.com/mythrex/p_companion_embedding/main/embeddings_l3_meta_data.txt"
@mythrex
mythrex / run_bash.py
Created November 16, 2021 03:51
Command to run a bash command
def run_bash(cmd_to_run:str, skip_flag:int=1, print_output:int=0):
if skip_flag == 1:
start = time()
print(cmd_to_run)
p = Popen(cmd_to_run, shell=True, stdout=PIPE)
p.wait()
if print_output == 1:
print(p.communicate()[0])
print('Time taken: {} seconds.\n'.format(round(time() - start)))
else:
@mythrex
mythrex / get url title.py
Created November 10, 2021 17:19
Fetch url title
import requests
from bs4 import BeautifulSoup as bs
from tqdm.auto import tqdm
from joblib import Parallel, delayed
def get_title(url):
r = requests.get(url)
soup = bs(r.content, 'lxml')
return soup.title.string
@mythrex
mythrex / hashify.sh
Last active March 25, 2021 08:35
Run this bash file to hashify the names
for i in **/*.mp4; do
sum=$(echo -n "$i" | md5sum)
mv -- "$i" "${sum%% *}.${i##*.}"
done
@mythrex
mythrex / extract video part
Created January 8, 2021 06:36
Extract part of a video with a one-line command
ffmpeg -ss 00:00:30 -i orginalfile -t 00:00:05 -vcodec copy -acodec copy newfile
@mythrex
mythrex / gist:db841b1d53e141fc8b8793f7c48aa7e6
Last active September 20, 2020 11:27
wget from google drive
wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O FILENAME
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O "VOCtrainval_06-Nov-2007.tar" && rm -rf /tmp/cookies.txt
@mythrex
mythrex / Image resize script
Created September 7, 2020 05:43
Resize your image to a size
import argparse
from PIL import Image
import os
parser = argparse.ArgumentParser(description='Resize Image')
parser.add_argument('-path',
'--path',
help='Enter Image Path',
required=True)
@mythrex
mythrex / Deep dream text embeddings negative
Last active August 30, 2020 15:58
For hosting embeddings publically.
{
"embeddings": [
{
"tensorName": "Deep Dream over text.",
"tensorShape": [
78,
100
],
"tensorPath": "https://raw.githubusercontent.com/mythrex/deep_dream_textual_data/master/embeddings/embeddings_neg.tsv",
"metadataPath": "https://raw.githubusercontent.com/mythrex/deep_dream_textual_data/master/embeddings/vocab_neg'.tsv"
@mythrex
mythrex / dream.py
Last active August 20, 2020 13:36
Dreaming over text
def dream(input, model, iterations, lr):
""" Updates the image to maximize outputs for n iterations """
model.eval()
out, orig_embeddings, hidden = model(input)
model.train()
losses = []
embeddings_steps = []
embeddings = torch.autograd.Variable(
orig_embeddings.mean(1), requires_grad=True)
embeddings_steps.append(embeddings.clone())
@mythrex
mythrex / Deep dream text embeddings
Last active August 30, 2020 15:15
For hosting embeddings publically.
{
"embeddings": [
{
"tensorName": "Deep Dream over text.",
"tensorShape": [
78,
100
],
"tensorPath": "https://raw.githubusercontent.com/mythrex/deep_dream_textual_data/master/embeddings/embeddings_pos.tsv",
"metadataPath": "https://raw.githubusercontent.com/mythrex/deep_dream_textual_data/master/embeddings/vocab_pos.tsv"