Spaces:
Runtime error
Runtime error
File size: 1,397 Bytes
a8c39f5 |
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 |
import gradio as gr
import os
import sys
import json
now_dir = os.getcwd()
def stop_train(model_name: str):
pid_file_path = os.path.join(now_dir, "logs", model_name, "config.json")
try:
with open(pid_file_path, "r") as pid_file:
pid_data = json.load(pid_file)
pids = pid_data.get("process_pids", [])
with open(pid_file_path, "w") as pid_file:
pid_data.pop("process_pids", None)
json.dump(pid_data, pid_file, indent=4)
for pid in pids:
os.kill(pid, 9)
except:
pass
def stop_infer():
pid_file_path = os.path.join(now_dir, "assets", "infer_pid.txt")
try:
with open(pid_file_path, "r") as pid_file:
pids = [int(pid) for pid in pid_file.readlines()]
for pid in pids:
os.kill(pid, 9)
os.remove(pid_file_path)
except:
pass
def restart_applio():
if os.name != "nt":
os.system("clear")
else:
os.system("cls")
python = sys.executable
os.execl(python, python, *sys.argv)
from assets.i18n.i18n import I18nAuto
i18n = I18nAuto()
def restart_tab():
with gr.Row():
with gr.Column():
restart_button = gr.Button(i18n("Restart Applio"))
restart_button.click(
fn=restart_applio,
inputs=[],
outputs=[],
)
|