Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -43,7 +43,7 @@ def fixed_get_imports(filename):
|
|
43 |
|
44 |
|
45 |
import subprocess
|
46 |
-
|
47 |
|
48 |
def download_file(url, folder_path, filename):
|
49 |
if not os.path.exists(folder_path):
|
@@ -125,13 +125,13 @@ DEFAULT_NEGATIVE_SUFFIX = "Nsfw oversaturated crappy_art low_quality blurry bad_
|
|
125 |
# Initialize Florence model
|
126 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
florence_model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True).to(device).eval()
|
131 |
-
florence_processor = AutoProcessor.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True)
|
132 |
-
|
133 |
|
134 |
-
|
135 |
|
136 |
# Prompt Enhancer
|
137 |
enhancer_medium = pipeline("summarization", model="gokaygokay/Lamini-Prompt-Enchance", device=device)
|
|
|
43 |
|
44 |
|
45 |
import subprocess
|
46 |
+
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
47 |
|
48 |
def download_file(url, folder_path, filename):
|
49 |
if not os.path.exists(folder_path):
|
|
|
125 |
# Initialize Florence model
|
126 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
127 |
|
128 |
+
def load_models():
|
129 |
+
with patch("transformers.dynamic_module_utils.get_imports", fixed_get_imports):
|
130 |
+
florence_model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True).to(device).eval()
|
131 |
+
florence_processor = AutoProcessor.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True)
|
132 |
+
return florence_model, florence_processor
|
133 |
|
134 |
+
florence_model, florence_processor = load_models()
|
135 |
|
136 |
# Prompt Enhancer
|
137 |
enhancer_medium = pipeline("summarization", model="gokaygokay/Lamini-Prompt-Enchance", device=device)
|