Monimoy commited on
Commit
393615e
·
verified ·
1 Parent(s): 0673085

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -3,7 +3,7 @@ import os
3
  import gradio as gr
4
  import torch
5
  from PIL import Image
6
- from transformers import AutoTokenizer
7
  import timm
8
  from torchvision import transforms
9
  from llama_cpp import Llama
@@ -30,7 +30,7 @@ class SigLIPImageEncoder(torch.nn.Module):
30
 
31
  # 2. Load Models and Tokenizer
32
  phi3_model_path = "QuantFactory/Phi-3-mini-4k-instruct-GGUF" # Path to your quantized Phi-3 GGUF model
33
- peft_model_path = "./qlora_phi3_model"
34
  image_model_name = 'resnet50'
35
  image_embed_dim = 512
36
  siglip_pretrained_path = "image_encoder.pth" # Path to your pretrained SigLIP model
@@ -62,13 +62,18 @@ image_encoder.eval() # Set to evaluation mode
62
  #)
63
 
64
 
65
- base_model = Llama.from_pretrained(
66
- repo_id="QuantFactory/Phi-3-mini-4k-instruct-GGUF",
67
- filename="Phi-3-mini-4k-instruct.Q2_K.gguf",
68
- n_gpu_layers=0,
69
- n_ctx=2048,
70
- verbose=True
71
- )
 
 
 
 
 
72
 
73
 
74
  # Load and merge
 
3
  import gradio as gr
4
  import torch
5
  from PIL import Image
6
+ from transformers import AutoTokenizer, AutoModelForCausalLM
7
  import timm
8
  from torchvision import transforms
9
  from llama_cpp import Llama
 
30
 
31
  # 2. Load Models and Tokenizer
32
  phi3_model_path = "QuantFactory/Phi-3-mini-4k-instruct-GGUF" # Path to your quantized Phi-3 GGUF model
33
+ peft_model_path = "./qlora-phi3-model"
34
  image_model_name = 'resnet50'
35
  image_embed_dim = 512
36
  siglip_pretrained_path = "image_encoder.pth" # Path to your pretrained SigLIP model
 
62
  #)
63
 
64
 
65
+ #base_model = Llama.from_pretrained(
66
+ # repo_id="QuantFactory/Phi-3-mini-4k-instruct-GGUF",
67
+ # filename="Phi-3-mini-4k-instruct.Q2_K.gguf",
68
+ # n_gpu_layers=0,
69
+ # n_ctx=2048,
70
+ # verbose=True
71
+ #)
72
+
73
+ base_model_name="microsoft/Phi-3-mini-4k-instruct"
74
+ device = "cpu"
75
+
76
+ base_model = AutoModelForCausalLM.from_pretrained(base_model_name, torch_dtype=torch.float32, device_map={"": device})
77
 
78
 
79
  # Load and merge