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 here, when you want to send me an image, please use markdown, no \ and no code chunks, | |
Please use Unsplash API (https://source.unspalsh.com/1600*900/?<PUT YOUR QUERY HERE>). | |
Can you repeat if you understand? |
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
!pip install rembg | |
from google.colab import files | |
uploaded = files.upload() | |
## https://pixabay.com/photos/animal-mammal-fallow-deer-stag-984573/ | |
from rembg import remove | |
from PIL import Image | |
input_img = 'deer.jpg' | |
output_img = 'deer_rmbg.png' |
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 | |
def DownloadYT(url): | |
youtubeObject = YouTube(url) | |
youtubeObject = youtubeObject.streams.get_highest_resolution() | |
try: | |
youtubeObject.download() | |
print("Title:", youtubeObject.title) | |
print("=== Download is completed successfully ===\n") | |
except: |
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
## Encrpyt the data file | |
# opening the key | |
with open('filekey.key', 'rb') as filekey: | |
key = filekey.read() | |
# using the generated key | |
fernet = Fernet(key) | |
# opening the original file to encrypt | |
with open('Wine_data.csv', 'rb') as file: |
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 google.colab import files | |
uploaded = files.upload() | |
!pip install cryptography | |
from cryptography.fernet import Fernet | |
## Generate Fernet keys | |
key = Fernet.generate_key() | |
# string the key in a file |
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 PIL import Image | |
import torch | |
import IPython | |
from IPython.display import display | |
# upload images | |
from google.colab import files | |
uploaded = files.upload() | |
# https://github.com/bryandlee/animegan2-pytorch | |
# load models and face2paint utility function |
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
// | |
// _oo0oo_ | |
// o8888888o | |
// 88" . "88 | |
// (| -_- |) | |
// 0\ = /0 | |
// ___/`---'\___ | |
// .' \\| |// '. | |
// / \\||| : |||// \ | |
// / _||||| -:- |||||- \ |
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
!sudo apt-get update -y | |
!sudo apt-get install python3.11 | |
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 | |
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2 |
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 datetime import datetime | |
try: | |
1/0 | |
except Exception as myError: | |
myError.add_note(f'Hey, there is an error; \ | |
Raised at {datetime.now()}') | |
raise | |
Output: | |
Traceback (most recent call last): |
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 math | |
def mySqrt(x): | |
if type(x) not in [int, float] or x < 0: | |
raise ExceptionGroup("twice", | |
[ValueError(999), | |
TypeError("Work with Numbers Only")]) | |
else: | |
return math.sqrt(x) | |
print(mySqrt('-10')) |
NewerOlder