Skip to content

Instantly share code, notes, and snippets.

View benhoyle's full-sized avatar

Ben Hoyle benhoyle

View GitHub Profile
nodes:
- id: webcam
custom:
source: https://huggingface.co/datasets/dora-rs/dora-idefics2/raw/main/operators/opencv_stream.py
outputs:
- image
- id: idefics2
operator:
python: https://huggingface.co/datasets/dora-rs/dora-idefics2/raw/main/operators/idefics2_op.py
inputs:
@nreimers
nreimers / Opensearch_int8_search.py
Last active March 27, 2024 12:29
OpenSearch int8 search with Cohere
# This code shows how to index data using Cohere Embed v3 byte (int8) embeddings.
# This gives you a 4x memory reduction while keeping 99.9% of the search quality.
# Make sure to have OpenSearch running with at least version 2.9. E.g. by using docker:
# docker run -d -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" opensearchproject/opensearch:2.11.1
# You also need the OpenSearch python client installed.
# pip install cohere opensearch-py
from opensearchpy import OpenSearch, helpers
import cohere
@adrianlacatus
adrianlacatus / nvidia.md
Created October 2, 2021 20:08 — forked from bitsurgeon/nvidia.md
install Nvidia driver on Ubuntu with Secure Boot

Install Nvidia Driver on Ubuntu 18.04.3

Secure Boot

This section applies to machines with Secure Boot, such as ThinkPad.

  1. Before installation, switch to "Discrete Graphics" in BIOS, if both Intel and Nvidia graphics are present.
  2. During installation, make sure to select the "Install third-party software for graphics and Wi-Fi hardware and addition media formats" in "Updates and other software" screen.
  3. Select "Configure Secure Boot", and set password.
  4. Continue Ubuntu installation as normal.
@giuseppebonaccorso
giuseppebonaccorso / twitter_sentiment_analysis_convnet.py
Last active March 16, 2020 19:26
Twitter Sentiment Analysis with Gensim Word2Vec and Keras Convolutional Networks
import keras.backend as K
import multiprocessing
import tensorflow as tf
from gensim.models.word2vec import Word2Vec
from keras.callbacks import EarlyStopping
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Flatten
from keras.layers.convolutional import Conv1D
@ilblackdragon
ilblackdragon / seq2seq.py
Last active May 22, 2022 21:42
Example of Seq2Seq with Attention using all the latest APIs
import logging
import numpy as np
import tensorflow as tf
from tensorflow.contrib import layers
GO_TOKEN = 0
END_TOKEN = 1
UNK_TOKEN = 2
@sourceperl
sourceperl / detect_tones.py
Last active January 9, 2023 05:37
Display sound spectral view with scipy FFT and matplotlib
#!/usr/bin/python3
# detect tones in sound spectrum with scipy FFT
# here sound source is a USB microphone with ALSA (channel 1)
from collections import deque
import struct
import sys
import time
import threading
@rouseguy
rouseguy / seq2seq_keras.py
Created July 19, 2016 09:17
Sequence to Sequence - Keras
%%time
# -*- coding: utf-8 -*-
'''An implementation of sequence to sequence learning for performing addition
Input: "535+61"
Output: "596"
Padding is handled by using a repeated sentinel character (space)
Input may optionally be inverted, shown to increase performance in many tasks in:
"Learning to Execute"
http://arxiv.org/abs/1410.4615
@danijar
danijar / blog_tensorflow_scope_decorator.py
Last active January 17, 2023 01:58
TensorFlow Scope Decorator
# Working example for my blog post at:
# https://danijar.github.io/structuring-your-tensorflow-models
import functools
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
def doublewrap(function):
"""
A decorator decorator, allowing to use the decorator to be used without
@artizirk
artizirk / 01-video.py
Last active November 22, 2022 11:48
Python v4l2 webcam capture test using PlayStation 3 camera. More advanced script can be found here: https://github.com/eik-robo/zoidberg/blob/master/examples/purepy_video_capture.py
#!/usr/bin/env python3
from v4l2 import *
import fcntl
import mmap
import select
import time
vd = open('/dev/video0', 'rb+', buffering=0)
@EderSantana
EderSantana / CATCH_Keras_RL.md
Last active October 16, 2023 08:32
Keras plays catch - a single file Reinforcement Learning example