ForeverBlue commited on
Commit
2dc4731
路
verified 路
1 Parent(s): c6c2197

Upgrade GRACE-VLM to a live ZeroGPU demo

Browse files
Files changed (4) hide show
  1. README.md +14 -7
  2. __pycache__/app.cpython-313.pyc +0 -0
  3. app.py +102 -0
  4. requirements.txt +5 -0
README.md CHANGED
@@ -3,10 +3,16 @@ title: GRACE-VLM
3
  emoji: 馃Β
4
  colorFrom: blue
5
  colorTo: purple
6
- sdk: static
7
- app_file: index.html
 
 
8
  pinned: true
9
- short_description: Deployable INT4 Qwen3-VL through GRACE distillation.
 
 
 
 
10
  models:
11
  - ForeverBlue/Qwen3-VL-2B-GRACE-W4G128-AWQ
12
  - ForeverBlue/Qwen3-VL-2B-GRACE-BF16
@@ -21,10 +27,11 @@ tags:
21
 
22
  # GRACE-VLM
23
 
24
- Project showcase for **GRACE-VLM: INT4 Quantization-Aware Distillation for
25
  Vision-Language Models**, accepted at ICML 2026. Read the paper at
26
  [arXiv:2601.22709](https://arxiv.org/abs/2601.22709).
27
 
28
- This free static Space presents the benchmark results, a model output, and the
29
- copy-ready real INT4 deployment command. Interactive inference requires hosted
30
- GPU hardware; the model and loader remain fully available for local deployment.
 
 
3
  emoji: 馃Β
4
  colorFrom: blue
5
  colorTo: purple
6
+ sdk: gradio
7
+ python_version: "3.10"
8
+ sdk_version: 5.49.1
9
+ app_file: app.py
10
  pinned: true
11
+ short_description: Try GRACE-VLM on an image, then deploy the INT4 build.
12
+ suggested_hardware: zero-a10g
13
+ startup_duration_timeout: 1h
14
+ preload_from_hub:
15
+ - ForeverBlue/Qwen3-VL-2B-GRACE-BF16
16
  models:
17
  - ForeverBlue/Qwen3-VL-2B-GRACE-W4G128-AWQ
18
  - ForeverBlue/Qwen3-VL-2B-GRACE-BF16
 
27
 
28
  # GRACE-VLM
29
 
30
+ Live demo for **GRACE-VLM: INT4 Quantization-Aware Distillation for
31
  Vision-Language Models**, accepted at ICML 2026. Read the paper at
32
  [arXiv:2601.22709](https://arxiv.org/abs/2601.22709).
33
 
34
+ Upload an image and ask a question to run the GRACE 2B BF16 checkpoint on free
35
+ ZeroGPU hardware. For genuine packed INT4 inference, use
36
+ [`ForeverBlue/Qwen3-VL-2B-GRACE-W4G128-AWQ`](https://huggingface.co/ForeverBlue/Qwen3-VL-2B-GRACE-W4G128-AWQ)
37
+ with the copy-ready [GRACE loader](https://github.com/ForeverBlue816/GRACE#quick-start-real-int4).
__pycache__/app.cpython-313.pyc ADDED
Binary file (4.45 kB). View file
 
app.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import threading
2
+
3
+ import gradio as gr
4
+ import spaces
5
+ import torch
6
+ from transformers import AutoModelForMultimodalLM, AutoProcessor
7
+
8
+
9
+ MODEL_ID = "ForeverBlue/Qwen3-VL-2B-GRACE-BF16"
10
+
11
+ processor = AutoProcessor.from_pretrained(MODEL_ID)
12
+ model = AutoModelForMultimodalLM.from_pretrained(
13
+ MODEL_ID,
14
+ dtype=torch.bfloat16,
15
+ low_cpu_mem_usage=True,
16
+ ).to("cuda").eval()
17
+ generation_lock = threading.Lock()
18
+
19
+
20
+ @spaces.GPU(duration=120)
21
+ def answer(image, prompt, max_new_tokens):
22
+ if image is None:
23
+ raise gr.Error("Please upload an image first.")
24
+ if not prompt or not prompt.strip():
25
+ raise gr.Error("Please enter a question about the image.")
26
+
27
+ messages = [
28
+ {
29
+ "role": "user",
30
+ "content": [
31
+ {"type": "image", "image": image},
32
+ {"type": "text", "text": prompt.strip()},
33
+ ],
34
+ }
35
+ ]
36
+ inputs = processor.apply_chat_template(
37
+ messages,
38
+ add_generation_prompt=True,
39
+ tokenize=True,
40
+ return_dict=True,
41
+ return_tensors="pt",
42
+ ).to(model.device)
43
+
44
+ with generation_lock, torch.inference_mode():
45
+ outputs = model.generate(
46
+ **inputs,
47
+ max_new_tokens=int(max_new_tokens),
48
+ do_sample=False,
49
+ )
50
+
51
+ prompt_length = inputs["input_ids"].shape[-1]
52
+ return processor.decode(
53
+ outputs[0][prompt_length:],
54
+ skip_special_tokens=True,
55
+ clean_up_tokenization_spaces=False,
56
+ ).strip()
57
+
58
+
59
+ with gr.Blocks(title="GRACE-VLM Demo") as demo:
60
+ gr.Markdown(
61
+ """
62
+ # 馃Β GRACE-VLM
63
+ **An ICML 2026 Qwen3-VL-2B student distilled from an 8B teacher.**
64
+
65
+ Upload an image and ask a question. This online demo runs the GRACE
66
+ BF16 checkpoint on ZeroGPU. The primary deployment checkpoint uses
67
+ [real AWQ-packed INT4](https://huggingface.co/ForeverBlue/Qwen3-VL-2B-GRACE-W4G128-AWQ)
68
+ and retains 98% of the GRACE BF16 benchmark average.
69
+ """
70
+ )
71
+ with gr.Row():
72
+ image_input = gr.Image(type="pil", label="Upload an image")
73
+ with gr.Column():
74
+ prompt_input = gr.Textbox(
75
+ value="Describe this image in detail.",
76
+ label="Question",
77
+ lines=3,
78
+ )
79
+ token_input = gr.Slider(
80
+ minimum=32,
81
+ maximum=256,
82
+ value=128,
83
+ step=32,
84
+ label="Maximum new tokens",
85
+ )
86
+ run_button = gr.Button("Run GRACE", variant="primary")
87
+ output = gr.Textbox(label="GRACE response", lines=10)
88
+ gr.Markdown(
89
+ "[Paper](https://arxiv.org/abs/2601.22709) 路 "
90
+ "[Code](https://github.com/ForeverBlue816/GRACE) 路 "
91
+ "[Models](https://huggingface.co/collections/ForeverBlue/grace)"
92
+ )
93
+ run_button.click(
94
+ fn=answer,
95
+ inputs=[image_input, prompt_input, token_input],
96
+ outputs=output,
97
+ )
98
+
99
+
100
+ if __name__ == "__main__":
101
+ demo.queue(default_concurrency_limit=1).launch()
102
+
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ accelerate==1.13.0
2
+ pillow>=12,<13
3
+ torch==2.8.0
4
+ transformers==5.9.0
5
+