Pengi5659 commited on
Commit
df258fa
·
verified ·
1 Parent(s): 2a7bb73

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
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 "Good Posture! Sit exactly like that for your Interview!" if predicted.item() == 0 else "Bad Posture, you should think of sitting a little straighter or more in frame for your real interview."
 
 
 
 
27
 
28
- # Set up Gradio interface
29
- iface = gr.Interface(fn=classify_image, inputs=gr.Image(type="pil", height=150, width=150), outputs="text")
30
- iface.launch()
 
 
 
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