Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
murphyk committed May 26, 2023
1 parent 4a14112 commit fe8a163
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 37 deletions.
58 changes: 30 additions & 28 deletions deprecated/scripts/colab_utils.py
Original file line number Diff line number Diff line change
@@ -1,65 +1,67 @@
import superimport
# import superimport

import os
import cv2 # open CV 2
import cv2 # open CV 2

def compute_image_resize(image, width = None, height = None):

def compute_image_resize(image, width=None, height=None):
# From https://stackoverflow.com/questions/44650888/resize-an-image-without-distortion-opencv
# initialize the dimensions of the image to be resized and
# grab the image size
dim = None
(h, w) = image.shape[:2]

# check to see if the width is None
if width is None:
# calculate the ratio of the height and construct the
# dimensions
r = height / float(h)
dim = (int(w * r), height)

# otherwise, the height is None
else:
# calculate the ratio of the width and construct the
# dimensions
r = width / float(w)
dim = (width, int(h * r))

return dim
def image_resize(img_path,size=None,ratio=None):


def image_resize(img_path, size=None, ratio=None):
if not size:
size=[0,480]
size = [0, 480]
img = cv2.imread(img_path, cv2.IMREAD_UNCHANGED)
dim = compute_image_resize(img, height=size[1])
img = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)
img = cv2.resize(img, dim, interpolation=cv2.INTER_AREA)
return img


def git_ssh(git_command, email, username, verbose=False):
'''Execute a git command via ssh from colab.
Details in https://github.com/probml/pyprobml/blob/master/book1/intro/colab_intro.ipynb
"""Execute a git command via ssh from colab.
Details in
https://github.com/probml/pyprobml/blob/master/notebooks/tutorials/colab_intro.ipynb
Authors: Mahmoud Soliman <[email protected]> and Kevin Murphy <[email protected]>
'''
git_command=git_command.replace(r"https://github.com/","[email protected]:")
print('executing command via ssh:', git_command)
"""
git_command = git_command.replace(r"https://github.com/", "[email protected]:")
print("executing command via ssh:", git_command)
# copy keys from drive to local .ssh folder
if verbose:
print('Copying keys from gdrive to local VM')
os.system('rm -rf ~/.ssh')
os.system('mkdir ~/.ssh')
os.system('cp -r /content/drive/MyDrive/ssh/* ~/.ssh/')
os.system('ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts')
os.system('ssh -T [email protected]') # test
print("Copying keys from gdrive to local VM")
os.system("rm -rf ~/.ssh")
os.system("mkdir ~/.ssh")
os.system("cp -r /content/drive/MyDrive/ssh/* ~/.ssh/")
os.system("ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts")
os.system("ssh -T [email protected]") # test
# git commands
if verbose:
print('Executing git commands')
os.system('git config --global user.email {}'.format(email))
os.system('git config --global user.name {}'.format(username))
print("Executing git commands")
os.system("git config --global user.email {}".format(email))
os.system("git config --global user.name {}".format(username))
os.system(git_command)
# cleanup
if verbose:
print('Cleanup local VM')
os.system('rm -r ~/.ssh/')
print("Cleanup local VM")
os.system("rm -r ~/.ssh/")
os.system('git config --global user.email ""')
os.system('git config --global user.name ""')
os.system('git config --global user.name ""')
Binary file modified tikz/bandits.pdf
Binary file not shown.
20 changes: 11 additions & 9 deletions tikz/bandits.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\documentclass[tikz, border=2pt]{standalone}
\documentclass[tikz, border=1cm]{standalone}
% main document, called main.tex
\usepackage{tikz}
\usetikzlibrary{bayesnet}
Expand Down Expand Up @@ -28,25 +28,27 @@
\node[rect, fill = black!20, right = 0.8cm of x1](a1){$a_1$};
\node[obs, above = 0.6 of a0](r0){$r_0$};
\node[obs, above = 0.6 of a1](r1){$r_1$};
\node[emptynode, right= 2cm of s2](e1){$\cdots$};
\node[emptynode, right= 2cm of b2](e2){$\cdots$};

%\node[emptynode, right= 2cm of s2](e1){$\cdots$};
%\node[emptynode, right= 2cm of b2](e2){$\cdots$};

\edge{s0}{b0,r0};
\edge{b0}{b1,a0};
\edge{b1}{b2};
\edge{a0}{r0,s1};
\edge{a0}{r0};
\edge{s1}{r1,b1};
\edge{b1}{b2, a1};
\edge{s2}{b2};
\edge{r1,a1}{b2};
\edge{a1}{r1,s2};
\edge{a1}{r1};
\edge{a0,r0}{b1};
%\edge{s2}{e1};
\edge{b2}{e2};

%\edge{s2}{e1};
%\edge{b2}{e2};
\node[draw=black,thin,fit=(s0)(s1)(s2), rectangle,inner sep=10pt](rect1) {};
\node[const, above = 2.9cm of a1](){environment};
% \node[const, above = 2.9cm of a1](){environment};
\node[draw=black,thin,fit=(b0)(b1)(b2), rectangle,inner sep=10pt](rect1) {};
\node[const, below = 1.9cm of a1](){agent};
% \node[const, below = 1.9cm of a1](){agent};

\end{tikzpicture}
\end{document}

0 comments on commit fe8a163

Please sign in to comment.