Skip to content

Instantly share code, notes, and snippets.

@Norod
Norod / apple_openelm-3b_cuda_gradio-demo.ipynb
Created April 24, 2024 17:27
apple_OpenELM-3B_cuda_Gradio-Demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Norod
Norod / apple_openelm-270m_cpu_gradio-demo.ipynb
Created April 24, 2024 17:08
Apple_OpenELM-270M_cpu_Gradio-Demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Norod
Norod / heb_tokenize_compare.py
Created March 18, 2024 09:21
Compare Hebrew efficiency in various tokenizers (The lower the number, the better)
from transformers import AutoTokenizer
from transformers import LlamaTokenizerFast
#tokenizer_yam = AutoTokenizer.from_pretrained("yam-peleg/Hebrew-Gemma-11B-V2")
tokenizer_grok = LlamaTokenizerFast.from_pretrained('Xenova/grok-1-tokenizer')
tokenizer_gemma = AutoTokenizer.from_pretrained("google/gemma-7b-it")
tokenizer_aya101 = AutoTokenizer.from_pretrained("CohereForAI/aya-101")
tokenizer_gpt2 = AutoTokenizer.from_pretrained("gpt2")
@Norod
Norod / aya-101-gradio-with-streamer.py
Created March 15, 2024 11:22
A simple inference script for CohereForAI/aya-101 with Gradio based UI, RTL support and Streaming text
import torch
import gradio as gr
from threading import Thread
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, TextIteratorStreamer
checkpoint = "CohereForAI/aya-101"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint, device_map='auto', torch_dtype=torch.bfloat16)
To enhance readability, I'll add more line breaks within the sections to make the text easier to follow. Here's a revised version with additional spacing:
"You are ChatGPT, a large language model trained by OpenAI, based on the GPT-4 architecture."
"Image input capabilities: Enabled"
"Conversation start date: 2023-12-19T01:17:10.597024"
"Deprecated knowledge cutoff: 2023-04-01"
@Norod
Norod / README.MD
Last active January 24, 2024 20:57
Head Crop with Face Landmarks

Head Crop with Face Landmarks

This Python script utilizes the dlib library for face detection and facial landmarks to detect and crop a human head in an image. The detect_and_crop_head function takes an input image file, detects the face using a pre-trained 5-point facial landmarks model, and crops the image to include the entire head with a 1:1 aspect ratio. The cropping is adjusted based on the roll and yaw angles calculated from the facial landmarks.

Dependencies

  • Python 3
  • OpenCV
  • dlib
  • NumPy
@Norod
Norod / README.MD
Created December 14, 2023 09:15
Detect and Crop Head in Image

Detect and Crop Head in Image

This Python script leverages the OpenCV library for face detection and the PIL (Pillow) library for image processing to detect and crop a human head in an image. The detect_and_crop_head function takes an input image file, detects the face using a pre-trained Haar Cascade classifier, and crops the image to include the entire head with a 1:1 aspect ratio. The cropping is achieved by specifying a factor that determines the size of the cropped region around the detected face. Adjust the factor parameter based on the specific requirements of your images.

Usage:

input_image_path = "path/to/your/input/image.jpg"
output_image_path = "path/to/save/cropped/head.jpg"
detect_and_crop_head(input_image_path, output_image_path, factor=1.5)
@Norod
Norod / colab-hebrewgpt-gradiodemo.ipynb
Last active March 7, 2024 08:30
colab-hebrewgpt-gradiodemo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Norod
Norod / sdxl_10_gen_test.py
Created July 28, 2023 18:10
Testing stable-diffusion-xl 1.0 generation pipelines using simple random prompts
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
import torch
#////////////////////////////////////////////////////////////////
guidance_scale=7.5
steps=40
width=1024
height=1024
base_model_id_str = "sdxl_10"
@Norod
Norod / multidiffusion_panorama_withmetadataqolupdatesbynorod78.ipynb
Created July 20, 2023 20:32
MultiDiffusion_Panorama_withMetadataQoLUpdatesByNorod78.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.