|
from libretranslate.app import create_app |
|
from libretranslate.default_values import DEFAULT_ARGUMENTS as DEFARGS |
|
from waitress import serve |
|
import os |
|
print(os.cpu_count()) |
|
print(os.uname()) |
|
print(os.environ) |
|
import platform |
|
import psutil |
|
|
|
print("Processor:", platform.processor()) |
|
print("CPU Cores:", psutil.cpu_count(logical=False)) |
|
print("Logical CPUs:", psutil.cpu_count(logical=True)) |
|
print("CPU Frequency:", psutil.cpu_freq().max, "MHz") |
|
|
|
ram = psutil.virtual_memory() |
|
print("Total RAM:", round(ram.total / (1024**3), 2), "GB") |
|
print("Available RAM:", round(ram.available / (1024**3), 2), "GB") |
|
print("Used RAM:", round(ram.used / (1024**3), 2), "GB") |
|
print("RAM Usage Percentage:", ram.percent, "%") |
|
|
|
disk = psutil.disk_usage('/') |
|
print("Total Disk Space:", round(disk.total / (1024**3), 2), "GB") |
|
print("Used Disk Space:", round(disk.used / (1024**3), 2), "GB") |
|
print("Free Disk Space:", round(disk.free / (1024**3), 2), "GB") |
|
print("Disk Usage Percentage:", disk.percent, "%") |
|
|
|
|
|
print("System:", platform.system()) |
|
print("Node Name:", platform.node()) |
|
print("Release:", platform.release()) |
|
print("Version:", platform.version()) |
|
print("Machine:", platform.machine()) |
|
print("Architecture:", platform.architecture()) |
|
|
|
def create_args(): |
|
"""Return default arguments compatible with Hugging Face Spaces.""" |
|
class Args: |
|
def __init__(self): |
|
self.host = "0.0.0.0" |
|
self.port = 7860 |
|
self.debug = False |
|
self.ssl = False |
|
self.url_prefix = "" |
|
self.load_only = DEFARGS['LOAD_ONLY'] |
|
self.update_models = DEFARGS.get('UPDATE_MODELS', False) |
|
self.force_update_models = DEFARGS.get('FORCE_UPDATE_MODELS', False) |
|
|
|
|
|
return Args() |
|
|
|
def main(environ, start_response): |
|
"""Main entry point for the application.""" |
|
args = create_args() |
|
app = create_app(args) |
|
print(f"Running on http://{args.host}:{args.port}{args.url_prefix}") |
|
return app(environ, start_response) |
|
|
|
if __name__ == "__main__": |
|
serve(main, host="0.0.0.0", port=7860) |