Spaces:
Running
on
Zero
Running
on
Zero
GanymedeNil
commited on
Commit
•
d0c2593
1
Parent(s):
df30ad6
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ import os
|
|
13 |
# subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
14 |
|
15 |
# models = {
|
16 |
-
# "Qwen/Qwen2-VL-2B-Instruct": AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-VL-
|
17 |
|
18 |
# }
|
19 |
def array_to_image_path(image_array):
|
@@ -33,15 +33,15 @@ def array_to_image_path(image_array):
|
|
33 |
return full_path
|
34 |
|
35 |
models = {
|
36 |
-
"Qwen/Qwen2-VL-
|
37 |
|
38 |
}
|
39 |
|
40 |
processors = {
|
41 |
-
"Qwen/Qwen2-VL-
|
42 |
}
|
43 |
|
44 |
-
DESCRIPTION = "[Qwen2-VL-
|
45 |
|
46 |
kwargs = {}
|
47 |
kwargs['torch_dtype'] = torch.bfloat16
|
@@ -51,7 +51,7 @@ assistant_prompt = '<|assistant|>\n'
|
|
51 |
prompt_suffix = "<|end|>\n"
|
52 |
|
53 |
@spaces.GPU
|
54 |
-
def run_example(image, text_input=None, model_id="Qwen/Qwen2-VL-
|
55 |
image_path = array_to_image_path(image)
|
56 |
|
57 |
print(image_path)
|
@@ -108,7 +108,7 @@ css = """
|
|
108 |
|
109 |
with gr.Blocks(css=css) as demo:
|
110 |
gr.Markdown(DESCRIPTION)
|
111 |
-
with gr.Tab(label="Qwen2-VL-
|
112 |
with gr.Row():
|
113 |
with gr.Column():
|
114 |
input_img = gr.Image(label="Input Picture")
|
|
|
13 |
# subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
|
14 |
|
15 |
# models = {
|
16 |
+
# "Qwen/Qwen2-VL-2B-Instruct": AutoModelForCausalLM.from_pretrained("Qwen/Qwen2-VL-7B-Instruct", trust_remote_code=True, torch_dtype="auto", _attn_implementation="flash_attention_2").cuda().eval()
|
17 |
|
18 |
# }
|
19 |
def array_to_image_path(image_array):
|
|
|
33 |
return full_path
|
34 |
|
35 |
models = {
|
36 |
+
"Qwen/Qwen2-VL-7B-Instruct": Qwen2VLForConditionalGeneration.from_pretrained("Qwen/Qwen2-VL-7B-Instruct", trust_remote_code=True, torch_dtype="auto").cuda().eval()
|
37 |
|
38 |
}
|
39 |
|
40 |
processors = {
|
41 |
+
"Qwen/Qwen2-VL-7B-Instruct": AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct", trust_remote_code=True)
|
42 |
}
|
43 |
|
44 |
+
DESCRIPTION = "[Qwen2-VL-7B Demo](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct)"
|
45 |
|
46 |
kwargs = {}
|
47 |
kwargs['torch_dtype'] = torch.bfloat16
|
|
|
51 |
prompt_suffix = "<|end|>\n"
|
52 |
|
53 |
@spaces.GPU
|
54 |
+
def run_example(image, text_input=None, model_id="Qwen/Qwen2-VL-7B-Instruct"):
|
55 |
image_path = array_to_image_path(image)
|
56 |
|
57 |
print(image_path)
|
|
|
108 |
|
109 |
with gr.Blocks(css=css) as demo:
|
110 |
gr.Markdown(DESCRIPTION)
|
111 |
+
with gr.Tab(label="Qwen2-VL-7B Input"):
|
112 |
with gr.Row():
|
113 |
with gr.Column():
|
114 |
input_img = gr.Image(label="Input Picture")
|