MoinulwithAI commited on
Commit
c09e4cb
·
verified ·
1 Parent(s): 8c4da2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -51,13 +51,13 @@ transform = transforms.Compose([
51
  transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])
52
  ])
53
 
54
- # -------- PREDICTION FUNCTION --------
55
- def predict_age(image):
56
- image = transform(image).unsqueeze(0).to(device)
57
  with torch.no_grad():
58
- output = model(image)
59
- age = output.item() # Convert to a single scalar
60
- return f"Predicted Age: {age:.2f}"
 
61
 
62
  import gradio as gr
63
 
 
51
  transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])
52
  ])
53
 
54
+ def predict_age(image: Image.Image) -> float:
55
+ image_tensor = transform(image).unsqueeze(0).to(device)
 
56
  with torch.no_grad():
57
+ output = model(image_tensor)
58
+ age = output.item()
59
+ return round(age, 2)
60
+
61
 
62
  import gradio as gr
63