This file contains 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
#pip install hebrew | |
import sys | |
from hebrew import Hebrew | |
def open_input_file_name(file_name): | |
try: | |
file = open(file_name, "r") | |
return file | |
except FileNotFoundError: |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
import tiktoken | |
test_string = "האיש האחרון עלי אדמות ישב לבד בחדרו, כשלפתע נשמעה דפיקה בדלת" | |
enc = tiktoken.get_encoding("cl100k_base") | |
encoded_text = enc.encode(test_string) | |
print(f'num of characters = {len(test_string)} encoded length = {len(encoded_text)} (cl100k_base)') | |
decoded_text = enc.decode(encoded_text) | |
assert decoded_text == test_string |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler | |
import torch | |
#//////////////////////////////////////////////////////////////// | |
guidance_scale=8.0 | |
steps=40 | |
width=512 | |
height=512 |
This file contains 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
from transformers import AutoTokenizer | |
tokenizer_heb = AutoTokenizer.from_pretrained("Norod78/hebrew-gpt_neo-small") | |
tokenizer_eng = AutoTokenizer.from_pretrained("gpt2") | |
prompt_text="שלום" | |
prompt_length = len(prompt_text) | |
encoded_prompt_heb = tokenizer_heb.encode(prompt_text, add_special_tokens=False, return_tensors="pt") | |
num_of_tokenz_heb = encoded_prompt_heb.size()[-1] | |
print(f"Hebrew tokenizer: Tokens = {num_of_tokenz_heb} length = {prompt_length}") #Hebrew tokenizer: Tokens = 1 length = 4 | |
encoded_prompt_eng = tokenizer_eng.encode(prompt_text, add_special_tokens=False, return_tensors="pt") |
This file contains 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
import torch | |
import requests | |
from PIL import Image | |
from diffusers import StableDiffusionDepth2ImgPipeline | |
def main(): | |
device = "cuda" if torch.cuda.is_available() else "cpu" | |
dtype = torch.float16 if device == "cuda" else torch.float32 | |
pipe = StableDiffusionDepth2ImgPipeline.from_pretrained( |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
import requests | |
import torch | |
from PIL import Image | |
from io import BytesIO | |
from diffusers import StableDiffusionImg2ImgPipeline, DPMSolverMultistepScheduler | |
def main(): | |
#//////////////////////////////////////////// | |
seed = 42 |
This file contains 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
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler | |
import torch | |
def main(): | |
#//////////////////////////////////////////// | |
seed = 42 | |
model = "Norod78/sd-simpsons-model" | |
#//////////////////////////////////////////// |