Handling uploaded file object
Browse files- custom_got/modeling_GOT.py +1 -1
- main_got.py +1 -1
custom_got/modeling_GOT.py
CHANGED
|
@@ -469,7 +469,7 @@ class GOTQwenForCausalLM(Qwen2ForCausalLM):
|
|
| 469 |
config.im_start_token, config.im_end_token = 151857, 151858
|
| 470 |
|
| 471 |
def load_image(self, image_file):
|
| 472 |
-
if image_file.startswith('http') or image_file.startswith('https'):
|
| 473 |
response = requests.get(image_file)
|
| 474 |
image = Image.open(BytesIO(response.content)).convert('RGB')
|
| 475 |
else:
|
|
|
|
| 469 |
config.im_start_token, config.im_end_token = 151857, 151858
|
| 470 |
|
| 471 |
def load_image(self, image_file):
|
| 472 |
+
if isinstance(image_file, str) and (image_file.startswith('http') or image_file.startswith('https')):
|
| 473 |
response = requests.get(image_file)
|
| 474 |
image = Image.open(BytesIO(response.content)).convert('RGB')
|
| 475 |
else:
|
main_got.py
CHANGED
|
@@ -22,5 +22,5 @@ def extract_text(image_path):
|
|
| 22 |
|
| 23 |
image_file = image_path
|
| 24 |
# Extract text
|
| 25 |
-
res = model.chat(tokenizer, image_file, ocr_type='ocr'
|
| 26 |
return res
|
|
|
|
| 22 |
|
| 23 |
image_file = image_path
|
| 24 |
# Extract text
|
| 25 |
+
res = model.chat(tokenizer, image_file, ocr_type='ocr')
|
| 26 |
return res
|