Skip to content

Instantly share code, notes, and snippets.

View TheLustriVA's full-sized avatar
🖥️
Coordinating Development Priorities

Pencoded TheLustriVA

🖥️
Coordinating Development Priorities
View GitHub Profile
@TheLustriVA
TheLustriVA / openrouter.py
Created January 20, 2024 06:16 — forked from thorhojhus/openrouter.py
Simple model picker for openrouter
import openai
from colorama import Fore
openai.api_base = "https://openrouter.ai/api/v1"
openai.api_key = "" #use own openrouter api key
system = "Your name is Bob. You are an intelligent and useful assistant that helps the user solve problems."
messages = [{"role" : "system", "content" : system},]
models = {
@TheLustriVA
TheLustriVA / python-as-service.md
Created September 20, 2022 15:06 — forked from wannadrunk/python-as-service.md
How to run Python script as systemd service.
  1. in Python script, make sure include #!/path/to/venv/python in the first line
  2. add a systemd service $ sudo systemctl edit --force --full name.service. In the editor complete at least these statments,
[Unit]
Description=Python Service
Wants=network.target
After=network.target

[Service]
ExecStartPre=/bin/sleep 10
@TheLustriVA
TheLustriVA / find_noise.py
Created September 16, 2022 01:23 — forked from trygvebw/find_noise.py
A "reverse" version of the k_euler sampler for Stable Diffusion, which finds the noise that will reconstruct the supplied image
import torch
import numpy as np
import k_diffusion as K
from PIL import Image
from torch import autocast
from einops import rearrange, repeat
def pil_img_to_torch(pil_img, half=False):
image = np.array(pil_img).astype(np.float32) / 255.0
@TheLustriVA
TheLustriVA / copilot_torch.py
Created September 3, 2022 12:06 — forked from jph00/copilot_torch.py
This is the code that copilot nearly entirely auto-generates for a function called `finetune` and a 1-line docstring
# I added all the imports by hand
import torch
from torchvision.datasets import ImageFolder
from torchvision import transforms,models
from torch import nn,optim
# For all functions including this one, I wrote the name and docstring, and sometimes also the param names
def finetune(folder, model):
"""fine tune pytorch model using images from folder and report results on validation set"""
if not os.path.exists(folder): raise ValueError(f"{folder} does not exist")
@TheLustriVA
TheLustriVA / pytz_time_zones.json
Last active September 2, 2022 15:00 — forked from heyalexej/pytz-time-zones.py
List of pytz time zones
{
"timezones": [
"Africa/Abidjan",
"Africa/Accra",
"Africa/Addis_Ababa",
"Africa/Algiers",
"Africa/Asmara",
"Africa/Asmera",
"Africa/Bamako",
"Africa/Bangui",