gokaygokay commited on
Commit
c70255d
·
verified ·
1 Parent(s): 10e1f89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -119,10 +119,13 @@ DEFAULT_NEGATIVE_SUFFIX = "Nsfw oversaturated crappy_art low_quality blurry bad_
119
 
120
  device = "cuda" if torch.cuda.is_available() else "cpu"
121
 
122
- #def load_models():
123
- #with patch("transformers.dynamic_module_utils.get_imports", fixed_get_imports):
124
- florence_model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True).to(device).eval()
125
- florence_processor = AutoProcessor.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True)
 
 
 
126
 
127
  # Prompt Enhancer
128
  enhancer_medium = pipeline("summarization", model="gokaygokay/Lamini-Prompt-Enchance", device=device)
 
119
 
120
  device = "cuda" if torch.cuda.is_available() else "cpu"
121
 
122
+ def load_models():
123
+ with patch("transformers.dynamic_module_utils.get_imports", fixed_get_imports):
124
+ florence_model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True).to(device).eval()
125
+ florence_processor = AutoProcessor.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True)
126
+ return florence_model, florence_processor
127
+
128
+ florence_model, florence_processor = load_models()
129
 
130
  # Prompt Enhancer
131
  enhancer_medium = pipeline("summarization", model="gokaygokay/Lamini-Prompt-Enchance", device=device)