Skip to content

Instantly share code, notes, and snippets.

@piyush01123
piyush01123 / naiveBayes.py
Last active July 8, 2025 04:52
Naive Bayes classification of MNIST images http://web.iitd.ac.in/~bspanda/BY.pdf
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, classification_report
# Load data
digits = datasets.load_digits()
trainX, testX, trainY, testY = train_test_split(digits.images, digits.target, test_size=0.2, random_state=42)
# mnist = datasets.fetch_openml('mnist_784', version=1, as_frame=False)
@piyush01123
piyush01123 / cam_app.py
Last active January 21, 2021 21:08
Live stream camera feed
import cv2
import flask
app = flask.Flask("CamApp")
def gen():
cap = cv2.VideoCapture(0)
while True:
_, frame = cap.read()
yield (b'--frame\r\n'