Skip to content

Instantly share code, notes, and snippets.

View sayakpaul's full-sized avatar
:octocat:
Learn, unlearn and relearn.

Sayak Paul sayakpaul

:octocat:
Learn, unlearn and relearn.
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Adapted from https://github.com/borisdayma/dalle-mini/blob/main/tools/train/train.py
import random
from dataclasses import dataclass, field
from functools import partial
import jax
import jax.numpy as jnp
import numpy as np
from datasets import Dataset, load_dataset
@sayakpaul
sayakpaul / benchmark_onnx.py
Last active March 16, 2023 02:45
Scripts to benchmark OpenVINO and ONNX versions of Stable Diffusion on an AWS m6i.4xlarge instance.
import timeit
from optimum.onnxruntime import ORTStableDiffusionPipeline
from diffusers import StableDiffusionPipeline
import numpy as np
model_id = "runwayml/stable-diffusion-v1-5"
onnx_model_id = "sayakpaul/onnx-stable-diffusion-v1-5"
prompt = "a photo of an astronaut riding a horse on mars"

To run

export MODEL_NAME="CompVis/stable-diffusion-v1-4"
export DATASET_NAME="lambdalabs/pokemon-blip-captions"

accelerate launch --mixed_precision="fp16"  train_text_to_image.py   \
	--pretrained_model_name_or_path=$MODEL_NAME --dataset_name=$DATASET_NAME \
#!/usr/bin/env python
# coding=utf-8
# Copyright 2022 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import tensorflow as tf
tf.keras.mixed_precision.set_global_policy("mixed_float16")
import glob
import os
import keras_cv
import numpy as np
import PIL
"""
Usage: python run_semantic_segmentation.py
References:
* https://www.tensorflow.org/tutorials/images/segmentation#define_the_model
* https://huggingface.co/docs/transformers/main/en/tasks/semantic_segmentation
"""
import os
import uuid
"""
Referred from https://stackoverflow.com/questions/534839/how-to-create-a-guid-uuid-in-python
"""
import os
import uuid
from concurrent.futures import ThreadPoolExecutor
import pandas as pd
import requests
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.