Skip to content

Commit da91c26

Browse files
authored
fix gradio image path (#2681)
1 parent 68aa665 commit da91c26

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

notebooks/phi-3-vision/gradio_helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def bot_streaming(message, history):
2828
if isinstance(files[-1], dict):
2929
image = files[-1]["path"]
3030
else:
31-
image = files[-1] if isinstance(files[-1], (list, tuple)) else files[-1].path
31+
image = files[-1] if isinstance(files[-1], (list, tuple, str)) else files[-1].path
3232
else:
3333
# if there's no image uploaded for this turn, look for images in the past turns
3434
# kept inside tuples, take the last one

notebooks/phi-3-vision/phi-3-vision.ipynb

+16-3
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@
207207
"</details>"
208208
]
209209
},
210+
{
211+
"cell_type": "code",
212+
"execution_count": null,
213+
"id": "c8ab9110",
214+
"metadata": {},
215+
"outputs": [],
216+
"source": [
217+
"to_compress = widgets.Checkbox(value=True, description=\"Compress model\", disabled=False)\n",
218+
"\n",
219+
"to_compress"
220+
]
221+
},
210222
{
211223
"cell_type": "code",
212224
"execution_count": 5,
@@ -312,8 +324,9 @@
312324
"source": [
313325
"from cmd_helper import optimum_cli\n",
314326
"\n",
315-
"if not (MODEL_DIR / \"INT4\").exists():\n",
316-
" optimum_cli(model_id, MODEL_DIR / \"INT4\", additional_args={\"weight-format\": \"int4\", \"trust-remote-code\": \"\"})"
327+
"model_dir = MODEL_DIR / \"INT4\" if to_compress.value else MODEL_DIR / \"FP16\"\n",
328+
"if not model_dir.exists():\n",
329+
" optimum_cli(model_id, model_dir, additional_args={\"weight-format\": \"int4\" if to_compress.value else \"fp16\", \"trust-remote-code\": \"\"})"
317330
]
318331
},
319332
{
@@ -377,7 +390,7 @@
377390
"source": [
378391
"from optimum.intel.openvino import OVModelForVisualCausalLM\n",
379392
"\n",
380-
"model = OVModelForVisualCausalLM.from_pretrained(MODEL_DIR / \"INT4\", device=device.value, trust_remote_code=True)"
393+
"model = OVModelForVisualCausalLM.from_pretrained(model_dir, device=device.value, trust_remote_code=True)"
381394
]
382395
},
383396
{

0 commit comments

Comments
 (0)