ninjals commited on
Commit
f5c862c
·
verified ·
1 Parent(s): 77f345f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -8,16 +8,13 @@ BASE_MODEL_ID = "HuggingFaceTB/SmolVLM2-500M-Video-Instruct"
8
  FINE_TUNED_MODEL_ID = "mrdbourke/FoodExtract-Vision-SmolVLM2-500M-fine-tune-v1"
9
  OUTPUT_TOKENS = 256
10
 
11
- # Change this in your app.py to match your training bf16=True setting
12
- DTYPE = torch.float16
13
-
14
  # Load original base model (no fine-tuning)
15
  print(f"[INFO] Loading Original Model")
16
  original_pipeline = pipeline(
17
  "image-text-to-text",
18
  model=BASE_MODEL_ID,
19
- torch_dtype=DTYPE,
20
- device_map="auto",
21
  )
22
 
23
  # Load fine-tuned model
@@ -25,14 +22,10 @@ print(f"[INFO] Loading Fine-tuned Model")
25
  ft_pipe = pipeline(
26
  "image-text-to-text",
27
  model=FINE_TUNED_MODEL_ID,
28
- torch_dtype=DTYPE,
29
- device_map="auto",
30
  )
31
 
32
- print(f"[INFO] Original Model Datatype: {original_pipeline.model.dtype}")
33
- print(f"[INFO] Fine-tuned Model Datatype: {ft_pipe.model.dtype}")
34
-
35
-
36
  def create_message(input_image):
37
  return [{'role': 'user',
38
  'content': [{'type': 'image',
@@ -100,3 +93,5 @@ demo = gr.Interface(
100
 
101
  if __name__ == "__main__":
102
  demo.launch(share=False)
 
 
 
8
  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
  print(f"[INFO] Loading Original Model")
13
  original_pipeline = pipeline(
14
  "image-text-to-text",
15
  model=BASE_MODEL_ID,
16
+ dtype=torch.bfloat16,
17
+ device_map="auto"
18
  )
19
 
20
  # Load fine-tuned model
 
22
  ft_pipe = pipeline(
23
  "image-text-to-text",
24
  model=FINE_TUNED_MODEL_ID,
25
+ dtype=torch.bfloat16,
26
+ device_map="auto"
27
  )
28
 
 
 
 
 
29
  def create_message(input_image):
30
  return [{'role': 'user',
31
  'content': [{'type': 'image',
 
93
 
94
  if __name__ == "__main__":
95
  demo.launch(share=False)
96
+
97
+