This file contains 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
def evaluate_board(): | |
if board.is_checkmate(): | |
if board.turn: | |
return -9999 | |
else: | |
return 9999 | |
if board.is_stalemate(): | |
return 0 | |
if board.is_insufficient_material(): |
This file contains 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 sklearn.cluster import KMeans | |
from tqdm.notebook import tqdm | |
from sklearn.metrics import silhouette_score | |
X = matrix | |
cluster_results_km = pd.DataFrame({'K': range(6, 25), 'SIL': np.nan}) | |
cluster_results_km.set_index('K', inplace=True) | |
for k in tqdm(cluster_results_km.index): | |
km_model = KMeans(n_clusters = k, init ='k-means++', random_state = 42) | |
y = km_model.fit_predict(X) |
This file contains 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 markdown | |
from IPython.core.display import HTML | |
art = createarticle_from_video('https://www.youtube.com/watch?v=oaNwxtLKyk0') | |
HTML(markdown.markdown(art)) |
This file contains 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 pytube import YouTube | |
import whisper | |
import openai | |
openai.api_key = YOUROPENAIKEY | |
from diffusers import StableDiffusionPipeline | |
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=YOUR_TOKEN) | |
def createarticle_from_video(url): | |
output = '' |
This file contains 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 diffusers import StableDiffusionPipeline | |
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=YOUR_TOKEN) | |
pipe = pipe.to("gpu") | |
image = pipe(titeltext).images[0] | |
image.save("news.jpg") |
This file contains 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 openai | |
openai.api_key = YOUROPENAIKEY | |
newstext = result["text"] | |
prompt = "Newstext:\n" + newstext + "\nTitle:\n *" | |
response = openai.Completion.create( | |
engine="text-davinci-002", | |
prompt=str(prompt), |
This file contains 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 whisper | |
model = whisper.load_model("base") | |
result = model.transcribe("bbc.mp4") | |
print(result["text"]) |
This file contains 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 pytube import YouTube | |
stream = YouTube('https://www.youtube.com/watch?v=oaNwxtLKyk0').streams.filter(only_audio=True).first() | |
stream.download('',"bbc.mp4") |
This file contains 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 openai | |
openai.api_key = "XXX-YOURKEY" | |
doc_per_cluster = 3 | |
for i in range(no_clusters): | |
print(f"Cluster {i} Topic:", end=" ") | |
docs = "\n".join(df[df.Cluster == i].Text.map(lambda x: x[:1000]).sample(doc_per_cluster, random_state=42).values) | |
response = openai.Completion.create( |
This file contains 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 seaborn as sns | |
from sklearn.manifold import TSNE | |
import matplotlib | |
import matplotlib.pyplot as plt | |
plt.rcParams['figure.figsize'] = (15, 8) | |
tsne = TSNE(n_components=2, perplexity=15, random_state=42, init='random', learning_rate=200) | |
vis_dims2 = tsne.fit_transform(matrix) | |
x = [x for x,y in vis_dims2] |
NewerOlder