LEGENDCODER1 commited on
Commit
17823c3
·
verified ·
1 Parent(s): fff9610

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -13
app.py CHANGED
@@ -1,22 +1,34 @@
1
- from transformers import pipeline
 
 
2
  import gradio as gr
3
 
4
- # Use a lightweight model for testing
5
- model = pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")
 
6
 
7
- # A simple function to test the app
8
- def classify_text(text):
9
- return model(text)
 
10
 
11
- # Gradio interface
 
 
 
 
 
 
 
 
12
  interface = gr.Interface(
13
- fn=classify_text,
14
- inputs="text",
15
- outputs="json",
16
- title="Text Classification Test",
17
- description="Enter a sentence to classify its sentiment."
18
  )
19
 
20
- # Launch the app
21
  if __name__ == "__main__":
22
  interface.launch(server_name="0.0.0.0")
 
1
+ import cv2
2
+ import numpy as np
3
+ import mediapipe as mp
4
  import gradio as gr
5
 
6
+ # Initialize MediaPipe Pose model
7
+ mp_pose = mp.solutions.pose
8
+ pose = mp_pose.Pose()
9
 
10
+ # Function to detect pose
11
+ def detect_pose(image):
12
+ # Convert image from RGB to BGR for OpenCV processing
13
+ image_rgb = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
14
 
15
+ # Run MediaPipe Pose model
16
+ results = pose.process(image_rgb)
17
+
18
+ if results.pose_landmarks:
19
+ return "Person Detected: Standing or Sitting Pose Identified"
20
+ else:
21
+ return "No person detected, please try again"
22
+
23
+ # Gradio Interface
24
  interface = gr.Interface(
25
+ fn=detect_pose,
26
+ inputs=gr.Image(type="pil"), # Accepts an image as input
27
+ outputs="text", # Outputs the detected pose
28
+ title="Pose Detection for Exoskeleton",
29
+ description="Upload an image of a person sitting or standing. The model will determine their pose."
30
  )
31
 
32
+ # Launch the Gradio App
33
  if __name__ == "__main__":
34
  interface.launch(server_name="0.0.0.0")