zluda vqa florence

This commit is contained in:
Seunghoon Lee
2024-06-24 14:22:22 +09:00
parent cc9b7c326e
commit bb44955fd0
3 changed files with 33 additions and 16 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ import torch
import transformers
from PIL import Image
from modules import shared, devices
from modules.zluda import is_zluda
processor = None
@@ -129,7 +130,7 @@ def moondream(question: str, image: Image.Image, repo: str = None):
def florence(question: str, image: Image.Image, repo: str = None):
global processor, model, loaded # pylint: disable=global-statement
from installer import install, installed
if not installed('flash_attn', quiet=True):
if not installed('flash_attn', quiet=True) and not is_zluda(devices.device):
install('flash_attn')
if model is None or loaded != repo:
model = transformers.AutoModelForCausalLM.from_pretrained(repo, trust_remote_code=True)