Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -20,6 +20,7 @@ import fitz # PyMuPDF
|
|
20 |
import gradio as gr
|
21 |
import requests
|
22 |
import torch
|
|
|
23 |
from huggingface_hub import snapshot_download
|
24 |
from PIL import Image, ImageDraw, ImageFont
|
25 |
from transformers import AutoModelForCausalLM, AutoProcessor, VisionEncoderDecoderModel
|
@@ -32,6 +33,15 @@ import albumentations as alb
|
|
32 |
from albumentations.pytorch import ToTensorV2
|
33 |
from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
# --- Constants & Global State ---
|
36 |
MIN_PIXELS = 3136
|
37 |
MAX_PIXELS = 11289600
|
|
|
20 |
import gradio as gr
|
21 |
import requests
|
22 |
import torch
|
23 |
+
import subprocess
|
24 |
from huggingface_hub import snapshot_download
|
25 |
from PIL import Image, ImageDraw, ImageFont
|
26 |
from transformers import AutoModelForCausalLM, AutoProcessor, VisionEncoderDecoderModel
|
|
|
33 |
from albumentations.pytorch import ToTensorV2
|
34 |
from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
|
35 |
|
36 |
+
|
37 |
+
# Attempt to install flash-attn
|
38 |
+
try:
|
39 |
+
subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, check=True, shell=True)
|
40 |
+
except subprocess.CalledProcessError as e:
|
41 |
+
print(f"Error installing flash-attn: {e}")
|
42 |
+
print("Continuing without flash-attn.")
|
43 |
+
|
44 |
+
|
45 |
# --- Constants & Global State ---
|
46 |
MIN_PIXELS = 3136
|
47 |
MAX_PIXELS = 11289600
|