Moditha24 commited on
Commit
9197021
·
verified ·
1 Parent(s): 93ff5a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -4,6 +4,18 @@ import torchvision.transforms as transforms
4
  from PIL import Image
5
  from resnet import SupCEResNet # Ensure the correct import path
6
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  # ✅ Define class labels (from Clothing1M)
8
  class_labels = [
9
  "T-Shirt", "Shirt", "Knitwear", "Chiffon", "Sweater", "Hoodie",
 
4
  from PIL import Image
5
  from resnet import SupCEResNet # Ensure the correct import path
6
 
7
+ import subprocess
8
+ import sys
9
+
10
+ # Ensure torch is installed before importing
11
+ try:
12
+ import torch
13
+ except ModuleNotFoundError:
14
+ print("🚨 Torch not found! Installing...")
15
+ subprocess.run([sys.executable, "-m", "pip", "install", "torch", "torchvision", "torchaudio"], check=True)
16
+ import torch # Try again after installation
17
+
18
+
19
  # ✅ Define class labels (from Clothing1M)
20
  class_labels = [
21
  "T-Shirt", "Shirt", "Knitwear", "Chiffon", "Sweater", "Hoodie",