Spaces:
Running
on
Zero
Running
on
Zero
Upload app.py
Browse files
app.py
CHANGED
|
@@ -128,12 +128,17 @@ def run_model(prompt: str, image: Optional[Image.Image], system_prompt: Optional
|
|
| 128 |
if torch.cuda.is_available():
|
| 129 |
model_kwargs["device_map"] = "auto"
|
| 130 |
model = AutoModelForImageTextToText.from_pretrained(MODEL_ID, **model_kwargs)
|
| 131 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
vlm = pipeline(
|
| 133 |
task="image-text-to-text",
|
| 134 |
model=model,
|
| 135 |
processor=processor,
|
| 136 |
-
generation_config=gen_cfg,
|
| 137 |
)
|
| 138 |
# Store for reuse
|
| 139 |
run_model.model = model
|
|
|
|
| 128 |
if torch.cuda.is_available():
|
| 129 |
model_kwargs["device_map"] = "auto"
|
| 130 |
model = AutoModelForImageTextToText.from_pretrained(MODEL_ID, **model_kwargs)
|
| 131 |
+
# Apply our generation configuration directly to the model. The
|
| 132 |
+
# transformers pipeline does not accept a ``generation_config``
|
| 133 |
+
# keyword argument, so we assign it here. See the Spaces
|
| 134 |
+
# documentation for more details on setting generation options.
|
| 135 |
+
model.generation_config = gen_cfg
|
| 136 |
+
# Create a pipeline for convenience. The pipeline will use the
|
| 137 |
+
# model's generation_config when invoked.
|
| 138 |
vlm = pipeline(
|
| 139 |
task="image-text-to-text",
|
| 140 |
model=model,
|
| 141 |
processor=processor,
|
|
|
|
| 142 |
)
|
| 143 |
# Store for reuse
|
| 144 |
run_model.model = model
|