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
| 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
| # !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
| # 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 | |
| import csv | |
| src = "en" # source language | |
| trg = "he" # target language |
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.
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
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| #pip install tokenizers==0.10.3 transformers==4.8.0 | |
| tokenizer = AutoTokenizer.from_pretrained("Norod78/distilgpt2-base-pretrained-he") | |
| model = AutoModelForCausalLM.from_pretrained("Norod78/distilgpt2-base-pretrained-he", pad_token_id=tokenizer.eos_token_id) | |
| prompt_text = "הנבחרת האולימפית של ישראל זכתה השנה" | |
| max_len = 50 |
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 onnx | |
| onnx_model = onnx.load('./input.onnx') | |
| #Rename 'inp' to 'inst' | |
| endpoint_names = ['inp', 'inst'] | |
| for i in range(len(onnx_model.graph.node)): | |
| for j in range(len(onnx_model.graph.node[i].input)): | |
| if onnx_model.graph.node[i].input[j] == endpoint_names[0]: |