Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,7 @@ import cv2
|
|
| 15 |
|
| 16 |
from transformers import (
|
| 17 |
Qwen2_5_VLForConditionalGeneration,
|
|
|
|
| 18 |
AutoProcessor,
|
| 19 |
TextIteratorStreamer,
|
| 20 |
)
|
|
@@ -27,10 +28,10 @@ MAX_INPUT_TOKEN_LENGTH = int(os.getenv("MAX_INPUT_TOKEN_LENGTH", "4096"))
|
|
| 27 |
|
| 28 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 29 |
|
| 30 |
-
# Load
|
| 31 |
-
MODEL_ID_M = "
|
| 32 |
processor_m = AutoProcessor.from_pretrained(MODEL_ID_M, trust_remote_code=True)
|
| 33 |
-
model_m =
|
| 34 |
MODEL_ID_M,
|
| 35 |
trust_remote_code=True,
|
| 36 |
torch_dtype=torch.float16
|
|
@@ -85,7 +86,7 @@ def generate_image(model_name: str, text: str, image: Image.Image,
|
|
| 85 |
"""
|
| 86 |
Generates responses using the selected model for image input.
|
| 87 |
"""
|
| 88 |
-
if model_name == "
|
| 89 |
processor = processor_m
|
| 90 |
model = model_m
|
| 91 |
elif model_name == "docscopeOCR-7B-050425-exp":
|
|
@@ -138,7 +139,7 @@ def generate_video(model_name: str, text: str, video_path: str,
|
|
| 138 |
"""
|
| 139 |
Generates responses using the selected model for video input.
|
| 140 |
"""
|
| 141 |
-
if model_name == "
|
| 142 |
processor = processor_m
|
| 143 |
model = model_m
|
| 144 |
elif model_name == "docscopeOCR-7B-050425-exp":
|
|
@@ -244,9 +245,9 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
| 244 |
with gr.Column():
|
| 245 |
output = gr.Textbox(label="Output", interactive=False, lines=2, scale=2)
|
| 246 |
model_choice = gr.Radio(
|
| 247 |
-
choices=["
|
| 248 |
label="Select Model",
|
| 249 |
-
value="
|
| 250 |
)
|
| 251 |
|
| 252 |
gr.Markdown("**Model Info**")
|
|
|
|
| 15 |
|
| 16 |
from transformers import (
|
| 17 |
Qwen2_5_VLForConditionalGeneration,
|
| 18 |
+
Gemma3ForConditionalGeneration,
|
| 19 |
AutoProcessor,
|
| 20 |
TextIteratorStreamer,
|
| 21 |
)
|
|
|
|
| 28 |
|
| 29 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
| 30 |
|
| 31 |
+
# Load gemma-3-4b-it
|
| 32 |
+
MODEL_ID_M = "google/gemma-3-4b-it"
|
| 33 |
processor_m = AutoProcessor.from_pretrained(MODEL_ID_M, trust_remote_code=True)
|
| 34 |
+
model_m = Gemma3ForConditionalGeneration.from_pretrained(
|
| 35 |
MODEL_ID_M,
|
| 36 |
trust_remote_code=True,
|
| 37 |
torch_dtype=torch.float16
|
|
|
|
| 86 |
"""
|
| 87 |
Generates responses using the selected model for image input.
|
| 88 |
"""
|
| 89 |
+
if model_name == "gemma-3-4b-it":
|
| 90 |
processor = processor_m
|
| 91 |
model = model_m
|
| 92 |
elif model_name == "docscopeOCR-7B-050425-exp":
|
|
|
|
| 139 |
"""
|
| 140 |
Generates responses using the selected model for video input.
|
| 141 |
"""
|
| 142 |
+
if model_name == "gemma-3-4b-it":
|
| 143 |
processor = processor_m
|
| 144 |
model = model_m
|
| 145 |
elif model_name == "docscopeOCR-7B-050425-exp":
|
|
|
|
| 245 |
with gr.Column():
|
| 246 |
output = gr.Textbox(label="Output", interactive=False, lines=2, scale=2)
|
| 247 |
model_choice = gr.Radio(
|
| 248 |
+
choices=["gemma-3-4b-it", "docscopeOCR-7B-050425-exp", "Captioner-7B"],
|
| 249 |
label="Select Model",
|
| 250 |
+
value="gemma-3-4b-it"
|
| 251 |
)
|
| 252 |
|
| 253 |
gr.Markdown("**Model Info**")
|