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
# Code adapted from:
# https://www.pyimagesearch.com/2018/08/20/opencv-text-detection-east-text-detector/
# USAGE
# python text_detection_video.py --east east_model_float16.tflite
# import the necessary packages
from imutils.video import VideoStream
from imutils.video import FPS
from imutils.object_detection import non_max_suppression
import tensorflow as tf
@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
#
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""
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.

Machine information

Parameter Value
OS Ubuntu 20.04.5
Python 3.8.10
CUDA 11.8
TensorFlow 2.10.1
TensorRT 8.5.1