narainp commited on
Commit
200fb6b
·
verified ·
1 Parent(s): 222641d

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -70,18 +70,18 @@ net.eval()
70
  path = "uploads" # Define path for uploads
71
  os.makedirs(path, exist_ok=True) # Ensure directory exists
72
 
73
- def predict_image(img):
74
- img_path = os.path.join(path, img.name)
75
- img.save(img_path)
76
 
77
- image_tensor = preprocess_image(img_path, get_test_transforms(224))
78
  pred = net(image_tensor)
79
  y_pred = 1 - nn.functional.softmax(pred, dim=1).data.cpu().numpy()[:, 0]
80
  return float(y_pred.item())
81
 
82
  iface = gr.Interface(
83
  fn=predict_image,
84
- inputs=gr.Image(type="file"),
85
  outputs="number",
86
  title="Image Prediction App",
87
  description="Upload an image and get a model prediction."
 
70
  path = "uploads" # Define path for uploads
71
  os.makedirs(path, exist_ok=True) # Ensure directory exists
72
 
73
+ def predict_image(path):
74
+ # img_path = os.path.join(path, img.name)
75
+ # img.save(img_path)
76
 
77
+ image_tensor = preprocess_image(path, get_test_transforms(224))
78
  pred = net(image_tensor)
79
  y_pred = 1 - nn.functional.softmax(pred, dim=1).data.cpu().numpy()[:, 0]
80
  return float(y_pred.item())
81
 
82
  iface = gr.Interface(
83
  fn=predict_image,
84
+ inputs=gr.Image(type="filepath"),
85
  outputs="number",
86
  title="Image Prediction App",
87
  description="Upload an image and get a model prediction."