Spaces:
Runtime error
Runtime error
deploy at 2025-05-14 10:09:12.419396
Browse files460 unmodified lines461462463464465466460 unmodified linescls="p-4 bg-gray-100 rounded overflow-auto max-h-[300px] text-sm"))setup_hf_backup(app)serve()460 unmodified lines461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551460 unmodified linescls="p-4 bg-gray-100 rounded overflow-auto max-h-[300px] text-sm"))@rt('/fastai-info')def get():try:import fastaiimport torchimport sysreturn Div(H2("Environment Information"),Ul(Li(f"FastAI version: {fastai.__version__}"),Li(f"PyTorch version: {torch.__version__}"),Li(f"Python version: {sys.version}"),Li(f"Sys path: {sys.path}")))except Exception as e:import tracebackreturn Div(H2("Error"),P(f"Error: {str(e)}"),Pre(traceback.format_exc(), cls="p-4 bg-gray-100 rounded"))@rt('/load-with-torch')def get():try:import torchimport osimport traceback# Try to load with torch insteadmodel_path = 'export.pkl'if not os.path.exists(model_path):return P(f"Model file not found at: {model_path}")# Try loading with torchmodel = torch.load(model_path, map_location=torch.device('cpu'))# If successful, show model structurereturn Div(H2("Model Loaded with Torch"),P("Successfully loaded model with torch.load", cls="text-green-600"),P(f"Model type: {type(model)}"),Pre(f"Model keys: {list(model.keys()) if isinstance(model, dict) else 'Not a dictionary'}",cls="p-4 bg-gray-100 rounded"))except Exception as e:return Div(H2("Torch Loading Error"),P(f"Error: {str(e)}", cls="text-red-600"),Pre(traceback.format_exc(), cls="p-4 bg-gray-100 rounded overflow-auto max-h-[300px] text-sm"))@rt('/create-test-model')def get():try:from fastai.vision.all import *import torchimport os# Create a simple modelmodel = nn.Sequential(nn.Conv2d(3, 16, 3, 1, 1), nn.ReLU(), nn.AdaptiveAvgPool2d(1), nn.Flatten())# Save ittorch.save(model, 'test_model.pth')# Try to load it backloaded_model = torch.load('test_model.pth')return Div(H2("Test Model Creation"),P("Successfully created and loaded a test model", cls="text-green-600"),P(f"Model saved at: {os.path.abspath('test_model.pth')}"),P(f"Model type: {type(loaded_model)}"))except Exception as e:import tracebackreturn Div(H2("Test Model Error"),P(f"Error: {str(e)}", cls="text-red-600"),Pre(traceback.format_exc(), cls="p-4 bg-gray-100 rounded overflow-auto max-h-[300px] text-sm"))setup_hf_backup(app)serve()
main.py+85