Spaces:
Running
on
Zero
Running
on
Zero
Uploading FoodExtract-Vision demo app.py
Browse files- .gitattributes +3 -0
- app.py +9 -4
- examples/Tandoori-Chicken.jpg +3 -0
- examples/camera.jpeg +3 -0
- examples/fries.jpeg +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
examples/Tandoori-Chicken.jpg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
examples/camera.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
examples/fries.jpeg filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -9,6 +9,7 @@ FINE_TUNED_MODEL_ID = "mrdbourke/FoodExtract-Vision-SmolVLM2-500M-fine-tune-v1"
|
|
| 9 |
OUTPUT_TOKENS = 256
|
| 10 |
|
| 11 |
# Load original base model (no fine-tuning)
|
|
|
|
| 12 |
original_pipeline = pipeline(
|
| 13 |
"image-text-to-text",
|
| 14 |
model=BASE_MODEL_ID,
|
|
@@ -17,6 +18,7 @@ original_pipeline = pipeline(
|
|
| 17 |
)
|
| 18 |
|
| 19 |
# Load fine-tuned model
|
|
|
|
| 20 |
ft_pipe = pipeline(
|
| 21 |
"image-text-to-text",
|
| 22 |
model=FINE_TUNED_MODEL_ID,
|
|
@@ -43,9 +45,9 @@ def extract_foods_from_image(input_image):
|
|
| 43 |
outputs_pretrained = original_pipeline_output[0][0]["generated_text"][-1]["content"]
|
| 44 |
|
| 45 |
# Get outputs from fine-tuned model (fine-tuned on food images)
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
outputs_fine_tuned =
|
| 49 |
|
| 50 |
return outputs_pretrained, outputs_fine_tuned
|
| 51 |
|
|
@@ -92,7 +94,10 @@ demo = gr.Interface(
|
|
| 92 |
title=demo_title,
|
| 93 |
description=demo_description,
|
| 94 |
outputs=[gr.Textbox(lines=4, label="Original Model (not fine-tuned)"),
|
| 95 |
-
gr.Textbox(lines=4, label="Fine-tuned Model")]
|
|
|
|
|
|
|
|
|
|
| 96 |
)
|
| 97 |
|
| 98 |
if __name__ == "__main__":
|
|
|
|
| 9 |
OUTPUT_TOKENS = 256
|
| 10 |
|
| 11 |
# Load original base model (no fine-tuning)
|
| 12 |
+
print(f"[INFO] Loading Original Model")
|
| 13 |
original_pipeline = pipeline(
|
| 14 |
"image-text-to-text",
|
| 15 |
model=BASE_MODEL_ID,
|
|
|
|
| 18 |
)
|
| 19 |
|
| 20 |
# Load fine-tuned model
|
| 21 |
+
print(f"[INFO] Loading Fine-tuned Model")
|
| 22 |
ft_pipe = pipeline(
|
| 23 |
"image-text-to-text",
|
| 24 |
model=FINE_TUNED_MODEL_ID,
|
|
|
|
| 45 |
outputs_pretrained = original_pipeline_output[0][0]["generated_text"][-1]["content"]
|
| 46 |
|
| 47 |
# Get outputs from fine-tuned model (fine-tuned on food images)
|
| 48 |
+
ft_pipe_output = ft_pipe(text=[input_message],
|
| 49 |
+
max_new_tokens=OUTPUT_TOKENS)
|
| 50 |
+
outputs_fine_tuned = ft_pipe_output[0][0]["generated_text"][-1]["content"]
|
| 51 |
|
| 52 |
return outputs_pretrained, outputs_fine_tuned
|
| 53 |
|
|
|
|
| 94 |
title=demo_title,
|
| 95 |
description=demo_description,
|
| 96 |
outputs=[gr.Textbox(lines=4, label="Original Model (not fine-tuned)"),
|
| 97 |
+
gr.Textbox(lines=4, label="Fine-tuned Model")],
|
| 98 |
+
examples=[["examples/camera.jpeg"],
|
| 99 |
+
["examples/Tandoori-Chicken.jpg"],
|
| 100 |
+
["examples/fries.jpeg"]],
|
| 101 |
)
|
| 102 |
|
| 103 |
if __name__ == "__main__":
|
examples/Tandoori-Chicken.jpg
ADDED
|
Git LFS Details
|
examples/camera.jpeg
ADDED
|
Git LFS Details
|
examples/fries.jpeg
ADDED
|
Git LFS Details
|