Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1 |
-
import gradio as gr
|
2 |
import subprocess
|
|
|
|
|
|
|
|
|
|
|
3 |
import torch
|
4 |
from PIL import Image
|
5 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
6 |
|
7 |
-
# subprocess to install flash-attn if necessary (commented for now)
|
8 |
-
# subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
9 |
-
|
10 |
# Initialize Florence model
|
11 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
12 |
florence_model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True).to(device).eval()
|
|
|
|
|
1 |
import subprocess
|
2 |
+
|
3 |
+
# 安裝缺少的依賴包
|
4 |
+
subprocess.run("pip install einops", shell=True)
|
5 |
+
|
6 |
+
import gradio as gr
|
7 |
import torch
|
8 |
from PIL import Image
|
9 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
10 |
|
|
|
|
|
|
|
11 |
# Initialize Florence model
|
12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
13 |
florence_model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True).to(device).eval()
|