Spaces:
Build error
Build error
| import gradio as gr | |
| import sys, os, subprocess, torch, json | |
| from pathlib import Path | |
| def cmd(comando): | |
| try: | |
| r = subprocess.run(comando, shell=True, capture_output=True, text=True, timeout=60) | |
| return f"$ {comando}\n\nSTDOUT:\n{r.stdout}\nSTDERR:\n{r.stderr}" | |
| except subprocess.TimeoutExpired: | |
| return "Timeout (60s)" | |
| except Exception as e: | |
| return str(e) | |
| def info_sistema(): | |
| cuda = torch.cuda.is_available() if hasattr(torch, 'cuda') else False | |
| return f"""## Sistema | |
| - Python: {sys.version} | |
| - PyTorch: {torch.__version__} | |
| - CUDA: {cuda} | |
| - Transformers: {__import__('transformers').__version__ if __import__('transformers') else 'N/A'} | |
| - HF Hub: {__import__('huggingface_hub').__version__ if __import__('huggingface_hub') else 'N/A'} | |
| - Directorio: {os.getcwd()} | |
| - Archivos: {os.listdir('.')} | |
| """ | |
| with gr.Blocks(title="Abliteration Dev - murdok1982", theme=gr.themes.Citrus()) as demo: | |
| gr.Markdown("# Abliteracion Dev Mode") | |
| gr.Markdown("## Consola remota para probar la cirugia") | |
| with gr.Tab("Terminal"): | |
| c = gr.Textbox(label="Comando", value="python --version && pip list | findstr torch") | |
| b = gr.Button("Ejecutar", variant="primary") | |
| o = gr.Textbox(label="Salida", lines=20) | |
| b.click(fn=cmd, inputs=c, outputs=o) | |
| with gr.Tab("Info Sistema"): | |
| b2 = gr.Button("Refrescar") | |
| o2 = gr.Markdown(info_sistema()) | |
| b2.click(fn=info_sistema, outputs=o2) | |
| demo.launch(server_name="0.0.0.0", server_port=7860) | |