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 numpy as np | |
import matplotlib.pyplot as plt | |
from PIL import Image | |
fname = 'daniel-plan-u1WcrpHk6Pg-unsplash.jpg' | |
image = Image.open(fname).convert("L") | |
img_mat = np.asarray(image) | |
plt.imshow(img_mat, cmap='gray', vmin=0, vmax=255) | |
plt.show() |
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 wolframalpha | |
client = wolframalpha.Client("lilpumpsaysnopeeking") | |
import wikipedia | |
import PySimpleGUI as sg | |
sg.theme('DarkPurple') | |
layout =[[sg.Text('Enter a command'), sg.InputText()],[sg.Button('Ok'), sg.Button('Cancel')]] | |
window = sg.Window('PyDa', layout) |
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
#!/usr/bin/env python3 | |
"""A recursive-descent arithmetic calculator.""" | |
import re | |
from collections import namedtuple | |
from fractions import Fraction | |
Parse = namedtuple('Parse', 'value, index') | |
FAILURE = Parse(None, -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 cv2 | |
guardcam = cv2.VideoCapture(0) | |
while guardcam.isOpened(): | |
ret, frame1 = guardcam.read() | |
ret, frame2 = guardcam.read() | |
diff = cv2.absdiff(frame1, frame2) | |
gray = cv2.cvtColor(diff, cv2.COLOR_RGB2GRAY) | |
blur = cv2.GaussianBlur(gray, (5, 5), 0) | |
_, thresh = cv2.threshold(blur, 20, 255, cv2.THRESH_BINARY) | |
dilated = cv2.dilate(thresh, None, iterations=3) |
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 struct | |
import zlib | |
from typing import BinaryIO, List, Tuple | |
Pixel = Tuple[int, int, int] | |
Image = List[List[Pixel]] | |
BLACK_PIXEL: Pixel = (0, 0, 0) | |
WHITE_PIXEL: Pixel = (255, 255, 255) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 logging | |
from argparse import ArgumentParser | |
logger = logging.getLogger(__name__) | |
def data(): | |
logger.info('run data func') | |
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 transformers import pipeline | |
from txtai.pipeline import HFTrainer | |
# Training data | |
data = [ | |
{"question": "What ingredient?", "context": "Pour 1 can whole tomatoes", "answers": "tomatoes"}, | |
{"question": "What ingredient?", "context": "Dice 1 yellow onion", "answers": "onion"}, | |
{"question": "What ingredient?", "context": "Cut 1 red pepper", "answers": "pepper"}, | |
{"question": "What ingredient?", "context": "Peel and dice 1 clove garlic", "answers": "garlic"}, | |
{"question": "What ingredient?", "context": "Put 1/2 lb beef", "answers": "beef"}, |
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 math | |
import numpy as np | |
from timebudget import timebudget | |
from multiprocessing import Pool | |
iterations_count = round(1e7) | |
def complex_operation(input_index): | |
print("Complex operation. Input index: {:2d}".format(input_index)) |
OlderNewer