Fahimeh Orvati Nia commited on
Commit
dffab99
·
1 Parent(s): 7613956

update the secret

Browse files
sorghum_pipeline/pipeline.py CHANGED
@@ -33,6 +33,7 @@ class SorghumPipeline:
33
  self.vegetation_extractor = VegetationIndexExtractor()
34
  self.morphology_extractor = MorphologyExtractor()
35
  self.segmentation_manager = SegmentationManager(
 
36
  device=self.config.get_device(),
37
  trust_remote_code=True
38
  )
 
33
  self.vegetation_extractor = VegetationIndexExtractor()
34
  self.morphology_extractor = MorphologyExtractor()
35
  self.segmentation_manager = SegmentationManager(
36
+ model_name="briaai/RMBG-2.0",
37
  device=self.config.get_device(),
38
  trust_remote_code=True
39
  )
sorghum_pipeline/segmentation/manager.py CHANGED
@@ -25,12 +25,17 @@ class SegmentationManager:
25
  self.threshold = threshold
26
  self.device = "cuda" if device == "auto" and torch.cuda.is_available() else device
27
 
 
 
 
 
28
  logger.info(f"Loading BRIA model: {model_name}")
29
  self.model = AutoModelForImageSegmentation.from_pretrained(
30
  model_name,
31
  trust_remote_code=trust_remote_code,
32
  cache_dir=cache_dir if cache_dir else None,
33
  local_files_only=local_files_only,
 
34
  ).eval().to(self.device)
35
 
36
  self.transform = transforms.Compose([
 
25
  self.threshold = threshold
26
  self.device = "cuda" if device == "auto" and torch.cuda.is_available() else device
27
 
28
+ # Get HF token from environment (set as Space secret)
29
+ import os
30
+ hf_token = os.environ.get("HF_TOKEN")
31
+
32
  logger.info(f"Loading BRIA model: {model_name}")
33
  self.model = AutoModelForImageSegmentation.from_pretrained(
34
  model_name,
35
  trust_remote_code=trust_remote_code,
36
  cache_dir=cache_dir if cache_dir else None,
37
  local_files_only=local_files_only,
38
+ token=hf_token,
39
  ).eval().to(self.device)
40
 
41
  self.transform = transforms.Compose([