Praveen0309 commited on
Commit
1c98b64
·
1 Parent(s): 13bcbbe
Files changed (3) hide show
  1. __pycache__/main.cpython-39.pyc +0 -0
  2. main.py +14 -12
  3. static/script.js +2 -2
__pycache__/main.cpython-39.pyc ADDED
Binary file (4.5 kB). View file
 
main.py CHANGED
@@ -22,18 +22,20 @@ warnings.filterwarnings('ignore')
22
 
23
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
24
 
25
- # model_id = "HuggingFaceH4/vsft-llava-1.5-7b-hf-trl"
26
- # quantization_config = BitsAndBytesConfig(load_in_4bit=True)
27
- # base_model = LlavaForConditionalGeneration.from_pretrained(model_id, quantization_config=quantization_config, torch_dtype=torch.float16)
28
 
29
- # # Load the PEFT Lora adapter
30
- # peft_lora_adapter_path = "Praveen0309/llava-1.5-7b-hf-ft-mix-vsft-3"
31
- # peft_lora_adapter = PeftModel.from_pretrained(base_model, peft_lora_adapter_path, adapter_name="lora_adapter")
32
- # base_model.load_adapter(peft_lora_adapter_path, adapter_name="lora_adapter")
33
 
34
- # processor = AutoProcessor.from_pretrained("HuggingFaceH4/vsft-llava-1.5-7b-hf-trl")
35
- # model = M2M100ForConditionalGeneration.from_pretrained("facebook/m2m100_418M")
36
- # tokenizer = M2M100Tokenizer.from_pretrained("facebook/m2m100_418M")
 
 
 
 
 
 
 
 
 
37
 
38
 
39
  # model_id = r"C:\Users\prave\OneDrive\Desktop\MLOPS\Mlops_2\huggingface_model"
@@ -122,7 +124,7 @@ def facebook_response(url, input_sentence):
122
 
123
 
124
  image_cache = {}
125
- @app.post('/upload')
126
  def upload_file():
127
  try:
128
  file = request.files['file']
@@ -143,7 +145,7 @@ def upload_file():
143
  def home():
144
  return FileResponse(path="/app/static/index.html", media_type="text/html")
145
 
146
- @app.get("/get")
147
  def get_bot_response():
148
  try:
149
  if 'image' in image_cache:
 
22
 
23
  app.mount("/", StaticFiles(directory="static", html=True), name="static")
24
 
 
 
 
25
 
 
 
 
 
26
 
27
+ model_id = "HuggingFaceH4/vsft-llava-1.5-7b-hf-trl"
28
+ quantization_config = BitsAndBytesConfig(load_in_4bit=True)
29
+ base_model = LlavaForConditionalGeneration.from_pretrained(model_id, quantization_config=quantization_config, torch_dtype=torch.float16)
30
+
31
+ # Load the PEFT Lora adapter
32
+ peft_lora_adapter_path = "Praveen0309/llava-1.5-7b-hf-ft-mix-vsft-3"
33
+ peft_lora_adapter = PeftModel.from_pretrained(base_model, peft_lora_adapter_path, adapter_name="lora_adapter")
34
+ base_model.load_adapter(peft_lora_adapter_path, adapter_name="lora_adapter")
35
+
36
+ processor = AutoProcessor.from_pretrained("HuggingFaceH4/vsft-llava-1.5-7b-hf-trl")
37
+ model = M2M100ForConditionalGeneration.from_pretrained("facebook/m2m100_418M")
38
+ tokenizer = M2M100Tokenizer.from_pretrained("facebook/m2m100_418M")
39
 
40
 
41
  # model_id = r"C:\Users\prave\OneDrive\Desktop\MLOPS\Mlops_2\huggingface_model"
 
124
 
125
 
126
  image_cache = {}
127
+ @app.post("/upload/")
128
  def upload_file():
129
  try:
130
  file = request.files['file']
 
145
  def home():
146
  return FileResponse(path="/app/static/index.html", media_type="text/html")
147
 
148
+ @app.get("/get/")
149
  def get_bot_response():
150
  try:
151
  if 'image' in image_cache:
static/script.js CHANGED
@@ -3,7 +3,7 @@ $(document).ready(function(){
3
  e.preventDefault();
4
  $('#uploadStatus').html('<p>Status: Processing...</p>');
5
  $.ajax({
6
- url: '/upload',
7
  type: 'POST',
8
  data: new FormData(this),
9
  contentType: false,
@@ -64,7 +64,7 @@ $(document).ready(function(){
64
  message.draw();
65
 
66
  // Call getResponse() to get the chatbot's response
67
- $.get("/get", { msg: text }).done(function(data) {
68
  // Draw bot message with bot-message class
69
  var botMessage = new Message({
70
  text: data,
 
3
  e.preventDefault();
4
  $('#uploadStatus').html('<p>Status: Processing...</p>');
5
  $.ajax({
6
+ url: "/upload/",
7
  type: 'POST',
8
  data: new FormData(this),
9
  contentType: false,
 
64
  message.draw();
65
 
66
  // Call getResponse() to get the chatbot's response
67
+ $.get("/get/", { msg: text }).done(function(data) {
68
  // Draw bot message with bot-message class
69
  var botMessage = new Message({
70
  text: data,