diff --git a/app/qwenvl.py b/app/qwenvl.py index 77114cb..614ec27 100644 --- a/app/qwenvl.py +++ b/app/qwenvl.py @@ -37,7 +37,7 @@ class Qwen2VLClass: # max_pixels = 1280*28*28 # processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct", min_pixels=min_pixels, max_pixels=max_pixels) - def inference(self, prompt, image=None, videofile=None): + def inference(self, prompt, image, videofile): content = [ { "type":"text", @@ -88,10 +88,10 @@ class Qwen2VLClass: generated_ids_trimmed = [ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids) ] - output_text = processor.batch_decode( + output_text = self.processor.batch_decode( generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False ) - return output_text + return output_text[0] def main(): config = getConfig() diff --git a/app/test.py b/app/test.py index 8d32925..83d106d 100644 --- a/app/test.py +++ b/app/test.py @@ -1,3 +1,4 @@ +import time import requests import base64 @@ -21,9 +22,11 @@ while True: i = input() if p == '' or i == '': continue + t1 = time.time() ret = requests.get('http://pd4e.com:10090/api', params={ 'prompt':p, 'image':file2b64(i) }) - print(ret.text) + t2 = time.time() + print(ret.text, t2 - t1, 'seconds') diff --git a/conf/config.json b/conf/config.json index bb220ef..21434af 100755 --- a/conf/config.json +++ b/conf/config.json @@ -1,7 +1,7 @@ { "password_key":"!@#$%^&*(*&^%$QWERTYUIqwertyui234567", - "modelname":"Qwen/Qwen2-VL-7B-Instruct", "modelname":"Qwen/Qwen2-VL-2B-Instruct", + "modelname":"Qwen/Qwen2-VL-7B-Instruct", "logger":{ "name":"qwenvl", "levelname":"info", diff --git a/wwwroot/api/index.dspy b/wwwroot/api/index.dspy index 36881a8..ee0bd6d 100644 --- a/wwwroot/api/index.dspy +++ b/wwwroot/api/index.dspy @@ -1,3 +1,3 @@ info(f'{params_kw=}') -return inference(params_kw.prompt, image=params_kw.image, video=params_kw.video) +return await inference(params_kw.prompt, params_kw.image, params_kw.video)