Spaces:
Runtime error
Runtime error
File size: 1,410 Bytes
8ef89ca |
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 |
import os
import sys
import json
now_dir = os.getcwd()
sys.path.append(now_dir)
import gradio as gr
from assets.i18n.i18n import I18nAuto
i18n = I18nAuto()
def set_precision(precision: str):
with open(os.path.join(now_dir, "assets", "config.json"), "r") as f:
config = json.load(f)
config["precision"] = precision
with open(os.path.join(now_dir, "assets", "config.json"), "w") as f:
json.dump(config, f, indent=4)
print(f"Precision set to {precision}.")
return f"Precision set to {precision}."
def get_precision():
with open(os.path.join(now_dir, "assets", "config.json"), "r") as f:
config = json.load(f)
return config["precision"] if "precision" in config else None
def precision_tab():
precision = gr.Radio(
label=i18n("Precision"),
info=i18n("Select the precision you want to use for training and inference."),
value=get_precision(),
choices=["fp32", "fp16", "bf16"],
interactive=True,
)
precision_info = gr.Textbox(
label=i18n("Output Information"),
info=i18n("The output information will be displayed here."),
value="",
max_lines=1,
)
button = gr.Button(i18n("Update precision"))
button.click(
fn=set_precision,
inputs=[precision],
outputs=[precision_info],
)
|