Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions gradio-inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import numpy as np
import cv2
import traceback

import torch
import torch.nn as nn
Expand Down Expand Up @@ -219,7 +220,6 @@ def predict_image(image: np.ndarray, model_type: str) -> tuple[dict, np.ndarray]

except Exception as e:
logging.error(f"Error generating heatmap: {e}")
import traceback
traceback.print_exc()
# Fallback: just do prediction without heatmap
with torch.no_grad():
Expand All @@ -237,7 +237,6 @@ def predict_image(image: np.ndarray, model_type: str) -> tuple[dict, np.ndarray]

except Exception as e:
logging.error(f"Error during prediction: {e}")
import traceback
traceback.print_exc()
return {cls: 0.0 for cls in CLASSES}, None

Expand Down
5 changes: 1 addition & 4 deletions utils/Trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from torch.utils.data import DataLoader
from tqdm import tqdm
import gc
import traceback

from utils.Evaluator import ClassificationEvaluator
from utils.Callback import EarlyStopping
Expand Down Expand Up @@ -272,15 +273,11 @@ def model_train(
return results
except Exception as viz_error:
print(f"Error in visualization: {viz_error}")
import traceback

traceback.print_exc()
return {"accuracy": None}

except Exception as e:
print(f"Error occurred when training {model_name}: {e}")
import traceback

traceback.print_exc()
return {"accuracy": None}
finally:
Expand Down