Bot De Telegram Para Cambiar Caras En Videos Best Site
Create face_swapper.py:
import cv2 import insightface import numpy as np from PIL import Image import tempfile import os import subprocess as spclass FaceSwapper: def init(self, gpu=True): ctx_id = 0 if gpu else -1 self.face_analyzer = insightface.app.FaceAnalysis(name='buffalo_l') self.face_analyzer.prepare(ctx_id=ctx_id, det_size=(640, 640)) self.swapper = insightface.model_zoo.get_model('inswapper_128.onnx') self.swapper.prepare(ctx_id=ctx_id) bot de telegram para cambiar caras en videos best
def get_best_face(self, img): faces = self.face_analyzer.get(img) if len(faces) == 0: return None # return largest face by area return max(faces, key=lambda f: (f.bbox[2]-f.bbox[0])*(f.bbox[3]-f.bbox[1])) def swap_video(self, video_path, source_face_img_path, output_path, target_face_idx=0): # read source face src_img = cv2.imread(source_face_img_path) src_face = self.get_best_face(src_img) if src_face is None: raise ValueError("No face found in source image") # open video cap = cv2.VideoCapture(video_path) fps = cap.get(cv2.CAP_PROP_FPS) width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) # temp dir for frames temp_dir = tempfile.mkdtemp() frame_pattern = os.path.join(temp_dir, "frame_%06d.jpg") # process frame by frame frame_count = 0 while True: ret, frame = cap.read() if not ret: break faces = self.face_analyzer.get(frame) if len(faces) > target_face_idx: target_face = faces[target_face_idx] frame = self.swapper.get(frame, target_face, src_face, paste_back=True) cv2.imwrite(frame_pattern % frame_count, frame) frame_count += 1 cap.release() # rebuild video with ffmpeg cmd = [ 'ffmpeg', '-y', '-framerate', str(fps), '-i', frame_pattern, '-c:v', 'libx264', '-pix_fmt', 'yuv420p', output_path ] sp.run(cmd, stdout=sp.DEVNULL, stderr=sp.DEVNULL) # cleanup for f in os.listdir(temp_dir): os.remove(os.path.join(temp_dir, f)) os.rmdir(temp_dir) return output_path
Para que el bot sea considerado "el mejor", no puede usar librerías antiguas como face-swap de GitHub básicas. Debe integrar tecnologías modernas: Create face_swapper
Regardless of which "best" bot you choose, the workflow is similar. Here is a generic tutorial for cambiar caras en videos using Telegram: Para que el bot sea considerado "el mejor",
Step 1: Open Telegram and search for the bot username (e.g., @FaceSwapVideoBot).
Step 2: Click "Start" or send /start.
Step 3: Send the Target Video (the video where you want to change the face). Note: Keep the video under 30MB for best results.
Step 4: Send the Source Face (the face you want to insert). This must be a clear, front-facing photo.
Step 5: Wait. The bot will process the video. You will see a loading percentage.
Step 6: The bot replies with the swapped video. Long-press the video to save it to your phone.