Skip to content

Instantly share code, notes, and snippets.

View culurciello's full-sized avatar

Eugenio Culurciello culurciello

View GitHub Profile
@culurciello
culurciello / github2llm.py
Created February 21, 2024 20:40
a python script that can recursively parse a directory of files with specific files extensions and copy all the files into a text string. Must be able to take as argument the directory string, and must have a variable to specify multiple file extensions. It should save the text file as prompt.txt
# E. Culurciello, February 2024
# generated with Gemini:
# generate a python script that can recursively parse a directory of files with specific files extensions and copy all the files into a text string. Must be able to take as argument the directory string, and must have a variable to specify multiple file extensions. It should save the text file as prompt.txt
# run as: python github2llm.py my_dir/ "swift,json,xcodeproj,plist"
import os
import sys
def parse_directory(directory, extensions):
@culurciello
culurciello / my-pi-temp.sh
Last active January 12, 2024 18:54
Display the ARM CPU and GPU temperature of Raspberry Pi
#!/bin/bash
# Script: my-pi-temp.sh
# Purpose: Display the ARM CPU and GPU temperature of Raspberry Pi
# -------------------------------------------------------
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo "--- Measure Raspberry Pi CPU and GPU temperature ---"
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
echo "GPU $(vcgencmd measure_temp)"
echo "CPU temp=$((cpu/1000))'C"
<?xml version="1.0"?>
<robot name="visual">
<!-- E. Culurciello, March 2021 -->
<!-- basic 2-fingers gripper -->
<link name="base">
<inertial>
<mass value="1"/>
<inertia ixx="100" ixy="0" ixz="0" iyy="100" iyz="0" izz="100" />
<origin/>
</inertial>
@culurciello
culurciello / pytorchcheat.txt
Created April 22, 2017 11:44
pytorch info
http://pytorch.org/
https://discuss.pytorch.org/
https://github.com/pytorch/
https://github.com/bfortuner/pytorch-cheatsheet/blob/master/pytorch-cheatsheet.ipynb
elab@gpu5 ~/pytorch-examples/imagenet [master*]$ python3 main.py -a alexnet /media/SuperSSD/test-dataset-train-val/
=> creating model 'alexnet'
Traceback (most recent call last):
File "main.py", line 286, in <module>
main()
File "main.py", line 129, in main
train(train_loader, model, criterion, optimizer, epoch)
File "main.py", line 165, in train
output = model(input_var)
File "/usr/local/lib/python3.4/dist-packages/torch/nn/modules/module.py", line 210, in __call__
-- E. Culurciello, November 2016
-- test to see if table insert/remove is slower than table addressing
iters = 1e5
tablesize = 1e4
tab1={}
item = torch.randn(iters,1024)
sys.tic()
-- Xception model
-- a Torch7 implementation of: https://arxiv.org/abs/1610.02357
-- E. Culurciello, October 2016
require 'nn'
local nClasses = 1000
function nn.SpatialSeparableConvolution(nInputPlane, nOutputPlane, kW, kH)
local block = nn.Sequential()
block:add(nn.SpatialConvolutionMap(nn.tables.oneToOne(nInputPlane), kW,kH, 1,1, 1,1))
#! /usr/bin/env python3
# E. Culurciello, example of reinforcement learning in Python
#
# http://mnemstudio.org/path-finding-q-learning-tutorial.htm
# Game: 5 rooms connected through doors. One room is the goal-room.
# the goal of the game is to get to the goal-room
import numpy as np
# this is how rooms are connected:
-- Eugenio Culurciello
-- August 2016
-- a test to learn to code PredNet-like nets in Torch7
require 'nn'
require 'nngraph'
torch.setdefaulttensortype('torch.FloatTensor')
nngraph.setDebug(true)
local cv = require 'cv'
require 'cv.highgui'
require 'cv.imgproc'
require 'cv.imgcodecs'
require 'image'
-- local image = cv.imread{arg[1] or 'demo/lena.jpg', cv.IMREAD_GRAYSCALE}
imgT = image.lena()
imgT = image.lena()
imgTg = imgT[2] -- convert to grayscale and remove the first dimension