Update app.py
Browse files
app.py
CHANGED
|
@@ -18,17 +18,14 @@ 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 |
-
"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 |
-
# Set up Gradio interface
|
| 33 |
-
iface = gr.Interface(fn=classify_image, inputs=gr.Image(type="pil"), outputs="text")
|
| 34 |
iface.launch()
|
|
|
|
|
|
| 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 "Good Posture" if predicted.item() == 0 else "Bad Posture"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
# Set up Gradio interface with live webcam capture
|
| 29 |
+
iface = gr.Interface(fn=classify_image, inputs=gr.Image(type="pil", live=True), outputs="text")
|
| 30 |
iface.launch()
|
| 31 |
+
|