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
def get_state_v0(state): | |
url = make_url(state) | |
IN = load_gif_url(url) | |
#Drop the text at the top | |
IN = IN[150:] | |
#Convert 3 color channels to 1 | |
IN_bw = get_bw(IN) |
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
def get_bw(src): | |
return cv2.cvtColor(src, cv2.COLOR_BGR2GRAY) | |
def show_color(src): | |
plt.imshow(cv2.cvtColor(src, cv2.COLOR_BGR2RGB)) | |
_ = plt.xticks([]), plt.yticks([]) | |
def show_bw(bw): | |
plt.imshow(bw, cmap='gray') | |
_ = plt.xticks([]), plt.yticks([]) |
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
from PIL import Image | |
import requests | |
import tempfile | |
def load_gif_url(url): | |
with tempfile.NamedTemporaryFile(suffix=".gif") as f: | |
f.write(requests.get(url).content) | |
f.flush() | |
img = Image.open(f.name) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder