Skip to content

Instantly share code, notes, and snippets.

View AIAnytime's full-sized avatar
👋
On vacation

AI Anytime AIAnytime

👋
On vacation
View GitHub Profile
@AIAnytime
AIAnytime / script.txt
Created November 8, 2023 10:53
Demo Script
Hello everyone, I am Sneha Roy, working as a full-stack AI Engineer and recently I have been working on Generative AI projects.
Today, I will be showcasing a solution that we have developed.........."GCC KB Chatbot".
it is an intelligent assistant tailored to simplify how call centers operate, in this case.. the GCC team.
GCC faces a significant challenge managing a high volume of tickets daily.
Each of these tickets is needing assistance, and each minute spent resolving one is critical.
Traditionally, our colleagues at GCC relied on a comprehensive but cumbersome Knowledge Base (KB) to find solutions,
which significantly contributed to longer turnaround times.
That's where our solution comes in... it drastically reduces the time taken to resolve tickets. Acting as a virtual agent,
@AIAnytime
AIAnytime / semantic_sim.py
Created October 30, 2023 10:02
semantic sim
import torch
from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = BertModel.from_pretrained('bert-base-uncased')
def encode(text):
tokens = tokenizer.tokenize(text)
tokens = ['[CLS]'] + tokens + ['[SEP]']
return tokenizer.convert_tokens_to_ids(tokens)
@AIAnytime
AIAnytime / top_p.text
Created October 30, 2023 08:09
top p top k thing
Nucleus sampling is a technique used in large language models to control the randomness and diversity of generated text. It works by sampling from only the most likely tokens in the model’s predicted distribution.
The key parameters are:
Temperature: Controls randomness, higher values increase diversity.
Top-p (nucleus): The cumulative probability cutoff for token selection. Lower values mean sampling from a smaller, more top-weighted nucleus.
Top-k: Sample from the k most likely next tokens at each step. Lower k focuses on higher probability tokens.
@AIAnytime
AIAnytime / deepfake_detection.py
Created May 27, 2023 14:43
Deepfake Audio Detection
import streamlit as st
import os
from tortoise.models.classifier import AudioMiniEncoderWithClassifierHead
from glob import glob
import io
import librosa
import plotly.express as px
import torch
import torch.nn.functional as F
import torchaudio
@AIAnytime
AIAnytime / stt.py
Created May 14, 2023 10:29
Speech to Text Assembly AI
# Assembly AI speech to text
def assemblyai_stt(audio_filename):
with open(audio_filename , "rb") as f:
response = requests.post(base_url + "/upload",
headers=headers,
data=f)
upload_url = response.json()["upload_url"]
data = {
"audio_url": upload_url
@AIAnytime
AIAnytime / pytube_audio.py
Created May 14, 2023 10:29
PyTube Audio Snippet
# PyTube function for YouTube video
def save_audio(url):
yt = YouTube(url)
video = yt.streams.filter(only_audio=True).first()
out_file = video.download()
base, ext = os.path.splitext(out_file)
file_name = base + '.mp3'
try:
os.rename(out_file, file_name)
except WindowsError:
@AIAnytime
AIAnytime / colorizer.py
Created April 16, 2023 08:21
Deoldify Images Streamlit
import streamlit as st
import fastai
from deoldify.visualize import *
def image_colorizer(url):
colorizer = get_image_colorizer(artistic=True)
source_url = url
render_factor = 35
watermarked = True
@AIAnytime
AIAnytime / reverse_sd.py
Created April 7, 2023 17:39
reverse_sd
# -*- coding: utf-8 -*-
"""Reverse SD.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1ci11cstH7uM9SPb6q2hb7f-IiZHYvcDq
"""
!pip install clip-interrogator==0.6.0
@AIAnytime
AIAnytime / spacy_streamlit_ner.py
Created February 18, 2023 16:12
Spacy Displacy Streamlit Code
HTML_WRAPPER = """<div style="overflow-x: auto; border: 1px solid #e6e9ef; border-radius: 0.25rem; padding: 1rem">{}</div>"""
@AIAnytime
AIAnytime / text_classifier_api.py
Created February 5, 2023 16:19
Text Classifier Fast API
from fastapi import FastAPI
import pickle
import numpy as np
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import MultinomialNB
app = FastAPI()
# Load the Tfidf and Naive Bayes models
tfidf = pickle.load(open("tf_idf.pkt", "rb"))