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
| # crapify_images.py | |
| # Go over a folder of images and reduce the quality and/or add noise to some of them (Useful for making a Pix2Pix model more resilient) | |
| # @Norod78 | |
| import skimage | |
| import skimage.io | |
| import skimage.io._plugins.pil_plugin as pp | |
| import numpy as np | |
| from PIL import Image |
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
| # !pip install sentencepiece transformers tokenizers | |
| from transformers import MarianTokenizer, MarianMTModel | |
| from typing import List | |
| src = "en" # source language | |
| trg = "he" # target language | |
| model_name = f"Helsinki-NLP/opus-mt-{src}-{trg}" |
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
| import gradio as gr | |
| from transformers import pipeline | |
| title = "Hebrew GPT-Neo Demo" | |
| description = "" | |
| article = "<p></p>" | |
| examples = [ | |
| ['צחוקים ושיגועים'], | |
| ["למנשה פומפרניקל יש"], | |
| ["פעם אחת לפני שנים רבות"] |
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
| import jax | |
| from transformers import FlaxGPTNeoForCausalLM, AutoTokenizer | |
| #model_name = 'Norod78/hebrew-gpt_neo-tiny' | |
| #model_name = 'Norod78/hebrew_poetry-gpt_neo-small' | |
| model_name = 'Norod78/hebrew-gpt_neo-small' | |
| model = FlaxGPTNeoForCausalLM.from_pretrained(model_name) | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) |
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
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import transformers | |
| from transformers import AutoTokenizer, AutoModelForCausalLM, AutoModel, AutoConfig | |
| from transformers.onnx import FeaturesManager, convert, export | |
| from pathlib import Path | |
| import os | |
| model_id = 'gpt2-large' |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| #### pip install diffusers==0.2.4 transformers scipy ftfy | |
| #### | |
| from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler | |
| import torch | |
| def main(): | |
| seed = 1000 #1000, 42, 420 | |
| torch.manual_seed(seed) | |
| generator = torch.Generator() |
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
| import importlib | |
| checker_location = importlib.util.find_spec('diffusers.pipelines.stable_diffusion.safety_checker').origin | |
| checker_location_flax = importlib.util.find_spec('diffusers.pipelines.stable_diffusion.safety_checker_flax').origin | |
| blocker_location_flax = importlib.util.find_spec('diffusers.pipelines.stable_diffusion.pipeline_flax_stable_diffusion').origin | |
| #FlaxStableDiffusionPipeline | |
| import fileinput |
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
| #!pip install diffusers==0.2.4 | |
| import torch | |
| from diffusers import AutoencoderKL | |
| from PIL import Image | |
| import numpy as np | |
| from torchvision import transforms as tfms | |
| torch_device = None | |
| vae = None |