feat: add scripts for one click windows (#219)

* feat: windows one-click installation

* chore: format

---------

Co-authored-by: zzzweakman <1819489045@qq.com>
This commit is contained in:
Jianzhu Guo 2024-07-25 18:50:54 +08:00 committed by GitHub
parent 172b852127
commit 1f443b2344
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 1 deletions

4
.gitignore vendored
View File

@ -22,3 +22,7 @@ tmp/*
.vscode/launch.json
**/*.DS_Store
gradio_temp/**
# Windows dependencies
ffmpeg/
LivePortrait_env/

5
app.py
View File

@ -32,11 +32,14 @@ def fast_check_ffmpeg():
tyro.extras.set_accent_color("bright_cyan")
args = tyro.cli(ArgumentConfig)
ffmpeg_dir = os.path.join(os.getcwd(), "ffmpeg")
if osp.exists(ffmpeg_dir):
os.environ["PATH"] += (os.pathsep + ffmpeg_dir)
if not fast_check_ffmpeg():
raise ImportError(
"FFmpeg is not installed. Please install FFmpeg (including ffmpeg and ffprobe) before running this script. https://ffmpeg.org/download.html"
)
# specify configs for inference
inference_cfg = partial_fields(InferenceConfig, args.__dict__) # use attribute of args to initial InferenceConfig
crop_cfg = partial_fields(CropConfig, args.__dict__) # use attribute of args to initial CropConfig

View File

@ -1,5 +1,6 @@
# coding: utf-8
import os
import os.path as osp
import tyro
import subprocess
@ -33,6 +34,10 @@ def main():
tyro.extras.set_accent_color("bright_cyan")
args = tyro.cli(ArgumentConfig)
ffmpeg_dir = os.path.join(os.getcwd(), "ffmpeg")
if osp.exists(ffmpeg_dir):
os.environ["PATH"] += (os.pathsep + ffmpeg_dir)
if not fast_check_ffmpeg():
raise ImportError(
"FFmpeg is not installed. Please install FFmpeg (including ffmpeg and ffprobe) before running this script. https://ffmpeg.org/download.html"

View File

@ -0,0 +1,18 @@
import socket
import sys
if len(sys.argv) != 2:
print("Usage: python check_port.py <port>")
sys.exit(1)
port = int(sys.argv[1])
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
result = sock.connect_ex(('127.0.0.1', port))
if result == 0:
print("LISTENING")
else:
print("NOT LISTENING")
sock.close