TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #22 · 19 јан.

Заметка начинающим, которые часто сталкиваются с подобной непоняткой. Ситуация следующая, есть список файлов: names = [ 'image.bmp', 'second.txt.bkp', 'data.db', '.config.cfg', 'file.ext.bkp' ] И мы хотим убрать у них окончание ".bkp". Не знаю зачем, пример довольно надуманный) Но суть он показывает, а это главное. Те, кто еще не очень знаком с библиотекой os.path или pathlib, вероятно решат обработать имена как строки. И тут вполне подойдет метод строки strip(). Что делает этот метод? Он отрезает указанные символы по обеим сторонам строки. Если ничего не указать, то убирает невидимые символы (пробелы, табуляции и переносы строк). В нашем случае будет выглядеть вот так: >>> name.strip('.bkp') То есть просим удалить строку '.bkp' по краям имени файла, если таковая есть. Можно применить аналогичный метод rstrip(), чтобы отрезать только справа, но для этого примера используем обычный. >>> for name in names: >>> print(name.strip('.bkp')) image.bm second.txt data.d config.cfg file.ext Хм, что-то не то с нашими именами! Что случилось??? Видим нежелательное переименование в именах, где и близко не было указанной строки '.bkp' А дело всё в том, что данный метод ищет не указанную строку, а указанные символы, и не важно в каком порядке. Для метода strip() строка '.bkp' это не паттерн для поискаа список символов. Потому он отрезал симовол 'p' от '.bmp' и удалил точку из файла '.config.cfg'. Как тогда правильно заменить именно паттерн? Для начинающего можно посоветовать метод строки replace(), который как раз использует для замены указанную строку целиком. В нашем примере заменим её на пустую строку. >>> for name in names: >>> print(name.replace('.bkp', '')) image.bmp second.txt data.db .config.cfg file.ext Уже лучше, но помните, это лишь пример про strip(). Для работы с именами файлов есть способы и более "правильные", дающие однозначно верный результат. Я взял файлы только в качестве примера. Даже replase() тут может сделать не то что ожидаем. Просто впредь будьте внимательны с этим strip(). #basic

Hashtags

Резултати

Пронајдени 5 слични објави

Пребарај: #mlx

当前筛选 #mlx清除筛选
GitHub Trends

@githubtrending · Post #15143 · 14.09.2025 г., 12:00

#python#llms#mlx MLX LM is a Python tool that helps you run and fine-tune large language models (LLMs) efficiently on Apple Silicon Macs. It connects easily to thousands of models on Hugging Face, supports model quantization to save memory, and allows distributed training. You can generate text or chat with models via simple commands or Python code. It also offers features like prompt caching and memory optimization for handling long texts, making it faster and less resource-heavy. This means you can run powerful AI models locally on your Mac without needing expensive cloud services, saving cost and improving speed. https://github.com/ml-explore/mlx-lm

GitHub Trends

@githubtrending · Post #14655 · 01.05.2025 г., 13:30

#typescript#electron#llama#llms#lora#mlx#rlhf#transformers Transformer Lab is a free, open-source tool that lets you easily work with large language models on your own computer, offering one-click downloads for popular models like Llama3 and Mistral, fine-tuning across different hardware (including Apple Silicon and GPUs), and features like chatting, training, and evaluating models through a simple interface—saving you from complex setups like CUDA or Python version issues[1][2][5]. https://github.com/transformerlab/transformerlab-app

GitHub Trends

@githubtrending · Post #15614 · 13.04.2026 г., 11:30

#typescript#ai#cuda#mlx#qwen3_tts#qwen3_tts_ui#voice_ai#voice_clone#whisper Voicebox is a free, open-source voice synthesis studio that lets you clone voices, generate speech in 23 languages, and apply audio effects—all running privately on your computer. You can create realistic voice clones from just seconds of audio, use five different text-to-speech engines for different needs, add effects like reverb and pitch shift, and build multi-voice projects with a timeline editor. The key benefit is complete privacy: your voice data and AI models never leave your machine, unlike cloud-based alternatives. It also includes an API for building voice-powered applications and works across Mac, Windows, and Linux with GPU acceleration support. https://github.com/jamiepine/voicebox

GitHub Trends

@githubtrending · Post #14684 · 08.05.2025 г., 12:00

#python#apple_silicon#audio_processing#mlx#multimodal#speech_recognition#speech_synthesis#speech_to_text#text_to_speech#transformers MLX-Audio is a powerful tool for converting text into speech and speech into new audio. It works well on Apple Silicon devices, like M-series chips, making it fast and efficient. You can choose from different languages and voices, and even adjust how fast the speech is. It also includes a web interface where you can see audio in 3D and play your own files. This tool is helpful for making audiobooks, interactive media, and personal projects because it's easy to use and provides high-quality audio quickly. https://github.com/Blaizzy/mlx-audio

GitHub Trends

@githubtrending · Post #15600 · 04.04.2026 г., 11:30

#python#apple_silicon#florence2#idefics#llava#llm#local_ai#mlx#molmo#paligemma#pixtral#vision_framework#vision_language_model#vision_transformer MLX-VLM lets you run, chat with, and fine-tune Vision Language Models (VLMs) plus audio/video models on your Mac using MLX—install easily with `pip install -U mlx-vlm`. Use CLI for quick text/image/audio generation (e.g., `mlx_vlm.generate --model ... --image photo.jpg`), Gradio UI for chats, Python scripts, or a FastAPI server with OpenAI-compatible endpoints supporting multi-images/videos. Features like TurboQuant cut KV cache memory by 76%, and LoRA/QLoRA fine-tuning works on consumer hardware. You benefit by experimenting with powerful multimodal AI locally—fast, memory-efficient, no cloud costs, perfect for Mac users tweaking models affordably. https://github.com/Blaizzy/mlx-vlm