{ "cells": [ { "cell_type": "markdown", "source": [ "# ViralCutter\n", "Uma alternativa gratuita ao `opus.pro` e ao `vidyo.ai`" ], "metadata": { "id": "pa36OeArowme" } }, { "cell_type": "markdown", "source": [ "# Suporte em:\n", "[![](https://dcbadge.limes.pink/api/server/tAdPHFAbud)](https://discord.gg/tAdPHFAbud)" ], "metadata": { "id": "6Q-ljfsw1unE" } }, { "cell_type": "markdown", "source": [ "# TODO📝\n", "- [x] Release code\n", "- [ ] Huggingface SpaceDemo\n", "- [x] Two face in the cut\n", "- [x] Custom caption and burn\n", "- [x] Make the code faster\n", "- [ ] More types of framing beyond 9:16" ], "metadata": { "id": "0o3KcBT5wzws" } }, { "cell_type": "code", "execution_count": 1, "metadata": { "id": "e76jiRnjONmj", "cellView": "form", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "6e8baa39-5e40-45d7-e247-a70eddbc1a79" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "✅ Instalação V7 Finalizada!\n", "- Transformers 4.46.3 (Compatível com Alinhamento): INSTALADO\n", "- Torch 2.3.1: ATIVO\n" ] } ], "source": [ "#@title 🛠️ Instalação\n", "import os\n", "import subprocess\n", "import shutil\n", "from IPython.display import clear_output\n", "\n", "# 1. Limpeza TOTAL\n", "print(\"🧹 Limpando instalação anterior...\")\n", "%cd /content\n", "if os.path.exists(\"ViralCutter\"):\n", " shutil.rmtree(\"ViralCutter\")\n", "\n", "!git clone -b dev https://github.com/RafaelGodoyEbert/ViralCutter.git\n", "%cd /content/ViralCutter\n", "\n", "print(\"⏳ Instalando gerenciador UV e drivers do sistema...\")\n", "\n", "# 2. Instalar UV e Drivers Linux\n", "subprocess.run(['pip', 'install', 'uv'], check=True)\n", "subprocess.run('sudo apt update -y && sudo apt install -y libcudnn8 ffmpeg xvfb', shell=True, check=True)\n", "\n", "# 3. Criar Ambiente Virtual\n", "print(\"⏳ Criando ambiente virtual...\")\n", "subprocess.run(['uv', 'venv', '.venv'], check=True)\n", "\n", "# 4. INSTALAÇÃO DAS DEPENDÊNCIAS\n", "print(\"⏳ Instalando Bibliotecas...\")\n", "\n", "# Passo A: WhisperX e Requisitos Básicos (Deixe instalar o que quiserem)\n", "cmds_fase_1 = [\n", " \"uv pip install --python .venv git+https://github.com/m-bain/whisperx.git\",\n", " \"uv pip install --python .venv -r requirements.txt\",\n", " \"uv pip install --python .venv yt-dlp pytubefix\",\n", " \"uv pip install yt_dlp\"\n", "]\n", "\n", "for cmd in cmds_fase_1:\n", " subprocess.run(cmd, shell=True, check=True)\n", "\n", "# Passo B: CORREÇÃO DE ALINHAMENTO E GEMINI\n", "# - google-generativeai: Para o Gemini funcionar\n", "# - pandas: Para separar palavras\n", "# - transformers==4.46.3: VERSÃO CRÍTICA. Versões mais novas exigem Torch 2.6 e quebram o alinhamento.\n", "# - accelerate: Ajuda no carregamento do modelo\n", "print(\"🔨 Aplicando downgrade estratégico no Transformers...\")\n", "extra_libs = [\n", " \"uv pip install --python .venv google-generativeai\",\n", " \"uv pip install --python .venv pandas\",\n", " \"uv pip install --python .venv onnxruntime-gpu\",\n", " \"uv pip install --python .venv transformers==4.46.3 accelerate>=0.26.0\"\n", "]\n", "\n", "for cmd in extra_libs:\n", " subprocess.run(cmd, shell=True, check=True)\n", "\n", "# Passo C: O MARTELO FINAL (Torch 2.3.1 Estável)\n", "# Reinstalamos por último para garantir que nada atualizou ele sem querer\n", "print(\"🔨 Forçando versão estável do Torch (2.3.1)...\")\n", "cmd_fix_torch = (\n", " \"uv pip install --python .venv \"\n", " \"torch==2.3.1+cu121 torchvision==0.18.1+cu121 torchaudio==2.3.1+cu121 \"\n", " \"--index-url https://download.pytorch.org/whl/cu121\"\n", ")\n", "subprocess.run(cmd_fix_torch, shell=True, check=True)\n", "\n", "# Passo D: Trava do Numpy\n", "print(\"🔨 Travando Numpy...\")\n", "subprocess.run(\"uv pip install --python .venv 'numpy<2.0' setuptools==69.5.1\", shell=True, check=True)\n", "\n", "# Passo E: Correção de Visão Computacional (CRÍTICO)\n", "print(\"🔨 Corrigindo InsightFace e MediaPipe...\")\n", "\n", "# 1. Garante que o InsightFace tenha o motor necessário (evita que ele falhe)\n", "subprocess.run(\"uv pip install --python .venv insightface onnxruntime-gpu\", shell=True, check=True)\n", "\n", "# 2. Limpeza Radical e Reinstalação do MediaPipe\n", "# Remove versões quebradas\n", "subprocess.run(\"uv pip uninstall --python .venv mediapipe protobuf flatbuffers\", shell=True)\n", "\n", "# 3. Instala versão FLEXÍVEL respeitando limites críticos\n", "# mediapipe>=0.10.0: Pega a versão mais recente compatível com Py3.12\n", "# protobuf>=3.20,<5.0: Garante compatibilidade sem quebrar o sistema antigo\n", "subprocess.run(\"uv pip install --python .venv 'mediapipe>=0.10.0' 'protobuf>=3.20,<5.0' 'flatbuffers>=2.0'\", shell=True, check=True)\n", "\n", "# 5. Configurar Monitor\n", "os.system('Xvfb :1 -screen 0 2560x1440x8 &')\n", "os.environ['DISPLAY'] = ':1.0'\n", "\n", "clear_output()\n", "print(\"✅ Instalação V7 Finalizada!\")\n", "print(\"- Transformers 4.46.3 (Compatível com Alinhamento): INSTALADO\")\n", "print(\"- Torch 2.3.1: ATIVO\")" ] }, { "cell_type": "code", "source": [ "#@title 🚀 Configuração e Execução\n", "import os\n", "\n", "%cd /content/ViralCutter\n", "\n", "# 1. Configura o \"Display\" falso (para evitar erros de interface gráfica)\n", "os.system('Xvfb :1 -screen 0 2560x1440x8 &')\n", "os.environ['DISPLAY'] = ':1.0'\n", "\n", "# 2. CORREÇÃO DO ERRO ATUAL:\n", "# Forçamos o Matplotlib a usar o backend 'Agg' (modo sem cabeça/headless)\n", "# Isso ignora o 'module://matplotlib_inline.backend_inline' que o Colab força e quebra o script.\n", "os.environ['MPLBACKEND'] = 'Agg'\n", "\n", "print(\"🚀 Iniciando ViralCutter usando o ambiente virtual...\")\n", "print(\"⚠️ Ignore os avisos de 'UserWarning', aguarde o link public URL.\")\n", "\n", "# Executa usando o Python do ambiente virtual\n", "!/content/ViralCutter/.venv/bin/python webui/app.py --colab" ], "metadata": { "id": "DNn8ZKJdD5XG", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "fd4689bd-f036-42de-fc7e-67854af40d81" }, "execution_count": null, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "/content/ViralCutter\n", "🚀 Iniciando ViralCutter usando o ambiente virtual...\n", "⚠️ Ignore os avisos de 'UserWarning', aguarde o link public URL.\n", "/content/ViralCutter/webui/app.py:204: UserWarning: The parameters have been moved from the Blocks constructor to the launch() method in Gradio 6.0: theme, css. Please pass these parameters to launch() instead.\n", " with gr.Blocks(title=i18n(\"ViralCutter WebUI\"), theme=gr.themes.Default(primary_hue=\"blue\", neutral_hue=\"slate\"), css=css) as demo:\n", "Running in Colab mode. Generating public link...\n", "* Running on local URL: http://127.0.0.1:7860\n", "* Running on public URL: https://7f3b04ec670707105b.gradio.live\n", "\n", "This share link expires in 1 week. For free permanent hosting and GPU upgrades, run `gradio deploy` from the terminal in the working directory to deploy to Hugging Face Spaces (https://huggingface.co/spaces)\n" ] } ] }, { "cell_type": "markdown", "metadata": { "id": "nEIsMZLwJ5kD" }, "source": [ "#Créditos\n", "\n", "Inspirado no [reels clips automator](https://github.com/eddieoz/reels-clips-automator) e no [YoutubeVideoToAIPoweredShorts](https://github.com/Fitsbit/YoutubeVideoToAIPoweredShorts)
\n", "\n", "---\n", "![Rafa.png](https://i.imgur.com/cGknQpU.png;base64)\n", "\n", "Desenvolvido por **Rafa.Godoy**
\n", "[ ![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white) ](https://github.com/rafaelGodoyEbert)
\n", "[ ![X](https://img.shields.io/twitter/url?url=https%3A%2F%2Ftwitter.com%2FGodoyEbert) ](https://twitter.com/GodoyEbert)
\n", "[Instagram](https://www.instagram.com/rafael.godoy.ebert/)
\n", "[ ![](https://dcbadge.vercel.app/api/server/aihubbrasil) ](https://discord.gg/aihubbrasil)" ] }, { "cell_type": "markdown", "source": [ "`0.1v Alpha`
\n", "\n", "Apenas uma alternativa gratuita ao `opus.pro` e ao `vidyo.ai`
\n" ], "metadata": { "id": "tpLJmPqGT5_u" } } ], "metadata": { "accelerator": "GPU", "colab": { "gpuType": "T4", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 0 }