Skip to content

Instantly share code, notes, and snippets.

View qaixerabbas's full-sized avatar
🎯
Learning

Qaiser Abbas qaixerabbas

🎯
Learning
View GitHub Profile
@qaixerabbas
qaixerabbas / gen_image_stable_diff_nvidia.py
Created November 16, 2023 12:29
Generating Images via Nvidia Stable Diffusion XL API
import requests
import base64
# https://catalog.ngc.nvidia.com/orgs/nvidia/teams/ai-foundation/models/sdxl/api
API_KEY = "GET API KEY FROM NVIDIA PLAYGROUND FROM ABOVE LINK IN COMMENT"
invoke_url = "https://api.nvcf.nvidia.com/v2/nvcf/pexec/functions/89848fb8-549f-41bb-88cb-95d6597044a4"
fetch_url_format = "https://api.nvcf.nvidia.com/v2/nvcf/pexec/status/"
headers = {
from sentence_transformers import SentenceTransformer, util
import time
model = SentenceTransformer("all-MiniLM-L6-v2")
# Two lists of sentences
sentences1 = [
"I want to know about financial advice about car loan.",
]
# Import necessary libraries
# Need to install requests and openai using PIP
# Go to your openai page and get your API from there and update below in the code.
import openai
import requests
import os
# Set the OpenAI API key
openai.api_key = "YOUR_API_KEY"
'''
=> df
Location Parameter
0 A 10
1 A 20
2 B 14
3 B 16
4 C 15
5 C 9
6 C 6
@qaixerabbas
qaixerabbas / download_kaggle_datasets.py
Last active July 22, 2022 11:12
A simple code to download Kaggle datasets to specified directories
#pip install opendatasets
#this will download the datasets into the specified folder / Google Drive
#pass the kaggle dataset URL string as an argument to od.download() function
import opendatasets as od
od.download("https://www.kaggle.com/datasets/jangedoo/utkface-new")
import tensorflow as tf
#load required libraries and functions such as load_model etc
model_path = './example.h5' #path to your model
tf_model = tf.keras.models.load_model( model_path )
converter = tf.lite.TFLiteConverter.from_keras_model( tf_model )
tf_lite_model = converter.convert()
open( 'facenet.tflite' , 'wb' ).write( tf_lite_model )