File size: 3,590 Bytes
ab79598 1d1a8c3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# Core dependencies streamlit # Build interactive web apps with Python! ๐ # - ๐ฅ Stream video: st.video("movie.mp4") to show a cool science clip! # - ๐ Plot data: st.line_chart(data) for visualizing AI model accuracy! # - ๐ผ๏ธ Show pics: st.image("cat.png", caption="AI-generated kitty!") for fun outputs! pandas # Crunch data like a pro! ๐ # - ๐งฎ Analyze scores: pd.DataFrame({"Student": ["Alex", "Bob"], "Score": [85, 90]}).mean() to avg grades! # - ๐ Filter rows: df[df["Age"] > 18] to find adult learners in a dataset! # - ๐ Pivot tables: pd.pivot_table(df, values="Sales", index="Month") for sales trends! torch # Power AI models with tensors! ๐ฅ # - ๐ค Train a model: torch.nn.Linear(10, 2) for a simple neural net! # - ๐ง Matrix math: torch.matmul(tensor1, tensor2) to compute embeddings! # - ๐ฒ Random tensors: torch.rand(3, 3) for mock data in experiments! requests # Fetch stuff from the web! ๐ # - ๐ Grab a PDF: requests.get("https://arxiv.org/pdf/2308.03892") to download research! # - ๐ค๏ธ Check weather: requests.get("api.weather.com/data") for live updates! # - ๐ Get jokes: requests.get("api.jokes.com/random") to lighten the mood! aiofiles # Async file handling for speed! โก # - โ๏ธ Write fast: await aiofiles.open("log.txt", "w").write("Done!") for quick logs! # - ๐ Read async: await aiofiles.open("data.csv", "r").read() to load files snappy! # - ๐๏ธ Bulk ops: await aiofiles.open("temp.bin", "wb").write(data) for temp storage! pillow # Play with images like an artist! ๐๏ธ # - ๐ Resize pics: Image.open("photo.jpg").resize((100, 100)) for thumbnails! # - ๐จ Color swap: Image.open("dog.png").convert("L") for grayscale pups! # - โ๏ธ Crop it: Image.open("scene.png").crop((10, 10, 50, 50)) to zoom in! # PDF processing PyMuPDF # Master PDFs like a wizard! ๐ # - ๐ผ๏ธ PDF to pic: doc[0].get_pixmap().save("page1.png") for snapshots! # - ๐ Extract text: doc[0].get_text() to pull words from a page! # - ๐ข Count pages: len(fitz.open("book.pdf")) to know the length! # Transformers and diffusion models transformers # Talk to AI models! ๐ฃ๏ธ # - ๐ค Chatbot: tokenizer.decode(model.generate(input_ids)) for AI replies! # - ๐ Summarize: model("Long text here") to shorten essays! # - ๐๏ธ Translate: model("Hola", src_lang="es", tgt_lang="en") for "Hello"! diffusers # Generate wild images! ๐จ # - ๐ฆ Dream art: pipeline("Unicorn in space").images[0].save("magic.png")! # - ๐ Style swap: pipeline("City in Van Gogh style") for cool remixes! # - ๐พ Pet pics: pipeline("Cartoon dog") to make fluffy cartoons! # OpenAI integration openai # Tap into GPT magic! โจ # - ๐ Summarize: openai.ChatCompletion.create(messages=[{"role": "user", "content": "Summarize this!"}]) for quick recaps! # - ๐ผ๏ธ Image OCR: openai.ChatCompletion.create(messages=[{"content": [{"type": "image_url", "image_url": "base64"}]}) for text extraction! # - ๐ Joke time: openai.ChatCompletion.create(messages=[{"content": "Tell me a joke!"}]) for laughs! # Additional utilities glob2 # Find files with flair! ๐ # - ๐ผ๏ธ List pics: glob.glob("*.png") to grab all images! # - ๐ PDF hunt: glob.glob("*.pdf") for all your docs! # - ๐๏ธ Wildcards: glob.glob("data_*_2023.txt") for specific files! pytz # Time zones made easy! โฐ # - ๐ Local time: pytz.timezone("US/Pacific").localize(datetime.now()) for Cali time! # - โณ UTC shift: datetime.now(pytz.UTC) for global sync! # - ๐ Convert: dt.astimezone(pytz.timezone("Asia/Tokyo")) for Tokyo vibes! tiktoken |