Skip to content

Instantly share code, notes, and snippets.

@YiLi225
YiLi225 / prompt.py
Created March 11, 2023 16:02
ChatGPT prompt to generate images
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?
!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'
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:
## 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:
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
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
@YiLi225
YiLi225 / buddha
Last active November 28, 2022 23:06
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
!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
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):
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'))