Update app.py
Browse files
app.py
CHANGED
|
@@ -18,13 +18,19 @@ transform = transforms.Compose([
|
|
| 18 |
# Function to classify posture images
|
| 19 |
def classify_image(image):
|
| 20 |
if image is None:
|
| 21 |
-
return "No image provided!"
|
| 22 |
|
| 23 |
image = transform(image).unsqueeze(0)
|
| 24 |
output = model(image)
|
| 25 |
_, predicted = torch.max(output, 1)
|
| 26 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
#
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
| 18 |
# Function to classify posture images
|
| 19 |
def classify_image(image):
|
| 20 |
if image is None:
|
| 21 |
+
return "No image provided! Please capture or upload an image."
|
| 22 |
|
| 23 |
image = transform(image).unsqueeze(0)
|
| 24 |
output = model(image)
|
| 25 |
_, predicted = torch.max(output, 1)
|
| 26 |
+
return (
|
| 27 |
+
"Good Posture! Sit exactly like that for your Interview!"
|
| 28 |
+
if predicted.item() == 0
|
| 29 |
+
else "Bad Posture, you should think of sitting a little straighter or more in frame for your real interview."
|
| 30 |
+
)
|
| 31 |
|
| 32 |
+
# Create a compact Gradio layout using Blocks
|
| 33 |
+
with gr.Blocks() as demo:
|
| 34 |
+
gr.Markdown("### Posture Classifier")
|
| 35 |
+
|
| 36 |
+
img_input = gr.Image
|