VaneshDev commited on
Commit
25239fa
·
verified ·
1 Parent(s): 8f3d78f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -49,9 +49,9 @@ condition_details = {
49
  "Diverticulitis": {"description": "Inflammation of diverticula in the colon.", "recommendation": "Gastroenterology consultation."}
50
  }
51
 
52
- # Load model (using a smaller model like MobileNetV2 for faster inference)
53
- model = models.mobilenet_v2(pretrained=True)
54
- model.classifier[1] = torch.nn.Linear(model.classifier[1].in_features, len(conditions)) # Adjust the classifier for our condition count
55
  model.eval()
56
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
57
  model.to(device)
@@ -59,9 +59,9 @@ model.to(device)
59
  # Image preprocessing
60
  def preprocess_image(image):
61
  transform = transforms.Compose([
62
- transforms.Resize((224, 224)),
63
  transforms.ToTensor(),
64
- transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
65
  ])
66
  return transform(image).unsqueeze(0).to(device)
67
 
 
49
  "Diverticulitis": {"description": "Inflammation of diverticula in the colon.", "recommendation": "Gastroenterology consultation."}
50
  }
51
 
52
+ # Load model (using a specialized X-ray model or pre-trained general model)
53
+ model = models.densenet121(pretrained=True) # You can swap to a more specific X-ray model if available
54
+ model.classifier = torch.nn.Linear(model.classifier.in_features, len(conditions)) # Adjust the classifier for our condition count
55
  model.eval()
56
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
57
  model.to(device)
 
59
  # Image preprocessing
60
  def preprocess_image(image):
61
  transform = transforms.Compose([
62
+ transforms.Resize((224, 224)), # Resize to match the model input size
63
  transforms.ToTensor(),
64
+ transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) # Standardize based on ImageNet values
65
  ])
66
  return transform(image).unsqueeze(0).to(device)
67