This file contains hidden or 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
| # This script will transcribe an audio file (mp3, wav, etc.) to text and then clean the text using a local LLM model. | |
| # GETTING STARTED: | |
| # 1. Install openai | |
| # 2. Git clone a copy of ggerganov/whisper (https://github.com/ggerganov/whisper.cpp) | |
| # 3. Build the whisper binary | |
| # 4. Download the whisper model (largev2 is the most accurate for all languages, though the base model works pretty well for English). | |
| # 5. Install ffmpeg | |
| # 6. Install ollama (https://ollama.com/download) | |
| # 7. Download an LLM model (https://ollama.com/library) |
This file contains hidden or 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
| There are two prompts, that chain together. The first prompt does most of the work, and the second prompt organizes the sections. I found because of the nature of how LLMs write, I couldn't get just one prompt to never jump back and forth in topics. | |
| Prompt 1, which takes as input a raw transcript and generates a structured-text version... | |
| """# Instructions | |
| A transcript is provided below of a voice memo I recorded as a "note to self". please extract all the points made or thoughts described, and put them in bullet-point form. use nested bullet points to indicate structure, e.g. a top-level bullet for each topic area and sub-bullets underneath. use multi-level nesting as appropriate to organize the thinking logically. use markdown formatting with `*` instead of `-` for bullet points. | |
| DO NOT OMIT ANY POINTS MADE. This is not a summarization task — your only goal is to structure the thoughts there so they are logically organized and easy to read. Be concise because the reader is busy, but again DO NOT omit any |
This file contains hidden or 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
| -- Create a group | |
| CREATE ROLE readaccess; | |
| -- Grant access to existing tables | |
| GRANT USAGE ON SCHEMA public TO readaccess; | |
| GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; | |
| -- Grant access to future tables | |
| ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; |
This file contains hidden or 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
| w = slicer.modules.NeedleFinderInstance | |
| l = w.logic | |
| case = 69 | |
| case_hd_filename = '/home/guillaume/Projects/github/3rd_stage/results/results-%d.csv' % case | |
| stats_filename = '/home/guillaume/Projects/github/3rd_stage/results/avg-results-%s.csv' % args.filename | |
| user = 0 | |
| results, outliers = l.evaluate(script=True) # calculate HD distances | |
| for result in results: | |
| result[0:0] = [user, case] |
This file contains hidden or 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
| ### Use IJK coordinates to trigger an automatic needle segmentation | |
| # get the module logic | |
| w = slicer.modules.NeedleFinderWidget | |
| l = w.logic | |
| # create the template limit with the postion "templateLimit" | |
| templateLimit = [0,0,-67] # in RAS coordinates. use l.ijk2ras if you need to do the conversion from IJK to RAS | |
| l.fiducialNode = slicer.mrmlScene.CreateNodeByClass('vtkMRMLAnnotationFiducialNode') | |
| l.fiducialNode.Initialize(slicer.mrmlScene) |
This file contains hidden or 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
| """ Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
| import numpy as np | |
| import cPickle as pickle | |
| import gym | |
| # hyperparameters | |
| H = 200 # number of hidden layer neurons | |
| batch_size = 10 # every how many episodes to do a param update? | |
| learning_rate = 1e-4 | |
| gamma = 0.99 # discount factor for reward |