Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,15 @@
|
|
| 1 |
import random
|
| 2 |
-
import torch
|
| 3 |
import spaces
|
| 4 |
import gradio as gr
|
| 5 |
-
from transformers import
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
model_path = "ibm-granite/granite-vision-3.1-2b-preview"
|
| 8 |
-
processor =
|
| 9 |
-
|
| 10 |
-
use_fast=True,
|
| 11 |
-
image_processor_type = 'llava_next'
|
| 12 |
-
)
|
| 13 |
-
model = LlavaNextForConditionalGeneration.from_pretrained(model_path, torch_dtype="auto", device_map="auto")
|
| 14 |
|
| 15 |
@spaces.GPU()
|
| 16 |
def get_text_from_content(content):
|
|
|
|
| 1 |
import random
|
|
|
|
| 2 |
import spaces
|
| 3 |
import gradio as gr
|
| 4 |
+
from transformers import AutoProcessor, AutoModelForVision2Seq
|
| 5 |
+
from huggingface_hub import hf_hub_download
|
| 6 |
+
import torch
|
| 7 |
+
|
| 8 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 9 |
|
| 10 |
model_path = "ibm-granite/granite-vision-3.1-2b-preview"
|
| 11 |
+
processor = AutoProcessor.from_pretrained(model_path)
|
| 12 |
+
model = AutoModelForVision2Seq.from_pretrained(model_path).to(device)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
@spaces.GPU()
|
| 15 |
def get_text_from_content(content):
|