Spaces:
Sleeping
Sleeping
updated app.py
Browse files- .idea/.name +1 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +7 -0
- .idea/vcs.xml +6 -0
- app.py +6 -5
.idea/.name
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
app.py
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="Black">
|
4 |
+
<option name="sdkName" value="Python 3.12 (1. Two Sum)" />
|
5 |
+
</component>
|
6 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (CNN_Pneumonia_detection)" project-jdk-type="Python SDK" />
|
7 |
+
</project>
|
.idea/vcs.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="VcsDirectoryMappings">
|
4 |
+
<mapping directory="" vcs="Git" />
|
5 |
+
</component>
|
6 |
+
</project>
|
app.py
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
import streamlit as st
|
2 |
import tensorflow as tf
|
|
|
|
|
|
|
3 |
import torch
|
4 |
import torch.nn as nn
|
5 |
import numpy as np
|
@@ -51,12 +54,10 @@ if uploaded_file is not None:
|
|
51 |
|
52 |
else: # TensorFlow
|
53 |
# Convert Image to NumPy and Normalize
|
54 |
-
|
55 |
-
image_array = np.array(img_resized) / 255.0
|
56 |
-
image_array = np.expand_dims(image_array, axis=0) # Add batch dimension
|
57 |
|
58 |
# Make Prediction
|
59 |
-
prediction = tf_model.predict(
|
60 |
|
61 |
# Display Prediction
|
62 |
st.header(
|
@@ -64,5 +65,5 @@ if uploaded_file is not None:
|
|
64 |
divider='blue'
|
65 |
)
|
66 |
# Display Uploaded Image
|
67 |
-
st.image(image, caption="Uploaded
|
68 |
|
|
|
1 |
import streamlit as st
|
2 |
import tensorflow as tf
|
3 |
+
from tensorflow import keras
|
4 |
+
from tensorflow.keras.preprocessing.image import ImageDataGenerator
|
5 |
+
import tensorflow.keras.applications.resnet_v2 as resnet_v2
|
6 |
import torch
|
7 |
import torch.nn as nn
|
8 |
import numpy as np
|
|
|
54 |
|
55 |
else: # TensorFlow
|
56 |
# Convert Image to NumPy and Normalize
|
57 |
+
image_preprocessed = resnet_v2.preprocess_input(image)
|
|
|
|
|
58 |
|
59 |
# Make Prediction
|
60 |
+
prediction = tf_model.predict(image_preprocessed)[0][0] # Extract single value
|
61 |
|
62 |
# Display Prediction
|
63 |
st.header(
|
|
|
65 |
divider='blue'
|
66 |
)
|
67 |
# Display Uploaded Image
|
68 |
+
st.image(image, caption="Uploaded image", use_container_width=True)
|
69 |
|