sohamnk commited on
Commit
ccb5338
Β·
verified Β·
1 Parent(s): 3b235ec
Files changed (1) hide show
  1. pipeline/__init__.py +7 -15
pipeline/__init__.py CHANGED
@@ -5,25 +5,17 @@ from flask import Flask
5
  FEATURE_WEIGHTS = {"shape": 0.4, "color": 0.5, "texture": 0.1}
6
  FINAL_SCORE_THRESHOLD = 0.5
7
 
8
- # Create Flask app
9
  app = Flask(__name__)
10
 
11
- # Load models
12
- print("=" * 50)
13
  print("πŸš€ Initializing application and loading models...")
14
-
15
  device_name = os.environ.get("device", "cpu")
16
- device = torch.device(
17
- 'cuda' if 'cuda' in device_name and torch.cuda.is_available() else 'cpu'
18
- )
19
  print(f"🧠 Using device: {device}")
20
 
21
- from transformers import (
22
- AutoProcessor,
23
- AutoModelForZeroShotObjectDetection,
24
- AutoTokenizer,
25
- AutoModel
26
- )
27
  from segment_anything import SamPredictor, sam_model_registry
28
 
29
  print("...Loading Grounding DINO model...")
@@ -53,7 +45,7 @@ models = {
53
  }
54
 
55
  print("βœ… All models loaded successfully.")
56
- print("=" * 50)
57
 
58
  # Import routes after app and models are defined to avoid circular imports
59
- from pipeline import routes
 
5
  FEATURE_WEIGHTS = {"shape": 0.4, "color": 0.5, "texture": 0.1}
6
  FINAL_SCORE_THRESHOLD = 0.5
7
 
8
+ # create flask app
9
  app = Flask(__name__)
10
 
11
+ # load models
12
+ print("="*50)
13
  print("πŸš€ Initializing application and loading models...")
 
14
  device_name = os.environ.get("device", "cpu")
15
+ device = torch.device('cuda' if 'cuda' in device_name and torch.cuda.is_available() else 'cpu')
 
 
16
  print(f"🧠 Using device: {device}")
17
 
18
+ from transformers import AutoProcessor, AutoModelForZeroShotObjectDetection, AutoTokenizer, AutoModel
 
 
 
 
 
19
  from segment_anything import SamPredictor, sam_model_registry
20
 
21
  print("...Loading Grounding DINO model...")
 
45
  }
46
 
47
  print("βœ… All models loaded successfully.")
48
+ print("="*50)
49
 
50
  # Import routes after app and models are defined to avoid circular imports
51
+ from pipeline import routes