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
prompt = """You intelligently transform text files into markdown format. | |
From the content infer the following formats: | |
- Heading level 1 | |
- Heading level 2 | |
- Blockquotes | |
- Bullet lists | |
- Number lists | |
- Preformatted text | |
EXAMPLE TEXT |
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
# robgonsalves | |
# Write some Python code to get ULRs to all images in my Flickr account. | |
# ChatGPT | |
# To get URLs to all images in your Flickr account, you can use the Flickr API and the flickr.photos.search method to retrieve the | |
# list of photos, and then construct the URLs based on the photo IDs and server IDs. | |
# Here's an example Python code that retrieves the URLs to all photos in your Flickr account using the flickrapi package: | |
import flickrapi |
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
pil_image = Image.open("test.png").convert('RGB') | |
result = Image.new(pil_image.mode, (w_target, h_target)) | |
pad_x = (w_target-w_source)//2 | |
result.paste(pil_image, (pad_x, 0)) | |
sample = 8 | |
left_side = pil_image.crop((0, 0, sample, h_source)) | |
left_side = left_side.resize((1, h_source//2), Image.BILINEAR) | |
left_side = left_side.resize((pad_x, h_source), Image.BILINEAR) |
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
# Copyright © 2022 Robert A. Gonsalves | |
# Released under CC BY-SA 4.0 | |
# https://creativecommons.org/licenses/by-sa/4.0/ | |
import torchvision.transforms as T | |
import torch | |
prompt = "penguins skiing down a snowy mountain" | |
num_steps = 100 | |
init_rand_amount = 0.25 |
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
import pke | |
extractor = pke.unsupervised.TopicRank() | |
num_keywords = 10 | |
phrase = "penguins skiing down a snowy mountain" | |
extractor.load_document(input=phrase) | |
extractor.candidate_selection(pos={'NOUN', 'PROPN', 'ADJ', 'VERB'}) | |
extractor.candidate_weighting() |
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
import wikipedia | |
def check_in_wiki(name): | |
name_parts = name.split() | |
wiki_results = wikipedia.search(name) | |
for w in wiki_results: | |
w = w.lower() | |
match_all_parts = True | |
for n in name_parts: | |
n = n.lower() | |
if n == "the" or n == "a": |
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
import requests | |
from bs4 import BeautifulSoup | |
import pandas as pd | |
df_friends = pd.DataFrame(columns=["id", "title", "summary", "meta.season", "meta.episode"]).set_index("id") | |
for season in range(1, 11): | |
url = "https://en.wikipedia.org/wiki/Friends_(season_" + str(season) + ")#Episodes" | |
page = requests.get(url) | |
soup = BeautifulSoup(page.text, "html.parser") |
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 keybert import KeyBERT | |
kw_model = KeyBERT() | |
summary = "After leaving her fiancé, Barry, at the altar, Rachel finds herself in Central Perk Café, soaking wet in her wedding dress." | |
theme = kw_model.extract_keywords(summary, keyphrase_ngram_range=(1, 3))[0][0] | |
print(theme) |
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 torchvision import transforms as T | |
import torch | |
texture_amount = 0.15 | |
texture_size = 9 | |
noise = torch.normal(0, texture_amount*texture_size**(1./3.), | |
size=[resized.shape[0], 1, resized.shape[2], resized.shape[3]]).to(device) | |
noise = noise.repeat(1, 3, 1, 1) |
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
import wikipedia | |
print(wikipedia.search("Albert Einstein")[:5]) | |
def check_in_wiki(name): | |
name_parts = name.split() | |
wiki_results = wikipedia.search(name) | |
for w in wiki_results: | |
w = w.lower() | |
match_all_parts = True | |
for n in name_parts: |
NewerOlder