Futuretop commited on
Commit
15cb9c1
Β·
verified Β·
1 Parent(s): b771622

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -10,11 +10,18 @@ subprocess.run(
10
  check=True
11
  )
12
 
13
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14
- model = 'microsoft/Florence-2-base-ft'
15
- florence_model = AutoModelForConditionalGeneration.from_pretrained(
16
- model,
17
- trust_remote_code=True).to(device).eval()
 
 
 
 
 
 
 
18
  florence_processor = AutoProcessor.from_pretrained(model, trust_remote_code=True)
19
 
20
  def generate_caption(image):
 
10
  check=True
11
  )
12
 
13
+ device = torch.device("cuda" if torch.cuda.is_available() else "CPU")
14
+
15
+ config = AutoConfig.from_pretrained(model_id, trust_remote_code=True)
16
+
17
+ module_base = config.__module__.rsplit(".", 1)[0]
18
+ modeling_mod_path = module_base + ".modeling_florence2"
19
+ modeling_mod = importlib.import_module(modeling_mod_path)
20
+
21
+ FlorenceLM = getattr(
22
+ modeling_mod,
23
+ "Florence2LanguageForConditionalGeneration"
24
+ )
25
  florence_processor = AutoProcessor.from_pretrained(model, trust_remote_code=True)
26
 
27
  def generate_caption(image):