Update app.py
Browse files
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 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
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')))
|