Update app.py
Browse files
app.py
CHANGED
|
@@ -4,10 +4,10 @@ import torchvision.transforms as transforms
|
|
| 4 |
import torchvision.models as models
|
| 5 |
from PIL import Image
|
| 6 |
|
| 7 |
-
# Load
|
| 8 |
model = models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1)
|
| 9 |
model.fc = torch.nn.Linear(model.fc.in_features, 2) # Adjust for two classes
|
| 10 |
-
model.eval()
|
| 11 |
|
| 12 |
# Define image transformation
|
| 13 |
transform = transforms.Compose([
|
|
@@ -25,6 +25,6 @@ def classify_image(image):
|
|
| 25 |
_, predicted = torch.max(output, 1)
|
| 26 |
return "Good Posture" if predicted.item() == 0 else "Bad Posture"
|
| 27 |
|
| 28 |
-
# Set up Gradio interface
|
| 29 |
-
iface = gr.Interface(fn=classify_image, inputs=gr.Image(type="pil"
|
| 30 |
iface.launch()
|
|
|
|
| 4 |
import torchvision.models as models
|
| 5 |
from PIL import Image
|
| 6 |
|
| 7 |
+
# Load ResNet18 model
|
| 8 |
model = models.resnet18(weights=models.ResNet18_Weights.IMAGENET1K_V1)
|
| 9 |
model.fc = torch.nn.Linear(model.fc.in_features, 2) # Adjust for two classes
|
| 10 |
+
model.eval()
|
| 11 |
|
| 12 |
# Define image transformation
|
| 13 |
transform = transforms.Compose([
|
|
|
|
| 25 |
_, predicted = torch.max(output, 1)
|
| 26 |
return "Good Posture" if predicted.item() == 0 else "Bad Posture"
|
| 27 |
|
| 28 |
+
# Set up Gradio interface
|
| 29 |
+
iface = gr.Interface(fn=classify_image, inputs=gr.Image(type="pil"), outputs="text")
|
| 30 |
iface.launch()
|