Rainnighttram commited on
Commit
c344b91
·
verified ·
1 Parent(s): 5ff3e81

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +16 -23
README.md CHANGED
@@ -92,7 +92,7 @@ if __name__ == "__main__":
92
  Script to test the vision model
93
  ```python
94
  import base64
95
- import subprocess
96
  import json
97
  import os
98
 
@@ -109,51 +109,44 @@ def encode_image_to_base64(image_path):
109
  print(f"Error encoding image: {str(e)}")
110
  return None
111
 
112
- def send_curl_request(base64_image):
113
- """Send base64 image to vision model server using curl in completions format."""
114
  try:
115
- # Prepare JSON payload
116
  payload = {
117
  "prompt": "Describe this image in detail.",
118
  "image": base64_image,
119
  "max_tokens": 300
120
  }
121
- payload_json = json.dumps(payload)
122
 
123
- curl_cmd = [
124
- "curl",
125
- "-X", "POST",
126
  "http://localhost:8000/v1/completions",
127
- "-H", "Content-Type: application/json",
128
- "-d", payload_json
129
- ]
130
 
131
- result = subprocess.run(curl_cmd, capture_output=True, text=True)
132
-
133
- if result.returncode == 0:
134
  print("Server response:")
135
- print(result.stdout)
136
  else:
137
- print(f"Curl command failed with code {result.returncode}:")
138
- print(result.stderr)
139
 
140
- except subprocess.SubprocessError as e:
141
- print(f"Error executing curl command: {str(e)}")
142
  except Exception as e:
143
  print(f"Unexpected error: {str(e)}")
144
 
145
  def main():
146
- image_path = "/path/to/your/image.jpeg"
147
 
148
  base64_image = encode_image_to_base64(image_path)
149
  if base64_image:
150
- # Send request
151
- send_curl_request(base64_image)
152
 
153
  if __name__ == "__main__":
154
  main()
155
  ```
156
- The quantized model can be loaded using a single GPU with VRAM larger than 8GB (Tested on Tesla T10)
157
  ```bash
158
  +-----------------------------------------------------------------------------------------+
159
  | NVIDIA-SMI 570.133.20 Driver Version: 570.133.20 CUDA Version: 12.8 |
 
92
  Script to test the vision model
93
  ```python
94
  import base64
95
+ import requests
96
  import json
97
  import os
98
 
 
109
  print(f"Error encoding image: {str(e)}")
110
  return None
111
 
112
+ def send_request(base64_image):
113
+ """Send base64 image to vision model server using requests."""
114
  try:
 
115
  payload = {
116
  "prompt": "Describe this image in detail.",
117
  "image": base64_image,
118
  "max_tokens": 300
119
  }
 
120
 
121
+ response = requests.post(
 
 
122
  "http://localhost:8000/v1/completions",
123
+ headers={"Content-Type": "application/json"},
124
+ json=payload
125
+ )
126
 
127
+ if response.status_code == 200:
 
 
128
  print("Server response:")
129
+ print(response.text)
130
  else:
131
+ print(f"Request failed with status code {response.status_code}:")
132
+ print(response.text)
133
 
134
+ except requests.RequestException as e:
135
+ print(f"Error sending request: {str(e)}")
136
  except Exception as e:
137
  print(f"Unexpected error: {str(e)}")
138
 
139
  def main():
140
+ image_path = "/path/to/sample.jpeg"
141
 
142
  base64_image = encode_image_to_base64(image_path)
143
  if base64_image:
144
+ send_request(base64_image)
 
145
 
146
  if __name__ == "__main__":
147
  main()
148
  ```
149
+ The quantized model can be loaded using a single GPU with VRAM larger than 12GB (Tested on Tesla T10)
150
  ```bash
151
  +-----------------------------------------------------------------------------------------+
152
  | NVIDIA-SMI 570.133.20 Driver Version: 570.133.20 CUDA Version: 12.8 |