DumbledoreWiz commited on
Commit
cf14c94
·
verified ·
1 Parent(s): 4b0d68d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -13,9 +13,10 @@ labels = ['Leggings', 'Jogger', 'Palazzo', 'Cargo', 'Dresspants', 'Chinos']
13
  logging.info(f"Labels: {labels}")
14
 
15
  # Define paths to the model files (all in the same directory as app.py)
16
- model_path = "model.safetensors"
17
- config_path = "config.json"
18
- preprocessor_path = "preprocessor_config.json"
 
19
 
20
  # Check if all required files exist
21
  for path in [model_path, config_path, preprocessor_path]:
@@ -25,12 +26,9 @@ for path in [model_path, config_path, preprocessor_path]:
25
  else:
26
  logging.info(f"Found file: {path}")
27
 
28
- # Load the configuration and feature extractor
29
- config = ViTForImageClassification.from_pretrained(".", config=config_path)
30
- feature_extractor = ViTFeatureExtractor.from_pretrained(".")
31
-
32
- # Initialize the model with the configuration
33
- model = ViTForImageClassification.from_pretrained(".", config=config)
34
 
35
  # Ensure the model is in evaluation mode
36
  model.eval()
 
13
  logging.info(f"Labels: {labels}")
14
 
15
  # Define paths to the model files (all in the same directory as app.py)
16
+ model_dir = "." # Use current directory
17
+ model_path = os.path.join(model_dir, "model.safetensors")
18
+ config_path = os.path.join(model_dir, "config.json")
19
+ preprocessor_path = os.path.join(model_dir, "preprocessor_config.json")
20
 
21
  # Check if all required files exist
22
  for path in [model_path, config_path, preprocessor_path]:
 
26
  else:
27
  logging.info(f"Found file: {path}")
28
 
29
+ # Load the model and feature extractor using the local directory
30
+ feature_extractor = ViTFeatureExtractor.from_pretrained(model_dir)
31
+ model = ViTForImageClassification.from_pretrained(model_dir)
 
 
 
32
 
33
  # Ensure the model is in evaluation mode
34
  model.eval()