Update src/app.py
Browse files1234545678910111213141516131718192095 unmodified lines1161171181151161171181191201211221191201211 unmodified line123124125126127128129130131132133134135136137138139140141142# AIdeaText v3# app.pyimport osimport torchtorch.classes.__path__ = [os.path.join(torch.__path__[0], torch.classes.__file__)] os.environ['TORCH_DISABLE_MLC'] = '1' # Desactiva la carga de componentes conflictivos
import streamlit as stfrom streamlit.runtime.scriptrunner import RerunException
import torchimport threading
import sys
from dotenv import load_dotenvfrom datetime import datetimefrom PIL import Imageimport threading
import logging
# Configuraci贸n b谩sica95 unmodified lineslogging.basicConfig(level=logging.INFO)logger = logging.getLogger(__name__)
def torch_operations(): print(torch.__version__) print(torch.cuda.is_available())
if __name__ == '__main__': torch_thread = threading.Thread(target=torch_operations) torch_thread.start()
@st.cache_resource(show_spinner=False)def initialize_nlp_models(): logger.info("Cargando modelos de spaCy")1 unmodified line logger.info("Modelos de spaCy cargados exitosamente") return models
# Soluci贸n para el error de torch.classesdef _patched_get_module_paths(module): if 'torch' in str(module.__file__): return [] return original_get_module_paths(module)
# Aplicar el parche solo si es necesariotry: from streamlit.watcher.local_sources_watcher import get_module_paths as original_get_module_paths import streamlit.watcher.local_sources_watcher streamlit.watcher.local_sources_watcher.get_module_paths = _patched_get_module_pathsexcept ImportError: pass
def app_main(): try: logger.info("Entrando en app_main()")src/app.py+21-11