Medvira commited on
Commit
0aa8ede
·
verified ·
1 Parent(s): 9fd2320

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -23,15 +23,13 @@ def inference(sample_name):
23
  age = sample['boneage'].item()
24
  outputs = session.run(None, {"input": sample['path'].numpy()})
25
  predicted_age = (outputs[0]*41.172)+127.329
26
- # Get the image path and load the image
27
- image_path = sample['path'][0]
28
- image = Image.open(image_path)
 
 
29
 
30
- return {
31
- 'Bone age': age,
32
- 'Predicted Bone age': predicted_age[0][0],
33
- 'Image': image
34
- }
35
 
36
  # List of sample file names
37
  sample_files = sorted(os.listdir(os.path.join(os.getcwd(),'samples')))
 
23
  age = sample['boneage'].item()
24
  outputs = session.run(None, {"input": sample['path'].numpy()})
25
  predicted_age = (outputs[0]*41.172)+127.329
26
+ # Get the image data from the MetaTensor and convert it to a format PIL can handle
27
+ image_data = sample['path'].numpy()
28
+ image_data = (image_data * 255).astype(np.uint8) # Assuming the image data is normalized
29
+ image_data = np.squeeze(image_data) # Remove any singleton dimensions if necessary
30
+ image = Image.fromarray(image_data.transpose(1, 2, 0)) # Convert to HWC format
31
 
32
+ return age, predicted_age[0][0], image
 
 
 
 
33
 
34
  # List of sample file names
35
  sample_files = sorted(os.listdir(os.path.join(os.getcwd(),'samples')))